Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run multiple channels simultaneously

I'm working on a system that will output 4 analog voltages, read 4 analog voltages, and output 4 digital signals simultaneously. For whatever reason, my system isn't working at all in terms of signal generation. What am I missing?

 

For reference, I'm using the NI 9221, NI 9263, and NI 9474, respectively.

0 Kudos
Message 1 of 2
(736 Views)

It'll help for you to provide more details about "my system isn't working at all".  Actual code is generally also more helpful than pics, though what you've provided is pretty clear.

 

Things I see:

1. Your calls to DAQmx Timing do not wire the top inputs.  So the default is to configure for Finite Sampling and 1000 samples.  Is that what you want?  Either way, that's what you get.

 

2. Your tasks are not fully synced. You would need to configure them to share timing signals such as a sample clock.  As it is, they're only kinda sorta synced via software calls that are likely to happen at *pretty close* to the same time.

 

3. Because you're in Finite Sampling mode, the special value -1 you wire to DAQmx Read will mean, "wait for all 1000 samples to accumulate, then return them all at once".  However, at 5 Hz, that would take 200 seconds.  Meanwhile, you didn't wire the timeout input which defaults to 10 seconds.  So after 10 seconds the task returns a timeout error and no data, thus ending the loop.

 

My *guess* is that you probably want to be in Continuous Sampling mode.  If so, then the special value -1 at DAQmx Read changes its meaning to, "give me whatever amount of new samples are available right now, no waiting".

    If you leave it that way, the loop will iterate many thousands of times a second, usually returning no data whatsoever b/c you only capture a new sample 5 times a second.   So you should either request a fixed (and small) positive # of  samples each read OR add a wait timer to the loop.  Both methods will yield CPU instead of burning it uselessly.

 

Hardware sync is accomplished by having 1 master task share its sample clock signal with the other 2 tasks AND making sure the master task starts *last*.

 

 

-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 2
(714 Views)