LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save data every few seconds in a control and simulation loop

Hello everyone,


I am running a control simulation where I created a sub VI to write the data to the file. However, the total data that I receive is extremely large (for a 10 second run time I get around 20000 data points) and hence I thought of saving the data at every few seconds.
So far, the only solution I can think of is using the while loop. But, any use of a while loop inside the sub VI is making the code get stuck there which results in the main VI not working.
I thought of the producer/consumer loop but am not sure if it would be applicable to the simulation loop. I cannot think of any other way to introduce a timing function or a way to reduce the data in a simulation running continuously.

I'd really appreciate some guidance in approaching this problem.

 

Thank You!

 

Download All
0 Kudos
Message 1 of 4
(2,429 Views)

You should not have any difficulty in streaming data to disk (your data rate is 2 kHz, certainly no problem).  Without seeing your VI (don't bother attaching a picture, I can't learn enough about your code by looking at a picture), it is difficult to say much more.  Certainly a Producer/Consumer design makes sense, but it also depends on how the data are being collected (DAQmx?  VISA?  Produced by a simulation loop?) and how it is "presented" (an array of N points every S seconds?  A Waveform?  Single points at a rate of 2 kHz?).

 

I presume you have a While loop that is generating the data.  That's your Producer.  Create another While Loop to "consume" the data, and use an asynchronous transfer mechanism such as a Queue or Stream Channel Wire to transfer the data from Producer to Consumer.  Give it a try, and if it doesn't work, attach your VI and come back to the Forum.

 

Bob Schor

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

Great article here on Streaming Data to and from Disk.  

 

Links to different strategies etc.  

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 3 of 4
(2,424 Views)

Bob,

The data is being produced by the simulation loop and presented in the form of 1D array to the array to spreadsheet string.I tried to use the while loop to save the data every few seconds. I understand a VI would be needed to know more. Unfortunately I would not be able to attach it as of now. 

As suggested, I will give the producer/consumer design a try. 

Thank you for your help!

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