11-17-2010 09:23 PM
Is there a way to ask a continuously capturing NI-DAQmx device how many samples have accumulated in its buffer? I looked around, but couldn't find the answer to this.
I wanted to set up my data capturing such that if there are
0 samples, wait until there are some samples in the buffer
1 - 24 samples, read all the samples from the buffer
25 or more samples, read exactly 25 samples and discard the rest
It doesn't seem like there is a way to set this up to automatically occur, so I thought I would write code to explicitly enable this. Simply reading the entire contents of the buffer came close to what I wanted, but sometimes I would encounter an empty buffer, the reason for which is still a mystery to me, since my sampling rate is so much faster than my loop execution rate.
If there isn't a method of determining the sample count inside a buffer, then I guess I'll just settle for reading the entire buffer and then counting the size of my array, and reading the buffer again if my array size is zero. This seems inelegant though, since sometimes I'd be reading samples that I intend to discard.
If anyone has any insight to share I would be greatly appreciative.
11-17-2010 11:09 PM
There is a method to determine number of samples that have been acquired , and number of samples that are available per channel using the DAQmx Read property node. Give the refnum of DAQmx Read VI to this property node.
Similarily on DAQmx Write side , there is a property node which tells you about: Space left in Buffer , Total elements written to buffer and current Write position:
Use both property nodes and use the outputs to develop cases so that you control data acq. as per the samples available in the buffer.
Hope that helps!!
11-18-2010 08:29 AM
Note that there are similar methods for NI-SCOPE and NI-HSDIO devices.