LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to; Counting data in a array of waveforms.

Solved!
Go to solution

Hi,

I have a DAQmx Read that sends 4-channel data in a waveform array. There is 3-7 doubles in each channel. How can I count the amount of doubles in each channel  during a running measure? To use arraysize on the waveform would be ok if the amount of data in each waveform is constant - but it's not.

Is the only method to use a For-loop and split up the cluster and count the data in each waveform?

 

Background:

DAQmx feeds a ringbuffer and a graph. When TrigOn happens the ringbuffer is saved first (TDMS), then the saving continues until trigg-off.  I want to check the number of doubles included in the pretrig buffer that is saved first. 

Mazy?

0 Kudos
Message 1 of 5
(1,236 Views)

Are you sure about that?  I've never known of a DAQmx Read call that would return waveforms whose data arrays contained different #'s of samples.   Maybe one loop iteration they all have 3 samples and another iteration they all have 7 -- that's definitely possible.  But in any one call each channel should have the same # samples.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 5
(1,192 Views)

Of course you are right. I explained bad. I have A0..A3. In one (I don't know what to call it in english) "row" all four have 3 doubles. Next fetch they have 5 doubles. It varies.

 

Just before reading with DAQmx Read I have a loop with AvailSampPerChan > 1. Why? I saw that some times was the array of doubles in each waveform zero. No data. 

 

edit: I think I got it now. I should work with digging holes in the ground or something instead of programming...so stupid.

0 Kudos
Message 3 of 5
(1,177 Views)
Solution
Accepted by TakeANap

The simpler solution is to just tell the DAQmx Read to read X samples.  It will sit there and wait for that number of samples to be in the buffer before giving them to you.  Then you always know how many samples are in your waveforms, unless of course there is an error.


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
(1,162 Views)

Yes. That is exactly what I did. I used AvailSampPerChan and set that to 10. Then I called DAQmx Read and suddenly I got 10 doubles in every "collect". I initialized also the Ring Buffer to store X rows of waveforms containing the data. I got the pretrig I wanted.

 

The problem is that I haven't study DAQmx (and waveforms) in detail. Now I know more. 

 

 

0 Kudos
Message 5 of 5
(1,153 Views)