This error is caused by a PC buffer overflow. The PC buffer is the buffer that exists on a computer between the DAQ hardware and LabVIEW's application memory. It is written to continuously by hardware, but is only periodically read from by LabVIEW. This can often lead to a mismatch in read rates. Typically, data is overwritten in the DAQmx PC Buffer because either the read rate is slower than the sample rate, or the DAQmx PC Buffer is too small to hold the data required by the NI-DAQmx task.
Case 1: Read Rate Is Slower Than Sample Rate
This error is often the result of the read rate for the continuously sampled DAQmx application being slower than the sample rate of the DAQmx task, causing samples to build up in the DAQmx PC Buffer until an overwrite error occurs. The sample rate is the rate specified via the DAQmx Timing VI property below:
When troubleshooting this error, the first step should be to ensure that the read rate and the sample rate for your application are the same.
Since the read rate for your application depends on both the number of samples you are requesting per DAQmx Read, as well as the number of times that the DAQmx Read function is called in a second, you can adjust the read rate by explicitly controlling the number of samples required by the DAQmx Read, or by explicitly controlling the number of times that the while loop containing your DAQmx Read executes in a second using timing nodes, such as Wait (ms):
DAQmx Read will automatically wait until the requested number of samples are available, so it is usually only necessary to control one of these factors in a particular application.
If the while loop is performing more slowly than expected, you may need to implement a Producer/Consumer architecture
to move other processes, such as logging, post-processing, analysis, and user interface functionality outside of the acquisition loop.
If increasing the while loop performance is not an option, you may need to lower the sample rate for your application instead.Note:
Do not use Highlight Execution with code that contains a DAQmx Read, since it will slow down the execution and cause a buffer overflow.
Case 2: PC Buffer Is Too Small to Hold Task Data
Another reason for this error is that the DAQmx PC Buffer is too small to hold the amount of data required by the DAQmx task, causing an overwrite in the DAQmx PC Buffer before data has been acquired at all.
Occasionally, this error can be resolved by simply increasing the size of the host side data buffer manually
. However, if the error is occurring because data is not being readout of the DAQmx buffer fast enough (Case 1 above), increasing the buffer size will only delay the occurrence of the error, and will not eliminate it completely.
Case 3: Reading two tasks running at different rates, using one acquisition loop
This error can occur if two tasks sharing an acquisition loop have different sample rates. The reason that this error presents itself is that the DAQmx read is a blocking call. One DAQmx read will take longer to read the same number of samples, while that longer read is occurring the other task's buffer is filling up.
- Make sure each DAQmx Read in the loop has the same read rate. For example, one task reads 3000 Samples / 3000 Samples/s = 1s, and the second task in the loop reads 100 Samples / 100Samples/s = 1s. Each DAQmx Read will take 1s, so the buffer won't fill up every iteration.
Remember always to read back the Sample Rate of each task by using a DAQmx Timing
property node >> SampClk.Rate.
This is important to confirm that the Actual Sample
rate used by the card is exactly what the user specified. Otherwise, there could be an overflow error because there will be some samples that are not being read and will be accumulated in the buffer. For example, this is common with M Series cards if you chose a sample rate that they can't achieve exactly, like 30000 S/s, the card will run at 30030.03 S/s. This means that if you read 30000 Samples in the DAQmx Read function in the acquisition loop, there will be 30.03 samples being accumulated in the buffer every iteration.
DSA modules can coerce to specific sample rates