SEI Absolute Encoder Communications Protocol

SEI Absolute Encoder Communications Protocol Data Sheet

Each encoder on the bus is assigned a unique address between 0 and E. The host computer is the master of the bus, while the encoders are slaves. Encoders cannot initiate communication, rather the host sends commands and the encoders respond. The first byte of a command always includes the address of the encoder to be selected. Address F is used to communicate to all devices on the bus at once. An encoder responds by activating the busy line if a valid command is received with the correct address. If the address is incorrect or the command is invalid (including framing errors), the encoder ignores the command. If the address is F, all encoders activate the busy line until the command is processed by everyone (wired-OR). If an encoder has the busy line active while processing a command, other encoders ignore all data.

In the case of a single-byte command, the host only sends one byte which contains the address and the command. The selected encoder activates the busy line, sends the response, and then releases the busy line. In the case of a multiple-byte command, the host first sends a byte which contains the address and an indication that a multiple-byte command is in process. The selected encoder activates the busy line to acknowledge the selection. The host sends the rest of the command and the busy line remains active until the particular command in completed. In the simplest single encoder configuration, if factory default modes don't need to be changed, only single-byte commands are needed. Large numbers are transmitted with the most significant byte first (Motorola big-endian convention).


Single Byte User Commands:

Request Command:

7 6 5 4 3 2 1 0
cmd3 cmd2 cmd1 cmd0 addr3 addr2 addr1 addr0

Addr3-0:
Address of encoder to be selected (0 to E). Address F selects any and all encoders on the bus. If there is only one encoder on the bus, address F can be used for all operations. If there are multiple encoders on the bus, address F is only useful for a few commands.

cmd3-cmd0 request type
0000 (reserved for control codes)
0001 position
0010 position + 1 byte status
0011 position + 2 bytes time + status
0100 strobe
0101 sleep
0110 wakeup
0111 reserved
1000 reserved
1001 reserved
1010 reserved
1011 reserved
1100 reserved
1101 reserved
1110 reserved
1111 (multiple byte command)

Position:
The encoder sends its current position. The format is either 1 or 2 bytes in single-turn mode, 4 bytes in multi-turn mode, most significant byte first, (see "Change Mode Command" for details).

Time:
The encoder sends the 2 byte value of its free running counter at the time of the position reading - most significant byte first. The counter increments at 1.843MHz 1% (1 count per 0.54 usec).

Strobe:
stb = 1, the encoder operates in strobe mode: it waits for a strobe request before reading the position; this mode is used to synchronize multiple encoders. After entering this mode, wait at least 2 msec before sending the first strobe command.
stb = 0, the encoder operates in asynchronous mode: it reads the position within 4 milliseconds (8 milliseconds for A2I) and sends the most current position when requested. The data can be from 0 to 4 milliseconds old (8 milliseconds for the A2I).

Sleep:
The encoder goes to sleep (without responding) after the command is executed, and the current consumption drops below 0.6 mA. If there are multiple encoders on the bus, use address F to put them all asleep at once. Any activity on the data bus wakes up all encoders (use wakeup command).

Wakeup:
This command wakes up all encoders on the bus, but the encoders do not respond. Wait at least 5 msec after this command to send the next command.

Status:
The encoder sends 1 byte status as follows:

7 6 5 4 3 2 1 0
err3 err2 err1 err0 sum3 sum2 sum1 sum0

err3-err0 meaning Corresponding
SEI Error Code
0000 no error n/A
0001 not enough light 28101
0010 too much light 28102
0011 misalignment or dust 28103
0100 misalignment or dust 28104
0101 misalignment or dust 28105
0110 hardware problem 28106
0111 fast mode error (V1.X) 28107
1000 multiturn pos. not initialized 28108

Sum3-0
Exclusive OR of all 4-bit nibbles of the request byte received and data bytes returned by the encoder, excluding the status byte. This is a good check of data integrity, especially in the case of a bus with multiple encoders.

Note: In multi-turn mode, the error 1000 is sent until a "set origin" or a "set position" command is received. This allows the host to know a reset or power loss has occurred and the multi-turn position is no longer valid.


