D. cyclic redundancy check (crc) error detection – Pololu Jrk USB User Manual
Page 30
jrk on the line whose device number matches the specified device number accepts the command that follows; all
other Pololu devices ignore the command. The remaining bytes in the command packet are the same as the compact
protocol command packet you would send, with one key difference: the compact protocol command byte is now a
data byte for the command 0xAA and hence must have its most significant bit cleared. Therefore, the command
packet is:
0xAA, device number byte, command byte with MSB cleared, any necessary data bytes
For example, if we want to set the target to 4080 for a jrk with device number 11, we could send the following byte
sequence:
in hex: 0xAA, 0x0B, 0x61, 0x7F
in decimal: 170, 11, 97, 127
Note that 0x61 is the command 0xE1 with its most significant bit cleared.
The jrk responds to both the Pololu and Compact protocols on the fly; you do not need to use a configuration
parameter to identify which protocol you are using.
4.d. Cyclic Redundancy Check (CRC) Error Detection
For certain applications, verifying the integrity of the data you are sending and receiving can be very important.
Because of this, the jrk has optional 7-bit cyclic redundancy checking, which is similar to a checksum but more robust
as it can detect errors that would not affect a checksum, such as an extra zero byte or bytes out of order.
Cyclic redundancy checking can be enabled by checking the “Enable CRC” checkbox in the configuration utility. In
CRC mode, the jrk expects an extra byte to be added onto the end of every command packet. The most-significant bit
of this byte must be cleared, and the seven least-significant bits must be the 7-bit CRC for that packet. If this CRC
byte is incorrect, the jrk will generate its Serial CRC error and ignore the command. The jrk does not append a CRC
byte to the data it transmits in response to serial commands.
A detailed account of how cyclic redundancy checking works is beyond the scope of this document, but you can find
a wealth of information using
. The CRC computation is
basically a carryless long division of a CRC “polynomial”, 0x91, into your message (expressed as a continuous stream
of bits), where all you care about is the remainder. The jrk uses CRC-7, which means it uses an 8-bit polynomial and,
as a result, produces a 7-bit remainder. This remainder is the lower 7 bits of the CRC byte you tack onto the end of
your command packets.
The CRC implemented on the jrk is the same as the one on the
motor controller but differs from that on the
motor controller.
Instead of being done MSB first, the computation is performed LSB first to match the order in which
the bits are transmitted over the serial line. In standard binary notation, the number 0x91 is written as
10010001. However, the bits are transmitted in this order: 1, 0, 0, 0, 1, 0, 0, 1, so we will write it as
10001001 to carry out the computation below.
The CRC-7 algorithm is as follows:
1. Express your 8-bit CRC-7 polynomial and message in binary, LSB first. The polynomial 0x91 is written as
10001001.
Pololu Jrk USB Motor Controller User's Guide
© 2001–2014 Pololu Corporation
4. Using the Serial Interface
Page 30 of 45