LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NiDAQmx limit on maximum number of analog samples that can be read / buffered?

Solved!
Go to solution

I am attempting to continuously collect analog samples on 2 channels from a USB-6363 at 1000Hz.  Everything is working until I start increasing the number of samples to read at one time in DAQmxReadAnalogF64().

 

I configure the buffer in DAQmxCfgSampClkTiming() as twice the amount of samples I want to read at any given time.

 

Up to about 8000 samples (128,000 bytes: 2ch x sizeof(double) x 8000) this works and the read call returns without timeout about once every 8 seconds.  Increasing the number of samples beyond this, I can no longer read data (the DAQmxReadAnalogF64() call always times out).

 

Question: am I running into a limit on the maximum number of samples that can be read or buffered....perhaps a DMA limit of some kind?  What determines how large you can make the buffer in  DAQmxCfgSampClkTiming() ?

 

0 Kudos
Message 1 of 5
(3,470 Views)

It may be a silly answer but... are you setting the timeout on DAQmxReadAnalogF64 according to the number of samples to read and the sample rate?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(3,463 Views)

No...I set a timeout of .2 seconds, but I call DAQmxReadAnalogF64 continuously.  It should just time out until the samples are available, but above a certain number it ALWAYS times out, no matter how long you wait.

0 Kudos
Message 3 of 5
(3,418 Views)
Solution
Accepted by topic author Kaha

This may not be obvious from the documentation, but if you look at the output value from the Samples Per Channel Read parameter of DAQmxReadAnalogF64 function, you will see that when it times out, it reads what was available when it timed out. So if you are continously calling this function, and your timeout value is too short, then you will always timeout, but you will still catch every sample. You can think of this as the function will return when either the buffer is full, or the timeout is reached. That is why we provided an output of the actual number of samples read.

 

Typically, you do not poll read like that with DAQmx. I would recommend registering a callback for EveryNSamples (there is an example that ships with CVI on how to do this), or specifying a longer timeout than it will take to actual collect that many samples (in your case, 8000 samples at 1KHz would be > 8 seconds). The main problem with polling with a short timeout is that you have to ignore run-time errors which is not recommended.

National Instruments
0 Kudos
Message 4 of 5
(3,410 Views)

Ah bingo, I didn't realize it was returning a partial read.  Yes in my application I need to do polling.  Works great now.  Thanks.

0 Kudos
Message 5 of 5
(3,396 Views)