LabVIEW Program with DAQmx Delayed by Multiple Read Cycles

Updated Feb 8, 2018

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I have a program that reads in analog data and processes it. It reads in X samples at X Hz in the main loop, and I have a Wait(ms) VI keeping the loop time at 1s.

When I run the program it starts out working fine. Then, after a bit, the output starts to become more and more delayed. How do I fix this?

Solution

If the loop naturally runs faster than 1 second, you can fix this in two ways:
Remove the Wait(ms) VI.
Set the DAQmx Read VI to read the entire buffer rather than exactly 1000 samples. (Note, this is the default behavior if you leave the "number of samples per channel" input disconnected.)

If the loop does not naturally run faster than 1 second, you will still want to implement one of the fixes above. However, you will also need to offload the processing. The Producer/Consumer design pattern is a common way to accomplish this.
 

Additional Information

The delay you are seeing likely comes from a conflict between hardware and software timing. If you have your DAQmx task set up to read in continuous samples, and you set your DAQmx Read VI to read exactly 1000 samples this can cause a backlog if you have a software delay of 1 second or more. This is because software timing can be inconsistent, and the loop time could be slightly longer than expected.

WAS THIS ARTICLE HELPFUL?

Not Helpful