LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with plotting multiple XY spreadsheets (program generates repeated data)

Solved!
Go to solution

Hello,

 

I want to make a small program which will reduce the amount of time to proceed with measurement data. I get the data in the .dat format, where every file consist of measurement spectrum with one X and one Y column. The problem is that I did 4 experiments (X column is same for each experiment) with 15 measurements file each, and more than 500 measurement points in each file. I would like to do some simple manipulation with that data and copy that information to one file with same X column and multiple Y columns, so later I could use this data with Origin or Excel (doing this manually is frustrating and time consuming).

 

In  the beginning my program reads background information with X and Y(b), and after I open spreadsheet to insert the X and Y(n) data. (doing some simple manipulation, like dividing Y(n)/Y(b), program show on one graph current data and on another graph multiple datas, which are stored and need to be exported to .txt, .dat or directly to Excel (which is more preferable)). I am OK with opening several data files, but not OK with copy/pasting to file and manipulating all that data  manually, that is my motivation to make this program.

 

The example which is attached can do all this (except for writing to file). It plots several graphs on one XY graph via use of cluster and shift registers. It is even possible to extract all that data in Excel from the graphs, but the real problems comes with data being always added because of the loop. This gives a lot of empty and later repeated data. I am lacking to get rid of this. I've also attached several measurement files: 1 background and 3 measurements.

 

P.S. I tried to save time by making this program, but now I've spent more time than if I did this manually 🙂

Download All
0 Kudos
Message 1 of 6
(2,716 Views)
Solution
Accepted by topic author Svojlt

Your program makes absolutely no sense. What's the purpose of the sequence structure? It just sits there, running once in parallel to the the while loop. Most likely you read from local variables before other parts of the program had a chance to write valid data to them.

 

In the while loop, you have a timeout case that appends the same data over and over, every 50ms. Why?

 

Your "switch until released" mechanical actions are ill advised. Use latch actions and remove the case structures inside the event frames.

 

Try to rethink the problem once mode, then solve the problem with 20% of your current code. See how far you get.

Message 2 of 6
(2,711 Views)

Thank you.

 

After revising help on Event structure and your coments could fix it to smaller code.

 

Although there are some minor problems left, such as additional XY columns for background (begining of the code) and after pushing the Stop button.

Is there are a method to save it with one X and several Y columns? It is possible to save data directly from the graph (right click on the graph), but the data  I receive has X column for every plot.

 

Thank you one more time for giving me some push to solve this problem

0 Kudos
Message 3 of 6
(2,687 Views)

A couple of pointers:

 

  • If there is no timeout, you don't need the timeout case.
  • If the buttons are latch action, you don't nee the inner case structures. the values will always be true.
  • I would initialize all shift registers
  • If you place the boolean terminals inside their respective events, they (and the event case) will be easier to find during editing and debugging.
  • latch action terminal always belong inside their event case, so they properly reset when the event fires.
  • Use "index array" instead of "delete from array" to get a row or column. It is even reiszeable.
  • Use complex arrays for xy graph. Less clutter.
  • The "build xy graph" express VI is just baggage here.
  • "latch when released" is preferable to "latch when pressed". If you press down accidentally, you can move the mouse off the control and it will not trigger.
  • You don't need to label the event cases if the free label just repeats the event name. Too redundant!
  • To save with a singe X column, just use a FOR loop as shown.
  • ...

Here is a quick draft (LV 2011). It is not tested, so modify as needed.

Message 4 of 6
(2,668 Views)

Thank you, this is much more simplier VI.

 

Never knew that complex arrays could be used for XY graphing. Although mine LV experience is not so big.

I've modiefied the program. Just separated the Stop and Save cases, because if you Stop the VI it will ask to save the data,

and if you Save the data and then Stop it will add last Y column one more time.

0 Kudos
Message 5 of 6
(2,650 Views)

Yes, you definitely need to build the array of xy plots inside the appropriate event case. the currently very simple implementation does not deal well with randon user inputs. You might even add an event case to remove existong plots.

0 Kudos
Message 6 of 6
(2,625 Views)