Compatibility Guides
Looking for replacement parts? US Digital's compatibility guides will help you find the perfect match. Start here »
The AD4B adapter provides a simple plug in method for connecting a single ended or differential quadrature encoder directly to an RS-232 serial com port. One end of the AD4 plugs into a serial port, while the other end plugs into a quadrature encoder. A quadrature counter (LFLS7166) inside the AD4 keeps track of encoder position, while a microprocessor provides a serial interface for the user to query the counter for the encoder position.
The bidirectional data lines carry commands from the host computer and responses from the AD4B. The format is 1 start bit, 8 data bits and 1 stop bit. The baud rate can be changed, but it always starts as 9600 baud after reset or power-up. Large numbers are transmitted with the most significant byte first.
Ping:
Function: Test for the presence of an AD4.
Send 1 byte: 'A' (41 hex)
Returns 1 byte: '4' (34 hex)
Read Position:
Function: Latches the counter and returns the current position.
Send 1 byte: 01 hex
Returns 4 bytes: 4 byte current position, LSB first. The LFLS7166 is a 24-bit counter, the 4th position byte can be ignored.
Initialize AD4's counter:
Function: Initializes the LFLS7166, sets the quadrature to a specified
multiplier, and loads the preset register with a specified value.
Initialization data sent to the LFLS7166's registers: 68 hex, B0 hex,
C0-3 hex (see LFLS7166 web page).
Send 6 bytes: 22 hex, quadrature mode (0, 1, 2, 4), 4-byte preset register value
Returns 1 byte: Checksum
Read the Counter's Output Data Register:
Function: Reads a byte directly from the LFLS7166's output latch(OL) (see LFLS7166 web page).
Send 1 byte: 33 hex
Returns 1 byte: Value of LFLS7166's OL, the OL consists of three bytes auto-incremented by each read, LSB first.
Write to Counter's Input Data Register:
Function: Writes a byte directly to the LFLS7166's preset register(PR),
the PR consists of three bytes auto-incremented by each write, LSB
first (see LFLS7166 web page).
Send 2 bytes: 44 hex, 1-byte data
Returns nothing.
Read the Output Status Register:
Function: Reads the LFLS7166's output status register(OSR) (see LFLS7166 web page).
Send 1 byte: 55 hex
Returns 1 byte: Value of LFLS7166's OSR.
Write to the Counter Control Register:
Function: Writes a byte directly to one of the LFLS7166's control
registers. Bits 6 and 7 select which control register to write to (see LFLS7166 web page).
Send 2 bytes: 66 hex, 1-byte register value
Returns nothing.
Change Baudrate:
Function: The baudrate change will be effective after checksum is sent
by the AD4. The baudrate always defaults to 9600 after a reset or
power-up.
Send 2 bytes: 77 hex, Baudrate Code (See table below)
Returns 1 byte: Checksum
| Baud Rate Byte | 0x00 | 0x01 | 0x10 | 0x11 | 0x12 | 0x13 | 0x14 | 0x15 |
| Baud Rate | 115200 | 57600 | 38400 | 19200 | 9600 | 4800 | 2400 | 1200 |
Enable Index:
Function: Enables the Index. The counter will reset when index=true.
Send 1 byte: 88 hex
Returns 1 byte: 'E' (45 hex)
Disable Index:
Function: Disables the Index.
Send 1 byte: 99 hex
Returns 1 byte: 'D' (44 hex)