LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Performing two DAQ operations simultaneously, DAQ inside state machines, and using AI DAQ to watch a digital signal...

 

 

    I am looking for the best way to structure a VI that consists of data acquisition inside a state machine.  As the state machine changes states the DAQ reads analog values into separate arrays (inrush, running, and stall currents in two directions).  I am using legacy AI reads because I have not yet updated the program I am working on to use newer functions.

The problem I am running into is that I am using two analog inputs to detect if two switches are closed or not.  A greater than function is used to do this.  The data acquisition is not running until the state machine is acquiring data so that the system does not get bogged down or suffer from a buffer overflow/under-run.  I would like the switches to be monitored constantly. 

I've considered creating a separate while loop for the acquisition that monitors the switches.  My concern here is that acquisition conflicting with the state machine's acquisition.

I've also considered adding an acquisition to the "idle" state of my state machine.  If the switches aren't monitored while the current acquisition is taking place that will be fine but in this case I would have to ignore any buffer under-runs/overflows (they would otherwise occur as the computer performed other tasks) and I might need to stop the acquisition just before starting the current acquisition.

I'd like to eventually use a digital input for this- would this give me more options ?  Ideally I'd like to have two LED controls linked directly to the digital inputs and not have them affect the rest of the program or analog inputs (although they are used when making decisions to change states).

Thanks for any feedback,

David

0 Kudos
Message 1 of 5
(2,759 Views)

It'll be a good idea to monitor the switches as Digital inputs rather than Analog.  Most DAQ boards will only allow 1 hardware-timed AI sampling task at a time and that will need to be dedicated to your current measurements.   I'm pretty sure that the newer DAQmx driver would allow you to have another simultaneous "on-demand" AI task where you poll the switch voltages in software at the same time your hardware is buffering the other hardware-timed samples.  I'm not so sure that the legacy driver would support this.

It's sensible to switch to Digital anyway since you only care about binary On/Off state.  And the legacy driver would surely allow you to poll digital inputs in software while analog samples are being buffered by the hardware.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 5
(2,748 Views)
David,

I agree with Kevin's comments. In addition I would suggest that you consider putting the DAQ in a parallel loop. That could be a simple state machine as well (Initialize, Idle, Acquire, Shutdown). Pass the data via a queue or an functional global VI (See Ben's Nugget on Action Engines). The acquisition loop can then run at a rate which is independent of the main loop. Also look at the Producer/Consumer design patterns which ship with LV. You main state machine can sort the data received from the DAQ loop to the appropriate destination according to the state it is in.

Lynn
0 Kudos
Message 3 of 5
(2,741 Views)
Thanks Kevin. 
 
I'll be switching to digital when time permits.  I've been using a "special state" to poll the DC signals that I'm reading through AI for now, I'll continue to do that until I get switched over.
 
Regards,
 
David.
 
0 Kudos
Message 4 of 5
(2,739 Views)
I'll take a look at the references, thanks Lynn.
 
I do have a producer/consumer architecture above the state machine; if it is set up properly or not I will need to verify! 🙂 In fact, I think you helped me get it set up about a year ago Lynn, that has been a tremendous help.
 
David
 

Message Edited by davey31415 on 05-23-2007 12:04 PM

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