Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

fastest method for USB DAQ

What is the fastest method to retrieve the current value of a digital and/or counter input from a USB-6212 card using the NIDAQmx C libraries?  Basically, I have a program that runs on a 5 ms timer and on each pass through the loop I would like to read the latest values of the digital and counter inputs (i.e. the value within the last 5 ms, though I don't actually need to it read the value on command right then and there).  However, when I do this using the functions like DAQmxReadCounterU32(..) they seem to take a 1-2 milliseconds for the function to return, which doesn't leave much time for the rest of my program.
 
Is the best alternative to set up the sample timing for both digital and counters to run at say 1000 Hz then every 5 ms read whatever data is available and simply use the last value?  I've been able to do this by configuring the timing on both of the counters to trigger off of an analog input, but I haven't been able to figure out how to configure timing for the rest of the digital inputs.
 
Thanks,
AJ
 
0 Kudos
Message 1 of 2
(2,771 Views)
Hello AJ,
 
The 1 to 2 millisecond delay you're seeing is expected behavior on a computer that is running a non-deterministic operating system (such as Windows).  When you call an instance of DAQmxRead LabVIEW tells the operating system to go pull the value from memory into the LabVIEW memory space--this takes a few milliseconds and the exact time is dependent on how busy the operating system is at the time.  The usual way to deal with this issue is to use buffered data acquisition and take data points at regular intervals using hardware timing.  Then even though the data retrieval is still uncertain your measurements are still taken at a known interval.
 
There are a number of ANSI C example programs for buffered counter measurements that you can look at.  If you're not sure where the example programs are installed you can check this KnowlegeBase article:  NI-DAQmx, NI-VISA, and NI-488.2 Visual C++ Example Locations
 
Here's the full path for one of the examples on my machine.  (Note:  the path on your machine may vary based on operating system and driver versions)
C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Measure Digital Frequency\Dig Freq-Buff-Cont-Large Range 2 Ctr
 
I hope this helps get you started.
 
Have a great day!


Message Edited by Brooks_C on 04-02-2008 10:34 AM
Brooks
0 Kudos
Message 2 of 2
(2,746 Views)