LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop or Timed Loop to read USB-6009 at 100ms intervals??

Hi,
 
I have a USB 6009 aquiring data at 100ms intervals. How do I set up a timed loop that will assure me of aquiring every data point? This system needs to run unattended for 787 hours. I have set my timed loop at 98ms to insure that the USB module cannot get ahead of the timed loop. Sometimes the timed loop seems to try to read the USB module when there is no data available and it come up with bad data. If I set my timed loop at 100ms, the USB module is gathering data slightly faster than the timed loop and eventually the buffer overflows. How can I perfectly synchronize the timed loop with the USB module?
 
Should I be using a While loop instead? How can I get the while loop to read when the data is available?
 
I am running LV8.0 on an XP-SP2 system. I have stripped out as many services as possible so the only ap running is my vi. The OS is running as bare bones as I can make it.
 
Thanks,
Chris
0 Kudos
Message 1 of 5
(2,736 Views)

Hello Chris.

Do you know that one millisecond in LabVIEW is about 1.000686 ms in real world? Look e.g. at
How do I avoid starving the interrupt which keeps OS time? - LabVIEW - NI Discussion Forums

I hope this helps, Guenter

0 Kudos
Message 2 of 5
(2,726 Views)
Okaaayyy,,,,
 
Is there a way to poll the USB-6009 since it is running on a hardware 100ms timing and read it only when data is available? That way there would never be either an under run or over run of data.
 
Chris
 
0 Kudos
Message 3 of 5
(2,718 Views)
Hello cdreike,

If you set up your DAQmx Task for hardware timed acquisition using the DAQmx Timing VI, your USB-6009 will use an onboard clock to acquire samples at the rate you specify.  If you place a DAQmx Read VI within a regular while loop (not a timed loop), your program will wait at the DAQmx Read VI until the number of samples you've specified to read have been acquired from the device.  Therefore, if you set your USB-6009 to acquire data at 10Hz (1 Sample every 100ms = 10 S/s), and set the DAQmx Read VI to read a single sample, your while loop will wait at the DAQmx Read function until a data point has arrived, and your while loop will ultimately execute at 10Hz.  This works as long as you are running at rates slow enough so that your computer can handle transferring data into LabVIEW one sample at a time, and you have nothing else in your while loop that is preventing the DAQmx Read VI from executing fast enough.  You'll get overflow or overwrite errors if either of these things happen.  Take a look at the Cont Acq&Graph Voltage-IntClk.vi example program found in the NI Example Finder in LabVIEW (Help > Find Examples).  This example shows a hardware timed continuous buffered acquisition using the DAQmx Read VI in a while loop.  If you set the number of samples to read of the DAQmx Read VI to 1, the while loop will execute at the rate samples are acquired.

Here's a screenshot of a block diagram showing a continuous hardware timed single point acquisition.



I hope this helps,
Travis G.
Applications Engineering
National Instruments
www.ni.com/support

Message Edited by Travis G. on 05-24-2006 05:11 PM

0 Kudos
Message 4 of 5
(2,698 Views)

Travis G.,

Thank you very much for the concise answer to my problem!!!

Chris

0 Kudos
Message 5 of 5
(2,692 Views)