Documentation Center

  • Trial Software
  • Product Updates

putvalue

Write values to digital output lines

Syntax

putvalue(obj,data)
putvalue(obj.Line(index),data)

    Note:   You cannot use the legacy interface on 64–bit MATLAB®. See Session-Based Interface to acquire and generate data.

Arguments

obj

A digital I/O object.

obj.Line(index)

One or more lines contained by obj.

data

A decimal value or binary vector.

Description

putvalue(obj,data) writes data to the hardware lines contained by the digital I/O object obj.

putvalue(obj.Line(index),data) writes data to the hardware lines specified by obj.Line(index).

Examples

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])

More About

expand all

Tips

More About Writing Values to Lines

  • 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.

Was this topic helpful?