5.1 - General Protocol [UE9 Datasheet] | LabJack

# 5.1 - General Protocol [UE9 Datasheet]

Following is a description of the general UE9 low-level communication protocol. There are two types of commands:

Normal: 1 command word plus 0-7 data words.
Extended: 3 command words plus 0-125 data words.

Normal commands have a smaller packet size and can be faster in some situations. Extended commands provide more commands, better error detection, and a larger maximum data payload.

Table 5.1-1. Normal command format

 Byte 0 Checksum8: Includes bytes 1-15 1 Command Byte: DCCCCWWW Bit 7: Destination Bit: 0 = Local, 1 = Remote. Bits 6-3: Normal command number (0-14). Bits 2-0: Number of data words. 2-15 Data words.

Table 5.1-2. Extended command format:

 Byte 0 Checksum8: Includes bytes 1-5 1 Command Byte: D1111WWW Bit 7: Destination Bit: 0 = Local, 1 = Remote. Bits 6-3: 1111 specifies that this is an extended command Bits 2-0: Used with some commands. 2 Number of data words. 3 Extended command number. 4 Checksum16 (LSB) 5 Checksum16 (MSB) 6-255 Data words.

Checksum calculations:

All checksums are a “1’s complement checksum”. Both the 8-bit and 16-bit checksum are unsigned. Sum all applicable bytes in an accumulator, 1 at a time. Each time another byte is added, check for overflow (carry bit), and if true add one to the accumulator.

In a high-level language, do the following for the 8-bit normal command checksum:

1. Get the subarray consisting of bytes 1 and up.
2. Convert bytes to U16 and sum into a U16 accumulator.
3. Divide by 28 and sum the quotient and remainder.
4. Divide by 28 and sum the quotient and remainder.

In a high-level language, do the following for an extended command 16-bit checksum:

1. Get the subarray consisting of bytes 6 and up.
2. Convert bytes to U16 and sum into a U16 accumulator (can’t overflow).

Then do the following for the 8-bit extended checksum:

1. Get the subarray consisting of bytes 1 through 5.
2. Convert bytes to U16 and sum into a U16 accumulator.
3. Divide by 28 and sum the quotient and remainder.
4. Divide by 28 and sum the quotient and remainder.

Destination bit:

This bit specifies whether the command is destined for the local or remote target. Generally, local means the packet should be handled by the Comm processor, while remote means the Comm processor should pass the packet on.

Multi-byte parameters:

In the following function definitions there are various multi-byte parameters. The least significant byte of the parameter will always be found at the lowest byte number. For instance, bytes 10 through 13 of CommConfig are the IP address which is 4 bytes long. Byte 10 is the least significant byte (LSB), and byte 13 is the most significant byte (MSB).

Some functions have mask parameters. The WriteMask found in some functions specifies which parameters are to be written. In the following documentation, parameters affected by the WriteMask have a [#] next to their name which specifies which bit in the WriteMask goes with which parameter. If a bit is 1, that parameter will be updated with the new passed value. If a bit is 0, the parameter is not changed and only a read is performed.

The AINMask found in some functions specifies which analog inputs are acquired. This is a 16-bit parameter where each bit corresponds to AIN0-AIN15. If a bit is 1, that channel will be acquired.

The digital I/O masks, such as FIOMask, specify that the passed value for direction and state are updated if a bit 1. If a bit of the mask is 0 only a read is performed on that bit of I/O.

Resolution:

All analog input functions have a Resolution parameter. This allows you to choose between speed or resolution. See Sections 3.1 and 3.2 for timing information.

SettlingTime:

Some analog input functions have a SettlingTime parameter. This parameter adds extra settling time before each sample of about SettlingTime * 5 microseconds.

Binary Encoded Parameters:

Many parameters in the following functions use specific bits within a single integer parameter to write/read specific information. In particular, most digital I/O parameters contain the information for each bit of I/O in one integer, where each bit of I/O corresponds to the same bit in the parameter (e.g. the direction of FIO0 is set in bit 0 of parameter FIODir). For instance, in the function ControlConfig, the parameter FIODir is a single byte (8 bits) that writes/reads the direction of each of the 8 FIO lines:

• if FIODir is 0, all FIO lines are input,
• if FIODir is 1 (20), FIO0 is output, FIO1-FIO7 are input,
• if FIODir is 5 (20 + 22), FIO0 and FIO2 are output, all other FIO lines are input,
• if FIODir is 255 (20 + … + 27), FIO0-FIO7 are output.