Incremental encoder command set – BEI Sensors Dual Encoder to USB Converter Module User Manual
Page 5

Tel:805-968-0782 / 800-350-2727 | Fax: 805-968-3154 / 800-960-2726
7230 Hollister Ave., Goleta, CA 93117 |
www.beisensors.com
Specification No. 02109-001 Rev. 06/11
INCREMENTAL ENCODER COMMAND SET
F - Read Encoder Status Flags
This command reads the three encoder status flags: Carry, Borrow and Power-up. The “c” field is the Encoder # (1 to 2). The Carry flag
is set whenever a carry rollover occurs (counter rolls from max value to zero) in the quadrature counter. Likewise, the Borrow flag is set
whenever a borrow occurs (counter rolls form zero to max value). The Power-up bit is set only upon initial power application to the unit.
This can be used to detect loss of power to the unit. Each flag will return a single character (either 0 or 1) representing the current state
of the flag. All three flags are reset to zero after the response is sent.
Send:
$0Fc<cr>
Success:
*0Fcxxx<cr>
Failure:
*0NACK<cr>
Example:
$0F1<cr>
*0F1101
For channel 1, the Carry flag is set, Borrow is cleared, and Power-up is set.
I - Set Encoder Index Configuration
This command sets the index configuration for each encoder channel. The “c” field is the Encoder # (1 to 2). The index can either be
enabled or disabled by sending a 1 or a 0 respectively for data field 'e'. If set to disabled, the <value> field is omitted. If enabled, the
<value> field is a number that the counter will be preset to when the index occurs. To zero the counter on index, set this value to 0. The
length of the <value> field will depend on the currently selected counter width (see Quadrature Configuration command 'Q'). For an 8,
16, 24 or 32 bit counter the <value> field will be 3, 5, 8 or 10 characters long respectively. Power on default configuration is index
disabled.
Send:
$0Ice<value><cr>
Success:
*0ACK<cr>
Failure:
*0NACK<cr>
Example:
$0I2100123<cr>
Enables encoder channel 2 index, with a preset value of 00123 (setup for 16 bit counter width)
Q - Set Quadrature Configuration
This command sets the quadrature configuration for each encoder channel. The “c” field is the Encoder # (1 to 2). The "m" field sets the
count mode, which can be set to one of four values. A value of 0 is Pulse/Dir mode, where a count pulse is input on input A and count
direction is input on input B. Values 1, 2 and 3 are quadrature count modes X1, X2 and X4 respectively. The "w" field sets the counter
width. Either 8 bit, 16 bit, 24 bit or 32 bit widths can be selected by sending a value of 0, 1, 2 or 3 respectively. The “s” field sets the
counter style. A value of 0 is free running counter a value of 1 is moulo-n counter (n = current index value from I command). Power on
default configuration is quadrature X1, 24 bit, free running counter.
Send:
$0Qcmws<cr>
Success:
*0ACK<cr>
Failure:
*0NACK<cr>
Example:
$0Q131<cr>
Sets channel 1 to quadrature X4 mode, 16 bit width.
R - Read Encoder Count Value
This command reports back the current count value of the encoder channel. The “c” field is the Encoder # (0*, 1 to 2). The length of the
<value> field will depend on the currently selected counter width (see Quadrature Configuration command 'Q'). For an 8, 16, 24 or 32 bit
counter the <value> field will be 3, 5, 8 or 10 characters long respectively.
Send:
$0Rc<cr>
Success:
*0Rc<value><cr>
Failure:
*0NACK<cr>
Example:
$0R2<cr>
*0R200004095<cr>
Reads the current count value of encoder channel 2, which is configured for 24 bits (8 character length).
The reported value is 00004095.
* If zero is sent as the encoder number, it will perform a read of both encoder channels. Each channel’s value will be sent
back in the data format specified by the encoder type (quadrature or SSI) with a comma between each data field. In the
following example, channels 1 and 2 are quadrature and set for 16 bit, with a count value of 12345 for each.
Example:
$0R0<cr>
*0R012345,12345<cr>
S - Set Encoder Counter Value
This command sets the encoder's counter to a specific value. The “c” field is the Encoder # (1 to 2). The length of the <value> field will
depend on the currently selected counter width (see Quadrature Configuration command 'Q'). For an 8, 16, 24 or 32 bit counter the
<value> field will be 3, 5, 8 or 10 characters long respectively.
Send:
$0Sc<value><cr>
Success:
*0ACK<cr>
Failure:
*0NACK<cr>
Example:
$0S1210<cr>
Sets encoder channel 1 counter to a value of 210, which is configured for 8 bits (3 character length).