Digital Data (Integer Format)

NI-DAQmx Key Concepts

Digital Data (Integer Format)

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:

unusedunusedport1port0

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/line00
port0/line10
port0/line21
port0/line30
port0/line41
port0/line51
port0/line60
port0/line71
port1/line01
port1/line11
port1/line21
port1/line30
port1/line41
port1/line50
port1/line60
port1/line71

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

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 1 1 0 1 1 0 1 0 0

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/line01
port0/line31

yield the following 8-bit representation:

0 0 0 0 1 0 0 1

with an integer value of 9.