10-26-2021 01:38 PM
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?
Solved! Go to Solution.
10-26-2021 05:11 PM
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
10-27-2021 12:18 AM - edited 10-27-2021 01:17 AM
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.
10-27-2021 07:31 AM
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.
10-27-2021 02:33 PM
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.