12-19-2011 01:15 PM
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() ?
Solved! Go to Solution.
12-20-2011 03:13 AM
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?
03-05-2012 12:48 PM
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.
03-05-2012 03:49 PM
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.
03-09-2012 03:23 PM
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.