Write values to digital output lines
Note: You cannot use the legacy interface on 64-bit MATLAB®. See Working with the Session-Based Interface to acquire and generate data on a 64-bit MATLAB.
A digital I/O object.
One or more lines contained by obj.
A decimal value or binary vector.
Create the digital I/O object dio and add four output lines to it.
dio = digitalio('nidaq','Dev1'); lines = addline(dio,0:3,'out');
Write the value 8 as a decimal value and as a binary vector.
putvalue(dio,8) putvalue(dio,[0 0 0 1])
You can specify data as either a decimal value or a binary vector. A binary vector (or binvec) is constructed with the least significant bit (LSB) in the first column and the most significant bit (MSB) in the last column. For example, the decimal number 23 is written as the binary vector [1 1 1 0 1].
If obj contains lines from a port-configurable device, then all lines will be written to even if they are not contained by the device object.
An error will be returned if data is written to an input line.
An error is returned if you attempt to write a negative value.
If a decimal value is written to a digital I/O object and the value is too large to be represented by the hardware, then an error is returned.
Note: Refer to the Hardware Limitations by Vendor section before you access National Instruments® devices with the NI-DAQmx adaptor simultaneously from multiple applications.