LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ Assistant inside while loop is SLOW?

Does anyone know how to speed up the DAQ assistant inside a while loop? I'm getting a latency bottleneck - the fastest the loop updates is every 2 seconds.

 

This issue can been causing me difficulty for some months. Right now the fastest loop counter update I can get is 1-2 seconds. I've experimented with converting the DAQ assistant to a task, but that doesn't seem to work.

 

Any insight from the LabVIEW community on this? Huge thanks in advance.

0 Kudos
Message 1 of 7
(5,630 Views)

Your DAQ Assistant is going to be limited by its acquisition settings. What's your Number of Samples set to? What's your timeout? Your loop won't finish its iteration until the DAQ Assistant finishes acquiring...

 

LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. Here's a simple resource to become more familiar with how it works. The Highlight Execution feature is a great way to watch how your application utilizes dataflow.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 7
(5,623 Views)

Thanks for the reply - great point. We seem to have set the samples to 256 at 100Hz. Is there an ideal sample rate? We're wanting to get as close to "real-time" data as possible.

 

I'd read about creating the DAQ Assistant outside the while loop, but when we do that of course the data doesn't update inside the loop

0 Kudos
Message 3 of 7
(5,610 Views)
You don't understand the basic arithmetic. The time it takes to update is samples/rate so 256 samples/100 samples/sec is 2.56 seconds. It becomes obvious that if you e want the display to update every second, you request 100 samples. To update every .5 seconds, request 50 samples.
0 Kudos
Message 4 of 7
(5,599 Views)

An update:

 

If I change the DAQ sampling to this, I get essentially real-time data with the loop executing quickly

Samples to read: 2

Rate: 100 Hz

 

 

However, the performance drops if I have multiple DAQ Assistants within the same loop (we have 4 cards, and 4 DAQ assistants). I can't seem to get faster 0.5 seconds per loop

0 Kudos
Message 5 of 7
(5,596 Views)

Read this excellent NI White Paper and stop using the DAQ Assistant.  You will also have a much easier time (and need far fewer DAQmx functions) if you create your Task first, either in MAX or inside a LabVIEW Project (you should always develop "serious" LabVIEW code in the context of a LabVIEW Project -- start with "Create Project" on the "Getting Started With LabVIEW" splash screen).

 

Once you have your task created in, say, the Project, you can generate a data acquisition loop that will run as fast as the hardware will allow by wiring up 3 DAQmx functions -- Start Acquisition (where you wire a Task constant to the upper left port, click the drop-down arrow, and choose the Task that you defined inside your Project, or inside MAX), a DAQmx Read (inside a While loop), and a DAQmx Stop Acquisition when the loop exits.  Note that all the "messy details", such as the name of the DAQ device, the name and numbers of the channels, the properties (Max, Min, etc.) of each channel, Sampling Clock source, sampling rate, sampling mode, etc. can all be pre-defined by the Task.  

 

Bob Schor

0 Kudos
Message 6 of 7
(5,588 Views)

Thanks Bob - I will study the whitepaper guide.

 

Have a great weekend!

0 Kudos
Message 7 of 7
(5,563 Views)