Data Acquisition Toolbox | ![]() ![]() |
Reading Digital Values
You can read values from one or more lines with the getvalue
function. getvalue
requires the DIO object as an input argument. You can optionally specify an output argument, which represents the returned values as a binary vector. Binary vectors are described in Writing Digital Values.
For example, suppose you create the digital I/O object dio
and add eight input lines to it from port 0.
To read the current value of all the lines contained by dio
:
To read the current values of the first five lines contained by dio
:
You can convert a binvec to a decimal value with the binvec2dec
function. For example, to convert the binary vector lineval
to a decimal value:
Rules for Reading Digital Values
Reading values from digital I/O lines follows these rules:
1
by default.
getvalue
always returns a binary vector (binvec). To convert the binvec to a decimal value, use the binvec2dec
function.
![]() | Writing and Reading Digital I/O Line Values | Example: Writing and Reading Digital Values | ![]() |