Loop Slows Down While Acquiring and Logging Data to a File

Updated Apr 27, 2018

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I am acquiring data from my DAQ device. After the acquisition I need to analyze the data and save it to a file. However, the analysis and logging is slowing down the iteration of my loop. How can I speed up my loop so that I get the data at the right speed?

Solution

The best practice when you need to process and log data, but don't want to slow down your data acquisition, is to use a Multiple Loop Design Pattern. We can divide our task into two loops, an Acquisition (Producer) Loop and an Analyze/Result (Consumer) Loop, and send data between them using FIFO Queues. 

Since the data acquisition is in its own loop, it can run faster than the loop that is analyzing and logging data. This ensures us that we receive data with desired frequency and have all the data analyzed and presented using slower Consumer Loop. An example of such an application is shown on the screenshot below. This screenshot is from the attached :
In this example code, the lower consumer loop receives the data from the queue and displays it on a waveform chart. You would place any slower data processing and logging code in the consumer loop.

Additional Information

Get Queue Status.vi in the example VI ensures that the consumer loop dequeues and processes all data that was inserted in the queue before the application stops.

For more information on using this type of design pattern, refer to Application Design Patterns: Producer/Consumer.

WAS THIS ARTICLE HELPFUL?

Not Helpful