From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ time lag

Solved!
Go to solution

Hi, 
I'm running a photosensor which detects drops.  This requires data to be collected with 5ms gaps in collection or better.

I'm using finite sampling on Labview 2009, taking 100 samples at 1kHz in a While loop.  I've tried DAQ assist and DAQmx.  With either, the DAQ loop takes ~125ms to run.  Collecting fewer points still has a roughly 25-30ms lag.  I've confirmed the processing loop is not causing by problem by only running the DAQ loop and I still get the lag.  What is the best way to collect the data to not miss any drops?  My DAQ is an NI USB-6212.

The DAQ loop is on the bottom of Check Valve Prelim Rate Test.

Thanks!

--nate

Download All
0 Kudos
Message 1 of 4
(2,801 Views)
Solution
Accepted by topic author NateLove

You said you are using Finite sampling.  Why aren't using continuous sampling?  Finite sampling means it starts and stops every loop iteration, but the real world is still generating data while the PC has moved onto other tasks that take about 25 msec after it grabbed the last sample.  With continuous sampling, the task is still running and the buffer collecting the next data coming in in series, while the PC moves onto the other tasks.  Next iteration, it grabs the data that has filled the buffer, (and waits if it hasn't all arrived yet) then moves on.  You won't "miss a drop".

 

You should also use queues and a producer and consumer loop to move data between loops.  Using local variables means you could miss data, or read duplicate data since you have a race condition for when data is written to or read from the terminals and local variables.

 

You have some other issues you'll need to fix.  Be sure to use block diagram cleanup to clean up those wires that wander all over the place.  Also, you have a For loop where you flip a 1-D array and repeatedly insert it into the original array.  That doesn't make any sense to me.  It just dramatically enlarges the size of the array repeated data in odd locations.

Message 2 of 4
(2,792 Views)

RavensFan beat me to it.  The solution is to use Continuous Sampling, which lets the hardware acquire data while the CPU is doing other things.

 

And so you have an idea about what he is referring to in the second half of his post: Producer/Consumer


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 4
(2,783 Views)

Thanks.  I'll take a look at the producer/consumer help and work off that.  That looks like it solves the problem I had last time of my buffer overflowing when I tried this under Continuous Sampling.

 

The For loop is to order things more logically for my graphical representation.  But in general, its time for a Spring Cleaning on this guy once I get the DAQ working right.

 

Thanks again!

--nate

0 Kudos
Message 4 of 4
(2,766 Views)