12-20-2011 02:32 PM
I'm trying to acquire an analog voltage using a PCI 6133 board using LabVIEW and NI-DAQmx. I have a bunch of low frequency (~ 30 Hz) signals that are fed into the board.
When the user presses a button on the front panel, I wish to acquire the most recent sample. Otherwise, I just want to acquire samples every 2 seconds. My acquisition loop needs to be as resource friendly as possible since we have multiple loops doing other acquisitions running simultaneously in different VIs on the same computer.
If I try using a "conventional" sample clock, DAQmx seems to buffer all unread samples. Instead, I want to read only the most current sample, one sample at a time. What's the best way of doing this?
Thanks.
Regards
Akarsh
12-21-2011 12:19 PM
Are you using the DAQmx VIs?
I have built sample code that seems to do what you want. Just pick your channel under Channel Parameters.
Basically, I have created an event structure in a loop. The event structure has two events. One event is "Acquire New Sample: Mouse Up," which fires when the mouse is let go on the acquire button. In this event, you simply have a DAQmx VI that acquires one sample and outputs it to the Data indicator.
The other event is the Timeout Event. If nothing happens in two seconds (since the last sample was acquired, either by button or automatically), then a sample is automatically taken.
I'm not sure whether this will be compatible with your other VIs, or if you need that 2 seconds to be dead precise, but if you don't, this can work well.