Multiple Byte Commands:

All multiple byte commands start with the request byte F0+addr; after receiving this byte, the addressed encoder will acknowledge by activating the busy line. After the acknowledgment, the encoder is ready to receive the rest of the command. Some commands may require the use of address F to select all encoders on the bus (like check serial number, baud rate change, etc...). When addressing multiple encoders, after the first busy received, wait 5 msec to send the rest of the command, to make sure they are all ready. When the command is successfully completed, the encoder sends a checksum byte, and then releases the busy line. If the command is invalid or failed, the encoder releases the busy line without sending a checksum. The checksum byte is the exclusive OR of the request byte, command bytes, and bytes returned by the encoder.

Set Origin Command:
2 bytes: request byte, 01
Returns checksum if command is successful.
Sets the absolute 0 at the current position.
In single-turn mode, the new origin is stored in EEPROM, therefore, it will be effective after resets and power downs until a "Set Origin" or a "Set Absolute Position" command is received.
In multi-turn mode, the 32 bit counter is reset, but not stored in EEPROM. This is effective until a reset occurs or a "Set Origin" or a "Set Absolute Position" command is received.

Set Absolute Position Command:
Single-turn: 4 bytes: request byte, 02, pos MS byte, pos LS byte.
Multi-turn: 6 bytes: request byte, 02, 4 bytes pos (MS to LS).
Returns checksum if command is successful.
Sets the given absolute position (at the current resolution) at the current position.
In single-turn mode, the new origin is stored in EEPROM, therefore it will be effective after resets and power downs, until a "Set Origin" or a "Set Absolute Position" command is received.
In multi-turn mode, the 32 bit counter is set, but not stored in EEPROM. This is effective until a reset occurs or a "Set Origin" or a "Set Absolute Position" command is received.

Read Serial Number:
2 bytes: request byte, 03
Returns 5 bytes: 4 bytes serial number and checksum if command is successful.

Check Serial Number:
10 bytes: request byte, 04, 4 bytes serial number, 4 bytes mask.
Returns nothing.
The encoder does a logical AND of its serial number with the mask supplied; the result is compared to the serial number supplied. If they match, the busy line is held active until another byte is received. Otherwise the busy line is released. This command is used to determine if an encoder with a particular serial number is present on the bus.

Fail Serial Number:
10 bytes: request byte, 05, 4 bytes serial number, 4 bytes mask.
Returns nothing.
The encoder does a logical AND of its serial number with the mask supplied; the result is compared to the serial number supplied. If they dont match, the busy line is held active until another byte is received. If they match the busy line is released. This is useful to determine if an encoder, whose serial number is known, is the only one on the bus.

Get Address:
6 bytes: request byte, 06, 4 bytes serial number.
Returns 2 bytes: 1 byte address and checksum if command is successful, only if serial number matches.
The encoder compares its serial number with the one supplied; if they match, it returns its address (0 to E). Otherwise, it returns nothing.

Assign Address:
7 bytes: request byte, 07, 4 bytes serial number, 1 byte address.
Returns checksum if command is successful.
The encoder compares its serial number with the one supplied; if they match, it assigns itself the address supplied (must be between 0 and E). The new address is stored in EEPROM, therefore, it will be effective after resets and power downs.

Read Factory Info:
2 bytes: request byte, 08
Returns 15 bytes: 2 bytes model number, 2 bytes version, 2 bytes configuration, 4 bytes serial number, month, day, 2 bytes year and checksum if command is successful.

Read Resolution Command:
2 bytes: request byte, 09
Returns 3 bytes: resolution MS byte, resolution LS byte and checksum if command is successful.
A zero value means 16 bit resolution.

Change Resolution Command:
4 bytes: request byte, 0A, resolution MS byte, resolution LS byte.
Returns checksum if command is successful.
The resolution can be any number between 0 and FFFF, 0 is for full 16 bit position. However, the accuracy is only guaranteed to 12 bits. The new resolution is stored in EEPROM, therefore, it will be effective after resets and power downs.

