LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determining the number of samples in the buffer of a continuously capturing device

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.

 

 

0 Kudos
Message 1 of 3
(4,049 Views)

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.

 

temp1.jpg

 

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:

 

 

temp1.jpg

 

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.

 

Smiley Happy Hope that helps!!

______________________________________________

Bandan Jot Singh | Applications Engineer | NI India
______________________________________________
Message 2 of 3
(4,034 Views)

Note that there are similar methods for NI-SCOPE and NI-HSDIO devices.

0 Kudos
Message 3 of 3
(4,019 Views)