Table Of Contents

Digital Data (Integer Format)

Last Modified: September 15, 2017

You typically use an integer format to read or write entire ports. In integer format, each digital channel you read or write must fit into one integer. For example, if the largest channel in a task consists of one 8-line port, you can use the 8-bit, 16-bit, or 32-bit format. If you have more than one 8-line port or a port with more than eight lines in any channel within a task, you must use the 32-bit format.

Each byte in the integer maps to a port in the channel, in the order in which you added the ports to the channel. The least significant byte maps to the first port added to the channel, with all unused bytes zeroed out. Therefore, if a channel contains two 8-line ports, port0 and port1, and you added port0 to the channel before port1, the channel uses a 32-bit representation:

unused unused port1 port0

Within a particular byte, each bit in the integer maps to a line in the corresponding port. NI-DAQmx orders the bits by line number, with the least significant bit mapping to the lowest line number. Therefore, with these values assigned to the lines in the channel, you might get the following:

port0/line0 0
port0/line1 0
port0/line2 1
port0/line3 0
port0/line4 1
port0/line5 1
port0/line6 0
port0/line7 1
port1/line0 1
port1/line1 1
port1/line2 1
port1/line3 0
port1/line4 1
port1/line5 0
port1/line6 0
port1/line7 1

The 32-bit binary representation of the channel is the following:

with an integer value of 38836.

If you specify only certain lines in a port to read or write, the full length of the integer is still used, but all unused bits are zeroed out. Therefore, the following lines and values:

port0/line0 1
port0/line3 1

yield the following 8-bit representation:

with an integer value of 9.


Recently Viewed Topics