Get variable (any input mode) – Pololu Simple User Manual

Page 66

Advertising
background image

To set the motor outputs to 50% braking (a Brake Amount of 16), we would transmit the following compact
protocol bytes:

We Send:

Command Byte Data Byte 1

Compact Protocol

0x92 (146)

0x10 (16)

Get Variable (any input mode)

Command Format:

Command Byte

Data Byte 1

Data Byte 2 Data Byte 3

Compact Protocol

0xA1 (161)

variable ID

-

-

Pololu Protocol

0xAA (170)

device number

0x21 (33)

variable ID

Response Format:

Response Byte 1 Response Byte 2

variable low byte variable high byte

Description: This command lets you read a 16-bit variable from the Simple Motor Controller. See

Section 6.4

for

a list of all of available variables. The value of the requested variable is transmitted as two bytes, with the low byte
sent first. You can reconstruct the variable value from these bytes using the following equation:

variable_low_byte + 256 * variable_high_byte

If the variable type is signed and the above result is greater than 32767, you will need to subtract 65536 from the
result to obtain the correct, signed value. Alternatively, if it is supported by the language you are using, you can
cast the result to a signed 16-bit data type.

Requesting variable IDs between 41 and 127 results in a Serial Format Error, and the controller does not transmit a
response.

Example:

To request the board temperature (variable ID 24), we would transmit the following compact protocol bytes and
wait until we have received two bytes in response from the Simple Motor Controller (or until our receiving function
times out, which could happen if there is a problem):

We Send:

Command Byte Data Byte 1

Compact Protocol

0xA1 (161)

0x18 (24)

We Receive:

Pololu Simple Motor Controller User's Guide

© 2001–2014 Pololu Corporation

6. Using the Serial Interface

Page 66 of 101

Advertising