LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to save data from a while loop periodically

Hello All,

 

I have two while loops one running inside the other. the second while loop is continuously streaming data which I want to save to an excel file after every few seconds (12 seconds). I am using a 16 bit ADC. I tried using timed loops with iteration period as 12 seconds. I do believe there might be easier ways to do this. Could someone share their opinion on this?. I am attaching an image of the block diagram without any timing structure

 

 

Regards

Sud 

 

0 Kudos
Message 1 of 4
(4,142 Views)

Saving data to a file is usually best done in a separate loop via a queue.

 

For an example of this type of structure, check the template:

File -> New -> Producer/Consumer Design Pattern (Data)

 

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 4
(4,138 Views)

Why do you have the outer while loop? 

 

If you want to save the data, take the other advice in this thread.  Set up a parallel while loop.  Use queues to pass the data from your acquisition loop (producer) to the secondary loop (consumer).  You can use whatever logic you'd like in the consumer loop to log the data.  You can log each point as you get them.  You can check for a number of elements in the queue before pulling them out and log it that way.  Log however you wish.

0 Kudos
Message 3 of 4
(4,119 Views)

It  depends on the data acquisition rate:

 

For high speed acquisition where data could be lost while processing and writing to disk use a producer-consumer architecture.

 

For low speed acquisition where there is time to process and write to disk before the next acquisition a simple state machine architecture works well enough.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 4
(4,101 Views)