03-27-2019 10:36 AM
Hi,
I need to avoid pc buffer overflow error in my code. When reading the following article, it is suggested that the read rate (DAQmx Read) and sample rate (DAQmx Timing) should be same to avoid this error.
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019KTeSAM&l=de-DE
But going through the following article on DAQmx Timing and Sample Rates, it is recommended that the number of samples be 1/10th the rate specified on the DAQmx Timing function (under Part 2 section). It would be nice if someone can explain the difference.
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7KdSAK&l=de-DE
Thanks.
Deepak
Solved! Go to Solution.
03-27-2019 11:22 AM
Both articles are far more comprehensive than this reply will be. I think the key is to understand that they don't disagree with one another, not *really*, about sample rates, read rates, and # samples to read for a buffered task.
In the first article, the emphasis is that you must *on average* read samples out of the buffer at the same rate that sampling is putting them into the buffer. The overall read rate needs to be the same as the sample rate. And the correct formula to use for read rate is (samples / read) * (reads / sec), not the formula given in the first article.
The second article focuses on the (samples / read) part of that equation. When you set it to 1/10th the DAQmx sample rate, you're essentially asking for 1/10th sec worth of data with every read. As long as the DAQmx Read function is the thing that governs loop timing, you'll find that you have a loop rate that gives you 10 reads/sec. Put together, you'll read 1 sec worth of data per second of sampling, thus preventing buffer overflow.
The following code illustration from the 1st link demonstrates such a loop, though you should be aware that its calculation of 'DAQmx Read Rate' is in units of samples/millisec:
-Kevin P
03-28-2019 05:54 AM
@Kevin_Price
Somehow your explanation cleared my doubt rather than the articles. Since i clearly didn't understand well from the article that the read rate and sample rate should be same *on average*.
Thanks and Best regards,
Deepak