Generate Signals Using Multiple Channels

This example shows how to generate data from multiple channels and multiple devices. The example generates data using channels from an NI 9263 voltage device with ID cDAQ1Mod2 and an NI 9265 current device with ID cDAQ1Mod8.

Create an NI session object and add two analog output 'Voltage' channels to cDAQ1Mod2:

s = daq.createSession('ni');
addAnalogOutputChannel(s,'cDAQ1Mod2', 2:3, 'Voltage');

Step 2. Add one output 'Current' channel on cDAQ1Mod8:

addAnalogOutputChannel(s,'cDAQ1Mod8', 'ao2', 'Current')
ans = 

Data acquisition session using National Instruments hardware:
   No data queued.  Will run at 1000 scans/second.
   All devices synchronized using cDAQ1 CompactDAQ chassis backplane. (Details)
      Number of channels: 3
      index Type  Device   Channel MeasurementType Range            Name
      ----- ---- --------- ------- --------------- ---------------- ----
      1     ao   cDAQ1Mod2 ao2     Voltage (Diff)  -10 to +10 Volts
      2     ao   cDAQ1Mod2 ao3     Voltage (Diff)  -10 to +10 Volts
      3     ao   cDAQ1Mod8 ao2     Current         0 to +0.020 A    

Specify the channel ID on NI devices using a terminal name, like ao1, or a numeric equivalent like 1.

Create one set of data to output for each added channel:

outputData(:,1) = linspace(-1,1,1000);
outputData(:,2) = linspace(-2,2,1000)';
outputData(:,3) = linspace(0,0.02,1000)';

Queue the output data:


Step 5. Generate the data:


Related Topics