LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding DAQmx, waveforms, and queue data flow

Solved!
Go to solution

Hello,

 

I am writing a program that has two analog voltage input channels via DAQmx, read into a producer loop as a 1D array of Waveform(DBL), queued to the consumer loop, de-queued, indexed to subarrays to separate the channels, then will be merged into a signal with a couple other data points, and saved in a TDMS file. Ultimately, I want to take the second channel (current data) and set a software trigger of sorts to record data for a set time or set number of samples after the current exceeds a threshold.

 

I am not understanding the fundamentals well, however:

- When using DAQmx with continuous sampling, there's the hardware buffer (that I'm not worried about) and the software buffer that I can adjust values accordingly to not be an issue, in accordance with the DAQmx read function. No issue in this understanding, right?

- I read the data as an analog 1D waveform (Nch Nsamp) and queue it up, then dequeue it, so I'm not too concerned about the queue sending the data, as the data will be received in order (lossless) and shouldnt affect any timestamp or anything along the way. Easy, right?

- I think the issue comes down to not getting the waveform datatype. I have a 1D array of waveform data because of the two channels I am sampling from. So I use the index array to parse to my separate channels, which are just waveforms. I know waveforms have attributes: start time (t0), change in time from point to point (dt), and then a 1D array of DBLs.

 

So when my consumer loop goes from iteration to iteration, what exactly is happening with t0, dt, and 1D(DBL)? Is the data in 1D(DBL) a window that gets refreshed every iteration? Or does it shift a value every iteration? When monitoring a value for exceeding a threshold, do I just reference the first value in the 1D array and assume it will slide? Or do I have to search the whole 1D array (window) every iteration for a value that exceeds?

 

Thanks very much for the help and I apologize for wordiness.

 

Pearse

0 Kudos
Message 1 of 4
(2,423 Views)

The waveform data is only the information read since the last read.  So you will need to search through all of the Y data in order to look for your threshold.


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 4
(2,388 Views)
Solution
Accepted by topic author pswail

Assume you are sampling 2 Analog channels, sampling 1000 points at 1 kHz, and have configured your DAQmx Task for Continuous Input.  Your DAQmx Read (inside a While Loop) is configured with 1000 wired to samples/channel, and configured for N Chans N Samples, 1D Array of Waveform (Samples).  Let's say you run the loop 5 times, getting 5 1D Array of Waveforms.

 

For simplicity, let's consider only Channel 0, so the first element of the 1D Array of Waveforms.  You have 5 Waveforms.  Consider the three components, t0, dt, and Y.

  • t0 is the time that the data were acquired, so you'll each goes up by 1 second (as it takes 1 second to acquire 1000 points at 1 kHz and we are recording continously).
  • dt will be 0.001000, as all the waveforms have the same sampling rate, 1 kHz, or 0.001000 seconds/sample
  • The Y arrays represent consecutive 1000-sample points -- you could "assemble" them (by concatenating the Arrays, say) and have a continuous 1 kHz sample of a data channel.  If you are going to analyze sections of the data that starts in one Array and ends in the next Array, you'll have to think of how to handle this computation.

Hope this helps with the confusion.

 

Bob Schor

Message 3 of 4
(2,376 Views)

Thanks very much, to both of you, but Bob your description with a little more playing around led to a workable (on the cusp of elegant) solution. I ended up modifying the sampling rate and number of samples to fit my data better, then played with some timing and building signals to get the data storage I needed. It took a little longer than it should have, but those are the growing pains of learning a program like LabView!

 

Thanks for your help!

 

Pearse

0 Kudos
Message 4 of 4
(2,311 Views)