LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital counter data is not written into a file

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

Message 11 of 16
(866 Views)

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.

0 Kudos
Message 12 of 16
(843 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 13 of 16
(829 Views)

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?

0 Kudos
Message 14 of 16
(812 Views)

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?

0 Kudos
Message 15 of 16
(801 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 16
(794 Views)