11-27-2015 02:02 PM
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.
11-27-2015 02:07 PM
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> ---'
11-27-2015 02:33 PM
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
11-27-2015 02:46 PM
11-27-2015 02:48 PM
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
11-27-2015 02:50 PM
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
11-27-2015 04:33 PM
Thanks Bob - I will study the whitepaper guide.
Have a great weekend!