Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 69267

Problem saving data to file using for loop

$
0
0

I am trying to write 1-D sampled data to a measurement file every 10 samples for efficiency. I have a producer-consumer architecture so that the acquired data is enqueued in a separate while loop. The consumer loop dequeues the data and builds an array in a for loop, and writes to the lvm file when N=10 samples have been accumulated.

 

The user interface has a FileSave button (switch when pressed, handled in an event loop) that controls whether the incoming data is Enqueued for writing to the measurement file. Each time the File Save button is pressed, a new file is created with the number appended to the base filename is incremented. (This is handled automatically by the Write to Measurement file Express-VI). Data is written to the file as long as File Save is on. This is all working as desired, except for the following:

 

In the consumer loop, the FileSave local variable terminates the for loop. However, on the second and subsequent times File Save is started and stopped, the beginning of the new file contains "old" data (always less than N samples), and I suspect that it's because the For loop is terminated with a partially-built array, such that the next File Save continues building on the array with the old data. What I intended is that the for loop terminates before completing N passes, and the next time it starts, the array is built up from scratch and the partial data is lost, which is ok. However, I'm not sure whether my code does this correctly, and I'm looking for some insight on this. I've posted screenshots of the consumer loop showing the array being built and also the saving to the file.  

 

Thanks in advance for your help.

 

FileSave_screenshot_1.png

FileSave_screenshot_2.png


Viewing all articles
Browse latest Browse all 69267

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>