I am currently using the USB-6212 for data collection. I am experiencing ~ 30msec read latency when I call DAQmxReadAnalogF64. I am collecting ~ 2.6 msec of data (65 samples * 25e3Hz sample rate). Is this a limitation of USB-6212? Can I reduce this latency some how?
here is the cal that I am using
DAQmxErrChk(DAQmxReadAnalogF64(taskHandle_AI, samplesPerChan, timeOutAI_sec, DAQmx_Val_GroupByChannel, dataAI, arraySizeSamps, &readAI, NULL));
The 30 ms read latency is not caused by a limitation of the USB-6212.
The way the DAQmxRead function works is when you send it to the device, the device starts to sample and sends the sample buffer back to the computer, and that data is read from the computer's memory and then delivers the information to you. The whole process introduces some latency, and reading the 65 samples from your memory can also be very time intensive, especially in Windows, as thread switching to read in the data will take up time. WIndows also has a clock resolution of 1ms, so if you are constantly trying to gather data continuously every 2.6ms, you would only be able to be accurate on the Windows side to 3ms. One possible fix is using a DAQmxStart function which will start the device sampling, and constantly saves data to the buffer and memory. This allows you to read in information from the memory without having to start the device acquisition every time. Another possible solution is increasing the amount of data points you are reading in for a more efficient use of memory, and then separating out the 65 samples from the larger chunk of data.
How often are you calling the DAQmxRead function?
Data collection is triggered by an encoder wheel. Typically, I'm calling the DAQmxRead function every 50-80 msec, but I would like to get this down to the 5 - 10 msec range. I need to syncronize the data collection with each position measurement. Having a running the DAQ collect a monolithic data chunk is not really the solution I'm looking for. I'm planning on switching to an X-series daq with hardware retriggering, which will hopefully solve this problem. However, it is delayed about a month and want to see how fast I can get the data collection in meantime. Any help is appreciated.
What might be a solution to help speed things up until you get your X-series is to set the data to only me recorded when the encoder reaches a certain point while constantly reading in data. This will help alleviate some of the time needed to start the measurements when acquiring the data as well as some of the memory access time. When you install NI-DAQmx, it should have also stored some examples within your file system. I would suggest taking a look at the example called: ContAcq-IntClk-DigStart-Retrig.c. While this my not be exactly what you are trying to do, it seems like a good start.
For more information on finding examples for text based programming, see these two Knowledge Base articles: