
It is OK to read past the last variable. The Motoron will return zeros when you try to read from
unimplemented areas of the variable space.
All multi-byte variables retrieved by this command are returned in little-endian format, meaning
that the least-significant byte comes first.
Set variable
Arguments
Motor:
a motor number, or 0 for general variables
Offset:
the address of the variable to set (only certain offsets allowed)
Value:
the new number to store in the variable (14-bit)
Response
None
Arduino library
void setVariable(uint8_t motor, uint8_t offset, uint16_t value)
Several functions with names starting with
set
Command encoding:
0x9C motor offset lower 7 bits of the value bits 7 through 13 of the value
Description:
This command sets the value of the variable specified variable.
The
motor
and
offset
arguments specify which variable to set. These arguments are equivalent
to the motor and offset arguments of the “Get variable” command. However, this command can
only set certain variables, and the offset argument must point to the
first byte
of the variable. The
Motoron will report a protocol error if the motor or offset arguments are invalid.
The
value
argument specifies the 14-bit number to set the variable to. The Motoron looks at all
14 bits of the value argument, even if the variable you are setting is 8-bit. If the value specified by
those 14 bits is outside of the allowed range of values for the variable, the Motoron will change it
to the closest allowed value before setting the variable.
Each variable, along with its offset, allowed range of values, and whether it can be set with this
command, is documented in
.
Here is some example C/C++ code that will generate the correct bytes, given integers
motor
,
offset
, and
value
and an array called
command
:
Pololu Motoron Motor Controller User’s Guide
© 2001–2022 Pololu Corporation
9. Command reference
Page 58 of 67