Documentation Center

  • Trial Software
  • Product Updates

Contents

Acquire Data and Generate Signals Simultaneously

This example shows how to acquire data from an NI 9205 device with ID cDAQ1Mod1 and generate signals using an NI 9263 device with ID cDAQ1Mod2.

You can acquire data and generate signals at the same time, on devices on the same chassis in the session-based interface. When the session contains output channels, duration and number of scans become read-only properties of the session. The number of scans in a session is determined by the amount of data queued, and the duration is determined by .

Step 1. Create an NI session object and add one analog input channel on cDAQ1Mod1 and one analog output channel on cDAQ1Mod2:

s = daq.createSession('ni');
addAnalogInputChannel(s,'cDAQ1Mod1', 'ai0', 'Voltage');
addAnalogOutputChannel(s,'cDAQ1Mod2', 'ao0', 'Voltage')
ans = 

Data acquisition session using National Instruments hardware:
   No data queued.  Will run at 1000 scans/second.
   Number of channels: 2
      index Type  Device   Channel   MeasurementType        Range       Name
      ----- ---- --------- ------- ------------------- ---------------- ----
      1     ai   cDAQ1Mod1 ai0     Voltage (Diff)      -10 to +10 Volts
      2     ao   cDAQ1Mod2 ao0     Voltage (SingleEnd) -10 to +10 Volts

Queue the output data:

queueOutputData (s,linspace(-1, 10, 2500)');

Display the session object to see the change in duration and the number of scans. These values change based on the amount of data queued.

s
s = 

Data acquisition session using National Instruments hardware:
   Will run for 2500 scans (2.5 seconds) at 1000 scans/second.
   All devices synchronized using cDAQ1 CompactDAQ chassis backplane. (Details)
      Number of channels: 2
      index Type  Device   Channel InputType      Range       Name
      ----- ---- --------- ------- --------- ---------------- ----
      1     ai   cDAQ1Mod1 ai0     Diff      -10 to +10 Volts
      2     ao   cDAQ1Mod2 ao0     n/a       -10 to +10 Volts

Acquire the data store it in the variable, acquiredData:

acquiredData = startForeground(s);
plot(acquiredData)
Was this topic helpful?