05-27-2015 01:48 PM
Instead of putting the Write loop to the right of the Acquisition loop, and wiring the Queue In (to the Write loop) from the Queue Out of the Acquisition loop, put the Write loop below the Acquisition loop (it really doesn't matter where you put it, but it will be clearer this way) and wire the Queue In to the Write Loop to the same wire that is the Queue In to the Acquisition loop.
Queues are "data conduits". When the Acquisition loop puts something on the Queue, any executing function can take it off (the data doesn't really "flow backwards" down the wire). In your example, the reason that the dequeue didn't work was that the dequeue function was not executing until the Acquisition loop ended and all of the inputs to the Write loop were satisfied.
Bob Schor
05-28-2015 02:39 AM
Ok, I wired the queue to the write loop after "obtain queue" but still outside of the acquisition loop. Is this what you meant?
To get the time I added "Elapsed Time" VI to the acquisition loop and wired Elapsed Tme (s) to the build array. Now the output file shows a time column but the values mostly repeat themselves like this:
time (s)
0,00000
0,00400
0,00400
0,00400
0,00600
0,00600....
I assume that Write to measurement file VI has some in-built timer since when I was using it getting the time wasn't a problem.
05-28-2015 05:57 AM
I recommend reading the data as an array of waveforms and sending the waveforms through the queue. The waveforms have timing information that the Write Measurement File can use.
05-29-2015 02:13 AM
So close but not quite there!
Now the measurement works otherwise perfectly but the writing loop of the upper acquisition loop drags behind (as expected). When I run the program for example 800s only 200 seconds of analog data is saved to the file. I tried making a logic circuit that would allow the writing to finish when Stop button is pressed but it didn't work.
How could I make sure that all the data from the queue is saved before the program completely stops?
05-29-2015 03:27 AM
Quick update to my previous post:
I made a numerical indicator for # elements in the queue. When stop is pressed the number starts to go down all the data is saved given enough time. BUT with measurements that last for several minutes (~15min) the writing would take longer than the measurement itself.
So a more refined question would be that can the data writing loop made any faster?
05-29-2015 06:57 AM - edited 05-29-2015 06:58 AM
Yes, writing the data to file is SLOW. So what can you do to speed it up? Write more data in a single write. My trick here is to put the Dequeue in a FOR loop that ends when there is a timeout (timeout is set to 0). I use a FOR loop in order to limit the number of items will be written to at a time. You will just need to do a little playing around to combine your waveforms after the Dequeue loop.
This code has not been tested, so no guarantees that it is bug free.