Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous acquire using DAQmxReadAnalogF64 returns the same values

I am trying to use DAQmxReadAnalogF64 in a continuous acquire application but i seem to be reading the same values for several scans before
they change ( I am reading from a simulated device PCI6133 in MAX). I am basically using the example provided by NI with a few changes for
sampling and timing. my sample clock and read implementation are below. I have set the samples to read to -1 so it should read all the
samples in the buffer.

 

DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,100));

 

DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,-1,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));

 

I am not quite sure when the buffer is cleared. Is it cleared after a read? If so then could it be that my read array still has the old
data before the next read and that is what i am seeing. In Labview if you try and read and there is no data in the buffer you get an empty array. This does not seem to be the case with DAQmxReadAnalogF64.

 

Anybody have any idea why i would be reading the same value for several scans before they change?

 

Thanks in advance.

0 Kudos
Message 1 of 2
(3,570 Views)

wewe,

 

Once a DAQmx task is started, the buffer should not be cleared until the task is stopped (this buffer is internal to DAQmx, and separate from the buffer you pass to the DAQmxRead function).  When you call DAQmxRead, DAQmx will transfer data out of its internal buffer and copy it to the buffer you pass the function.  By default, DAQmx should start by reading the first sample acquired, then each subsequent read should return data starting from where the last read sample.  I see that you're configuring your device to acquire data at 10 Hz.  How often is DAQmxRead being called?  Are you examining the sampsPerChanRead parameter after read returns?

 

Since your acquisition rate is fairly slow, and you're configuring DAQmx to read 'all available samples', it is certainly possible that DAQmx has no samples available and returns immediately without modifying the the buffer you pass it at all.  In this instance, I would expect it would pass zero back to you via the 'sampsPerChanRead' parameter.  As a result, you should never process more data out of the buffer you pass DAQmxRead than the amount specified in the 'sampsPerChanRead' parameter.

 

If this is what you are seeing, it would be considered correct behavior.  You can check how many samples are available in the buffer at any time using the DAQmxGetReadAvailSampPerChan function. Additionally, if you would like DAQmx to return you a specific number of samples, I would recommend against passing '-1' for the 'numSampsPerChan' parameter and explicitly requesting a certain number of sample with a reasonable timeout.

 

Hope that helps,

Dan

0 Kudos
Message 2 of 2
(3,564 Views)