LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving all data from a while loop

Solved!
Go to solution

I do not have the Mathscript module, so using it is not an option for me.

 

In general I would say that the appropriate times to use it are when you have existing Matlab code which is proven to work, is complicated or lengthy, is not too likely to be changed, or which implements functions not readily available in LV. Where the trade-off points are in any project will depend on your relative experience with the two programming environments as well.

 

When converting code between the two languages, keep in mind that LV starts array indexes at 0 while Matlab starts at 1 (I think).

 

Lynn

Message 11 of 17
(1,259 Views)

Thank for the tip.  I have a little bit of problem on the saving, if I use write to waveform and set append = True. The file gets bigger but when I retreive it, it only return 1 second of data.

 

My loggic is that I use the queue store and retrieve the data, even only 1 element in queue get enqueue each loop- should I be able save all of the information?

0 Kudos
Message 12 of 17
(1,251 Views)

There is a subtle effect in the Write Waveform to File.vi Read Waveform from File.vi. They write "records" which consist of an array of waveforms. Each time called one record is written or read.  So, to get all the data, you need to read multiple times.  The detailed help does describe this but it is not so obvious.

 

Look at the attached test Read VI. It reads successive records until Error 4, End of File encountered occurs.

 

Also, the VI I posted yesterday will not stop properly because I did not wire the queue reference through the Stop event case. ( I wish tunnels on the event structure did not default to Use Default if Unwired!). The attached version is cleaner.

 

Lynn

Download All
Message 13 of 17
(1,244 Views)

johnsold,

I appreciate all the help.  If you don't mind if I ask you one more quewstion. there is a thing that is not very clear. Instead of saving the waveform into 1 waveform. Each loop acctually save the data into another waveform - if there is N time of loops, then there is an N waveforms (to compare with 1 waveform with N*duration of 1 loop).The read waveform vi does return a multiple of waveform not a single waveform.  

 

In order to get a 1 waveform, I need to read each waveform in saved file and then combine all saved waveform togther into 1 sinlge long duration waveform?

0 Kudos
Message 14 of 17
(1,232 Views)

That is correct.  Be careful when you do this to ensure your data is actually contiguous (does not have time gaps).  The waveform concatenation VI should give you an error if you do.

Message 15 of 17
(1,217 Views)

Smiley Surprisedthank you both.

😛 that why I only saw 1 second of the data while still seeing the file size get bigger.

Can you tell me what is the technique (function) to ensure there is no gap?

 

 

0 Kudos
Message 16 of 17
(1,207 Views)

If you are streaming data from a continuous generation to the LVM file, you should be fine.  If you are taking non-continuous data sets and streaming those to the LVM file, your data is not continuous.

 

Under the hood, the concatenation routines check the t0, dt, and number of points and confirm that the first point of the second waveform is at the correct time position based on the timing of the first waveform.  t0 and dt of both waveforms also need to be equal.  Note that "equal" is fuzzy to account for rounding errors saving data to disk and restoring it.

0 Kudos
Message 17 of 17
(1,199 Views)