LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

producer consumer timing

It depends on the time reference you want. If you want to reference time on when you started taking data in seconds then it would be easy. A 2D array with one colum as time (seconds) and one as data. If you need the actual time and date then the waveform would be the way to go. Now you could use the waveform data nd conver that you seconds and then use the 2D array again.

Tim
GHSP
0 Kudos
Message 11 of 17
(835 Views)

hang on a sec

 

If I set my sample rate, in the MAX task to the same as the producer/consumer loops (10ms in there, so 100Hz on the task sample rate) I get near perfect 1 second increments in my log file. If I increase my rate in the MAX task, then that cuts my log file time increments by the same factor. So if I set a 200hz sample rate I get time stamps half a second apart instead of a second apart. All the while the file is only being written to at 1 per second, so the write time doesnt match the time in the log file.

0 Kudos
Message 12 of 17
(834 Views)

I dont need the time and date no, I just need it to start from zero and count up in seconds, minutes, hours until I stop the whole thing manually when the test is done.

0 Kudos
Message 13 of 17
(832 Views)

This should give you what you are looking for for time and data.

Tim
GHSP
Message 14 of 17
(821 Views)

In the example project you posted, I found the buffer size to be 2. This probably accounts for the differences you are finding. Try it set to 1. You could also get rid of the Wait in the upper lop. Setting the DAQmx task to 50Hz sets the pace at which data will be available for reading.

 

JohnCS

Message 15 of 17
(802 Views)

Thanks for the help guys, I think I can muddle through with this now

 

Removing the delay and setting the bufffer back to 1 (sorry was mistakenly set to 2) seems to have done the trick. I just need to figure out stopping the loops now, I think my current stop stops the writing but the VI is still running, its not exited.

 

Tim thanks for playing with my VI's.

 

That last one you did looks good, though I get an error upon exiting, something about there being an invalid character for the dequeue process. Also it outputs the data in a funny way, but doing as JonCS suggested, I can keep the wave forms and it will log at 1 per second and record the right time!

 

So again Thank you very much guys!

 

Alex

 

0 Kudos
Message 16 of 17
(786 Views)

To make the error on exit go away: In the original code, disconnect the error in to the Destroy Queue and rewire it from the error cluster in the lower loop.  Use a local variable on the stop button to halt the lower loop instead of the error cluster. Here's what happens now: hit stop, upper loop quits after the next DAQmx read, loop stops, the queue is destroyed. Meanwhile the lower loop is waiting for the time out, seeks to dequeue the data but the queue has been destroyed resulting in an error and that stops the loop.  It is important to maintain the data flow.

 

A clean way to stop might be to send a code in the data queue that means I want to quit. Lets say that-1 in the waveform means quit. So put a -1 in the queue when the stop button is pressed. Then check for a -1 when the data is dequeued, write a terminal message to the file and then quit the loop.

 

JohnCS

 

 

0 Kudos
Message 17 of 17
(774 Views)