LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer Consumer Data Acquisition

Hello everyone,

 

Over the past few days I've been hammering out what I think is a pretty nifty little program. I'm attempting to log data from an analog input channel at resolutions of around 1 ms using NI's USB 6009. Since the 6009 does not support hardware timing I've opted for producer/consumer daq and write loops respectively. This has worked wonderfully, allowing me to achieve far better resolutions that I might have otherwise. However, I find myself suspicious of the sampling resolution. Are these timestamps simply manufactured along with the acquired waveform, or is data queueing really that powerful? I guess what I'm wondering is how well does the data I'm collecting represent real-time readings.

 

Thanks,

Travis

0 Kudos
Message 1 of 5
(2,842 Views)

The queuing of data is quite powerful since you break up the processes.  However, I would make a major change to your program.  For the Analog Input, do not use the express VI.  Setup the analog input task before the loop and close it after.  Then inside the loop, use the DAQmx Read set up to be Single Channel, N Samples Waveform.  By reading the waveform, the timestamp is included for free.  And when you setup the timing of the task, use Continuous Samples.  Your 6009 does have hardware timing for the analog input, so by all means use it.

 

I would also use the DAQmx Streaming to TDMS feature to have your data go straight to a TDMS file instead of making your own.  It will be even faster than your producer/consumer.


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 2 of 5
(2,831 Views)

Thanks for the suggestions.

 

I'm actually using the N Samples Waveform option because I'm collecting data for a specific interval after a trigger. The timestamp is initialized in the producer loop because it's used in the consumer loop to calculate elapsed time specific to each log interval. Are there many advantages to TDSM streaming?

 

Travis

0 Kudos
Message 3 of 5
(2,821 Views)

@tdb867 wrote:

Thanks for the suggestions.

 

I'm actually using the N Samples Waveform option because I'm collecting data for a specific interval after a trigger. The timestamp is initialized in the producer loop because it's used in the consumer loop to calculate elapsed time specific to each log interval. Are there many advantages to TDSM streaming?

 

Travis


Even still, reading as a waveform will give you a better timestamp than the Get Date/Time.

 

The Stream to TDMS makes life so much easier since you don't have to do the logging yoruself.  And TDMS also allows for metadata to be included in the file.  This metadata could include channel name, sample rate, task configuration settings.  And TDMS is a binary file, so it will take less disk space than your CSV file.  You just won't be able to read the data with a text editor.  But there is a free plugin for Excel to read the TDMS files.


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 4 of 5
(2,818 Views)

I guess what you're suggesting then is that I use the 0 index of my timestamp array as the initial timestamp value, correct?

0 Kudos
Message 5 of 5
(2,805 Views)