6.2. Binary Commands

6.2.1. Binary Command Reference

When configured in “Binary” serial mode, the Simple Motor Controller offers several serial command protocols similar to that of other Pololu products. Communication is achieved by sending serial command packets consisting of a single command byte followed by any data bytes that command requires (not all commands require data bytes; some command packets simply consist of a single command byte). Command bytes always have their most significant bits set, while data bytes almost always have their most significant bits cleared:

    0x80 (128) ≤ command byte ≤ 0xFF (255)
    0x00 (0) ≤ data byte ≤ 0x7F (127)

This means that each data byte can only transmit seven bits of information. The only exception to this is the Mini SSC command, where the command byte is 0xFF, or 255, and the data bytes can have any value from 0x00 to 0xFE (0 to 254).

Note: If you are using the TTL serial interface and the motor controller is in Auto-Detect Baud Rate mode, you must send the baud rate indication byte 0xAA, or 170, on the RX line before sending any commands. The 0xAA baud rate indication byte can be the first byte of a Pololu protocol command, or it can be transmitted as a single byte. Communication via the controller’s virtual COM port is unaffected by baud rate settings and does not require the transmission of an initial baud rate indication byte.

This guide displays byte values in the format: “hex (decimal)”, where hex is the hexadecimal (base-16) representation of the byte’s value, and decimal is the decimal representation of the byte’s value. The hexadecimal representation starts with the prefix 0x (e.g. 0x10).

Keep in mind that a byte is simply a number between 0x00 (0) and 0xFF (255). For serial protocols, the important thing about a byte is its value, not the notation (e.g. hex, decimal, or binary) you use in your source code to write the byte.

The following three sub-protocols are available in binary serial mode:

Compact Protocol

This is the simpler and more compact of the two protocols; it is the protocol you should use if your Simple Motor Controller is the only device connected to your serial line. The compact protocol command packet is simply:

command byte (MSB set) [data byte 1] [data byte 2] [data byte n]
1XXXXXXX [0XXXXXXX] [0XXXXXXX] [0XXXXXXX]

For example, if we want to set the motor speed to 3200 (full speed) forward, we could send the following byte sequence:

    Hex notation: 0x85, 0x00, 0x64
    Decimal notation: 133, 0, 100

The byte 0x85 is the Set Motor Forward command, and the last two bytes contain the speed.

Pololu Protocol

This protocol is compatible with the serial protocol used by our other serial motor and servo controllers. As such, you can daisy-chain a Simple Motor Controller on a single serial line along with our other serial controllers (including additional Simple Motor Controllers) and, using this protocol, send commands specifically to the desired controller without confusing the other devices on the line.

To use the Pololu protocol, you must transmit 0xAA (170 in decimal) as the first (command) byte, followed by a Device Number data byte. The default Device Number for the Simple Motor Controller is 0x0D (13 in decimal), but this is a configuration parameter you can change. Any controller 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 (170) device number command byte (with MSB cleared) [data byte 1] [data byte 2] [data byte n]
10101010 0XXXXXXX 0XXXXXXX [0XXXXXXX] [0XXXXXXX] [0XXXXXXX]

For example, if we want to set the motor speed to 3200 (full speed) forward, we could send the following byte sequence:

    Hex notation: 0xAA, 0x0D, 0x05, 0x00, 0x64
    Decimal notation: 170, 13, 5, 0, 100

The byte 0x05 is the Set Motor Forward command (0x85) with its most significant bit cleared.

Mini SSC Protocol

The Simple Motor Controller also responds to the Scott Edwards Mini SSC protocol, a simple, three-byte serial protocol commonly used by servo controllers. This protocol allows you to control up to 254 different motors by chaining multiple motor controllers together. Since it only takes three serial bytes to set the speed of one motor, this protocol is good if you need to send many commands rapidly to multiple motor controllers. The Mini SSC protocol is to transmit 0xFF (255 in decimal) as the first (command) byte, followed by a Device Number byte and an 8-bit motor speed byte. If you think of the available motor speeds as ranging from -127 to +127, the motor speed byte is this signed speed value offset by 127. Therefore, A speed byte of 0 results in full-speed reverse, a speed byte of 127 results in speed 0 (motor stopped), and a speed byte of 254 results in full-speed forward. The command packet is:

0xFF (255) device number (0-254) speed byte (0-254)
11111111 XXXXXXXX XXXXXXXX

For example, if we want to set the speed of device 13 to approximately half-speed forward (63+127=190), we could send the following byte sequence:

    Hex notation: 0xFF, 0x11, 0xBE
    Decimal notation: 255, 13, 190

The Device Number byte and Speed byte can be any value except 255, though the Simple Motor Control center will not let you set the controller’s Device Number to a value greater than 127. If the Device Number byte matches the motor controller’s device number or if the Device Number byte is 254, the motor controller will respond to the command (all controllers respond to Mini SSC commands addressed to Device Number 254).

The Simple Motor Controller identifies the Pololu, Compact, and Mini-SSC protocols on the fly when configured in Binary serial mode; you do not need to use a configuration parameter to identify which of these three protocols you are using, and you can freely mix commands in the three protocols.

Trying the Binary Serial Interface

If you are having trouble using the Binary protocols, it can help to first use a program like the Pololu Serial Transmitter utility for Windows to send bytes to the Simple Motor Controller’s virtual COM port. This program makes it easy send packets of arbitrary bytes, which can help you identify if your problems are with your control software or with the bytes you are trying to send. The Serial Transmitter Utility can even automatically append the appropriate CRC7 byte to the end of the transmitted command packet.

Sending Binary (Compact Protocol) commands to the Simple Motor Controller with the Pololu Serial Transmitter utility.

Related Products

Pololu Simple Motor Controller 18v7 (Fully Assembled)
Pololu Simple Motor Controller 18v7
Pololu Simple High-Power Motor Controller 18v15 (Fully Assembled)
Pololu Simple High-Power Motor Controller 18v15
Pololu Simple High-Power Motor Controller 24v12 (Fully Assembled)
Pololu Simple High-Power Motor Controller 24v12
Pololu Simple High-Power Motor Controller 18v25
Pololu Simple High-Power Motor Controller 24v23
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors