Read values from digital input and output lines
out = getvalue(obj)
out = getvalue(obj,Line(index))
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 binary vector.
Create the digital I/O object dio and add eight input lines to it.
dio = digitalio('nidaq','Dev1'); lines = addline(dio,0:7,'in');
To return the current values from all lines contained by dio as a binvec value:
out = getvalue(dio);
By default, out is returned as a binary vector (binvec). A binvec value 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 binvec value [1 1 1 0 1].
You can convert a binvec value to a decimal value with the binvec2dec function.
If obj contains lines from a port-configurable device, the data acquisition engine will automatically read from all the lines even if they are not contained by the device object.
When obj contains lines configured for output, getvalue returns the most recently output value set by putvalue. If you have not called putvalue since you created the digitalio object, then getvalue returns a 0. getvalue cannot ascertain the current output value on the hardware.
Note: Refer to the Hardware Limitations by Vendor section before you access National Instruments® devices with the NI-DAQmx adaptor simultaneously from multiple applications.