Write output scans to hardware channels
If the DataAcquisition has not been started,
write sends the
data and starts device output generation. As a finite foreground generation, this
blocks MATLAB until completed.
If the DataAcquisition had already been started,
provides the data for the output operation to begin, which then runs in the background
without blocking MATLAB. The
start function arguments determine
if the generation is finite, repeating, or continuous. Continuous output requires
write to provide data for as long as output is needed;
multiple calls to
write might be necessary.
If the supplied data value specifies only a single scan of data for
all output channels, the
write function generates an on-demand output
Create interface and add two output channels.
d = daq("ni"); ch = addoutput(d,"Dev1",0:1,"Voltage");
ch = Index Type Device Channel Measurement Type Range Name _____ ____ ______ _______ _____________________ __________________ __________ 1 "ao" "Dev1" "ao0" "Voltage (SingleEnd)" "-10 to +10 Volts" "Dev1_ao0" 2 "ao" "Dev1" "ao1" "Voltage (SingleEnd)" "-10 to +10 Volts" "Dev1_ao1"
Output 5 volts on both channels.
Start a DataAcquisition interface for background operation, then provide data for device output.
d = daq("ni"); addoutput(d,"Dev1",1,"Voltage"); signalData = sin((1:1000)*2*pi/1000); start(d,"RepeatOutput") % ⋮ write(d,signalData') % Device output now repeated while MATLAB continues. pause(5) stop(d)
scanData— Scan data for device output
Scan data for device output, specified as an M-by-N matrix, where M is the number of
data scans and N is the number of output channels in the DataAcquisition interface. Each
scanData contains the data for one channel. For a single
channel, the data is a column vector.