LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read and display data with OR without recording at the same time?

Hi all,
  This forum has been of much help to me, but I have a rather specific question I can't seem to find an answer to.  I am new to LabView, educating myself with tutorials, trial and error, and this forum. 
  Attached is what I have so far.  I would like to read data (three voltages) and write it to an excel file.  As written below, it will do nothing until I click the "Record" button, when it then takes data, displays it on the gauges and waveform chart, and writes it to a file.  What I would like it to do is display the data at all times, and record when I click the record button (while still displaying data being read).  I have tried to do this by moving the DAQ Assistant VI, gauges, and waveform graph outside of the loops, but when I do this, it will read until I press record, and then it simply records whatever value it's stuck on.  Sorry for the long post, thanks for any help. 
  --Nathan
0 Kudos
Message 1 of 4
(2,908 Views)
Sorry, I don't have any DAQ installed, so I won't comment on the DAQ parts.
 
First of all, Your VI will do nothing until you (1) first set the record button to ON  and (2) press the start button in the tool bar. It almost seems that you are using the "continuous run" button. (Don't! That's not its purpose. Basically, it automatically restarts the program whenever it finishes). A toplevel VI should never stop during normal operation, so place a big while loop around all code and create a wait state that does nothing until you tell it to acquire.
 
You don't need the inner while loop, simply place your code inside the big while loop (and accumulate your array data in an initialized shift register if really needed. Currently you do at the inner loop boundary for some reason). You have a big problem that the array can grow without bounds unless you clear the accumulated data once in a while or place it in a FIFO buffer of limited size. If you let ot grow forever like you do now, the program might run out of resources at one point in the future.
 
Since you are appending to your file, maybe yo don't need any shift register, just use the data points of the current iteration. Place your save operations in a case structure and keep appending the new data to your file only if the case is true.
 
It is also very inefficient to use highlevel file IO here,because each instance opens and closes the file. I recommend to open the file once outside the loop, then use low level IO to append, and close the file once the big loop is done.
0 Kudos
Message 2 of 4
(2,896 Views)
Thanks for the reply.  I figured I was doing at least a few things ridiculously inefficiently.  Part of the learning process I suppose.  Thanks again. 
0 Kudos
Message 3 of 4
(2,892 Views)

I would suggest one way as using the Producer/Consumer loops with queues and event structures.  You can find some info on that here;  http://zone.ni.com/devzone/cda/tut/p/id/3085

Or, even more simply, use a simple event structure in a while loop.

You could put your read data code in the event structure timeout node wired to your time between reads.  Then when you hit the record button, a different "record" event case will run which will have your write to file code.  You can pass the data from one event case to the next through shift registers in your while loop.

0 Kudos
Message 4 of 4
(2,891 Views)