Read Mode Command:
2 bytes: request byte, 0B
Returns 2 bytes: mode and checksum if command is successful.

Change Mode Command (temporary):
3 bytes: request byte, 0C, mode.
Returns checksum if command is successful.
The mode is changed temporarily and will be effective until the encoder is reset, power down, or another mode change command is received. It is not stored in the EEPROM. Mode byte as follows:

7 6 5 4 3 2 1 0
0 /256 0 incr size multi stb rev

Reverse:
rev = 1, the position increases counter clockwise.
rev = 0, the position increases clockwise.

Strobe:
stb = 1, the encoder operates in strobe mode: it waits for a strobe request before reading the position; this mode is used to synchronize multiple encoders. After entering this mode, wait at least 2 mSec before sending the first strobe command.
stb = 0, the encoder operates in asynchronous mode: it reads the position within 2 mSec and sends the most current position when requested. The data can be from 0 to 2 mSec old.

Multi:
multi = 1, multi-turn mode: a 32 bit counter keeps track of the position (it increases or decreases over multiple turns, i.e. 3 1/2 turns at a resolution of 100 would be 350). This counter is cleared at reset.
multi = 0, single-turn mode: position is between zero and the max resolution, according to the shaft angle.
Note: in older versions (V1.X), this bit indicated a fast mode (3msec update rate) with a 9 bit accuracy.
Also, any other command besides position inquires can corrupt the multi-turn position.

Size:
only effective in single-turn mode:
size = 1: the encoder always sends the position in 2 bytes, even if the resolution is 256 decimal or less.
size = 0: the position is sent as 1 byte if the resolution is up to 256 decimal, or as 2 bytes if above 256 decimal.
In multi-turn mode, the position is always 4 bytes and this bit is ignored.

Incr:
only effective in multi-turn mode:
incr = 1: the encoder sends the position change since the last request, as a 32 bit signed number.
incr = 0: the encoder sends the position as a 32 bit signed number.

/256:
only available for analog version
only effective in multi-turn mode:
/256 = 1: the encoder position is divided by 256.
/256 = 0: the encoder position is normal.

Change Power Up Mode Command:
3 bytes: request byte, 0D, mode.
Returns checksum if command is successful.
Same as "Change Mode Command" described above, except the mode is stored in EEPROM, therefore it will be effective after resets and power downs.

Reset Command:
2 bytes: request byte, 0E
Returns checksum if command is successful.
After releasing the busy line the encoder does a software reset (the baud rate returns to 9600 after the checksum byte is sent). The encoder requires 35msec after reset to be ready to receive new commands. The other ways to reset are: turning the power off, or sending a break condition (dataL low, dataH high) for at least 1 second. Note that the reset threshold of the power input is between 4.5 and 5.5 volts. The EEPROM parameters are not affected, but any temporary mode changes or baud rate change are lost.


User Diagnostic Commands:

Loopback Mode:
2 bytes: request byte, 10
Returns no checksum.
After receiving this command the encoder returns every byte it receives. This is useful to test the SEI bus. The busy line remains active during this test. The test is aborted if a delay of 350msec or more occurs. (rev 1.01 firmware was 35msec). The host must release the data lines after each byte sent, to allow the encoder to respond. The AD2 adapter does this automatically.

Off line Command:
2 bytes: request byte, 11
Returns checksum if command is successful.
After releasing the busy line the encoder does not respond to any command. To place it back on line it must receive a break condition (dataL low, dataH high) for at least 1 second or power down and up again. We do not recommend using this command. It may be removed in a future firmware revision.

Change Baud Rate Command (temporary):
3 bytes: request byte, 0F, baud rate byte
Returns checksum if command is successful.
The rate will be changed as follows and will be effective after checksum is sent until the encoder is reset or another baud rate change command is received. At reset, the baud rate always defaults to 9600. Note: If multiple encoders are on the same bus, use address F to set them all to the same baud rate.

Baud Rate Byte 0x00 0x01 0x10 0x11 0x12 0x13 0x14 0x15
Baud Rate 115200 57600 38400 19200 9600 4800 2400 1200