Manual

3.a.10. Command 192: Set Current Limit
Effect: Sets the current limit for the specified motor and the current control constant P (proportional component
of PID). The current limit is provided as an 8-bit value that is continuously compared to the corresponding motor
current average measured using the ADC. The control constant P is a 7-bit value that determines how the motor
behaves in the vicinity of the current limit. Additionally, P affects what the motor does in response to a motor
fault. If P is zero, the motor will shut down if it experiences a fault. Otherwise the motor will attempt to recover
from the fault by toggling the control lines. The following pseudocode details how the current limit is handled:
if current limit == 0:
no current limit, take no actions based on motor current average
else if P == 0:
shut down motor if motor current average > current limit
(or if a motor fault occurs)
else:
adjust pwm every 10 ms according to the formula:
internal pwm word += min( acceleration, P * ( current limit – current ))
actual pwm = min( target pwm, ( internal pwm word + 5 ) / 10 )
The pwm is internally tracked with two-byte precision rather than one to provide added resolution. When using a
non-zero current limit and P, the effect is that that pwm is decreased each update if the average current exceeds the
current limit. If the average current is below the current limit and the pwm is below the target pwm, the pwm will
be increased each update either based on our acceleration setting or based on a value proportional to the difference
between the average current and the current limit, whichever increment is smaller. Acceleration and P combine to
influence how the pwm will change each motor update cycle.
It is important to note that current sensing is not possible in joint motor mode. As such, this command has no effect
when running in joint motor mode. It is also important to note that current sensing is only possible when using a
motor driver daughter board that has VNH2SP30s (the VNH3SP30 does not provide current sense feedback).
This command does not save this setting to EEPROM, however it can be saved by issuing separate EEPROM-
write commands (240—Section 3.d.02) that store the values at the appropriate addresses (5 for motor 1 current
limit, 6 for motor 1 P, 7 for motor 2 current limit, and 8 for motor 2 P). P must be stored as a 7-bit value (i.e. P
must be <= 127).
Note: this command is bugged in firmware version 1.00, however it has been fixed in version 1.01.
Values sent: current limit (8 bits), control constant P (7 bits), motor (1 bit)
command byte = 192 | (motor << 1) | current limit MSB
data byte 1 = 7 lower bits of current limit
data byte 2 = 7-bit control constant P (MSB always zero)
3.a.11. Command 210: Set Motor PWM Frequencies
Effect: Sets the resolutions and clock prescalers of the two motor PWMs, which in turn allows customization of
the PWM frequencies. The PWMs can have either seven- or eight-bit resolution, and the allowed clock prescalers
are 8, 64, 256, and 1024. This means the eight possible PWM frequencies are 19.5 kHz, 9.77 kHz, 2.44 kHz,
1.22 kHz, 610 Hz, 305 Hz, 153 Hz, and 76.3 Hz. A seven-bit resolution coupled with a prescaler of 8 will result
in the only frequency in this group that generally exceeds what can be detected by the human ear ( 19.5 kHz);
the daughter motor-driver boards with VNH2SP30s will function at this frequency, but those with VNH3SP30s
will not. Because of this, the default frequency is 9.77kHz. Lower frequencies can be used to decrease switching
Orangutan X2 Command Documentation v1.01 © 2001–2010 Pololu Corporation
3. Low-Level SPI Commands Page 10 of 27