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.
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.
03-22-2017 01:15 PM
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
Solved! Go to Solution.
03-22-2017 01:33 PM - edited 03-22-2017 01:38 PM
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.
03-22-2017 01:39 PM
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
03-22-2017 01:59 PM
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