Showing results for 
Search instead for 
Did you mean: 

Using two analog outputs on the 6341 at the same time

Im trying to control two servo motors with the NI USB X 6341 at the same time. One pulse width cable is connected (servo 1) to AO0 and the other (servo 2) is connected to the AO1. Both servos are connected to the same ground and 5V source.

The problem when running the vi is that the motors dont work simultaniously, only one works at the time. When I run the VI only 1 motor works, when I stop it and run it again the other one works. Is there anything wrong with this VI?


0 Kudos
Message 1 of 8

Yes, there is something wrong. You simply cannot have more than one task for an analog output. This has been discussed often and the solution is to have a single task with both channels. You can only use a single task because of the shared clock. This also means you have to have a single rate.

Message 2 of 8

I tried to do it with a single task but the DaqMX Create Channel needs a physical channel input.. So I don't know how to do it with a Task.. Could you help a little?

0 Kudos
Message 3 of 8

You can simply select the Browse option and shift-click or ctrl-click to get multiple channels. To enter manually, the syntax would be Dev1/ai0:1 for consectutive channels or Dev1/ai0,Dev1/ai2 for non-consecutive channels.

0 Kudos
Message 4 of 8

Then how would the VI know which channel to use for which servo? I don't really get how to work with tasks:(

0 Kudos
Message 5 of 8

You should know which analog channel is connected to which servo. Your older code shows that you do so I don't understand the question. The only difference is that you would have an array of waveforms passed to the DAQmx Write. The DAQmx Writes have to be changed to NChannel. The first element in the waveform array is the first channel in the physical channel control, the second element is the second channel, etc.


p.s. Clean up your block diagram. You have hiddent functions and wires going every which direction.

0 Kudos
Message 6 of 8
So ill just have tot delete one of the Create channel lines and connect the remaining one tot the write which has two waveforms connected in an array?
0 Kudos
Message 7 of 8

You would have one DAQmx Create Channel (unless the settings are different), one DAQmx Timing, one DAQmx Write (Analog 1D Wfm NChan Nsamp), one DAQmx start, one DAQmx Clear.

Message 8 of 8