Support » Pololu Simple Motor Controller G2 User’s Guide » 6. Using the serial and I²C interfaces »
6.4. Controller variables
The Simple Motor Controller G2 maintains a set of variables that contain real-time information about the controller’s inputs, outputs, and state. Most of these variables are all displayed in Status tab of the Simple Motor Control Center G2 software (see Section 3.2), and they can all be requested via the serial or I²C interfaces (see the “Get variable” command in Section 6.2.1 and Section 6.3.1). The “Get variable” command reports all variables as 16-bit (2-byte values transmitted least significant byte first), though not all variables use all 16 bits.
Status flag registers
Status flag registers are unsigned, 16-bit values whose bits convey general information about the controller’s status, such as any errors that have occurred, the errors are currently stopping the motor, and sources of controller output limitations.
ID | Name | Description |
---|---|---|
0 | Error status | The set bits of this variable indicate the errors that are currently stopping the motor. The motor can only be driven when this register has a value of 0. (See Section 3.3 for error descriptions.)
|
1 | Errors occurred | The set bits of this register indicate the errors that have occurred since this register was last cleared. This status register has the same bit assignments as the Error status register documented above. Reading this variable clears all of the bits. |
2 | Serial errors occurred | The set bits of this variable indicate the serial errors that have occurred since this variable was last cleared. Reading this variable clears all of the bits. (See Section 3.3 for serial error descriptions.)
|
3 | Limit status | The set bits of this variable indicate things that are currently limiting the motor controller.
|
127 | Reset flags | Flags indicating the source of the last board reset. This variable does not change while the controller is running. You can view this information in the Device Information window of the Control Center, which is available from the Device menu, and for the first two seconds after start-up, the yellow status LED flashes a pattern that indicates the last reset source (see Section 3.5).
|
RC channel inputs
The raw and scaled signals measured on the RC channel inputs are always available through serial/I²C variable requests, which allows programs using the serial interface to factor the channel inputs into their motor control algorithms. If no valid signal is detected, the raw channel value is reported as 0xFFFF (65535) and the scaled channel value is reported as 0. The Simple Motor Controller G2 is always reading the RC input channels, even when the Input Mode is not RC.
ID | Name | Type | Description | Units |
---|---|---|---|---|
4 | RC1 unlimited raw value | unsigned 16-bit |
The positive pulse width of the signal on RC channel 1. This value is 0xFFFF (65535) if no valid signal is detected. | 0.25 µs |
5 | RC1 raw value | unsigned 16-bit |
The positive pulse width of the signal on RC channel 1. This value is 0xFFFF (65535) if no valid signal is detected or if the signal is outside of the error max/error min channel calibration settings. | 0.25 µs |
6 | RC1 scaled value | signed 16-bit |
The scaled version of the RC1 raw value (based on RC channel 1 calibration settings). This value is 0 if the raw value is 0xFFFF, else it ranges from −3200 to +3200. | internal units |
8 | RC2 unlimited raw value | unsigned 16-bit |
See RC1 unlimited raw value. | 0.25 µs |
9 | RC2 raw value | unsigned 16-bit |
See RC1 raw value. | 0.25 µs |
10 | RC2 scaled value | signed 16-bit |
See RC1 scaled value. | internal units |
Analog channel inputs
The raw and scaled voltages measured on the analog channel inputs are always available through serial/I²C variable requests, which allows programs using the serial interface to factor the channel inputs into their motor control algorithms. If the controller detects a disconnected potentiometer (this requires potentiometer disconnect detection to be enabled under the Advanced Settings tab), the raw channel value is reported as 0xFFFF (65535) and the scaled channel value is reported as 0. The Simple Motor Controller G2 is always reading the analog input channels, even when the input mode is not “Analog”.
ID | Name | Type | Description | Units |
---|---|---|---|---|
12 | AN1 unlimited raw value | unsigned 16-bit |
The 12-bit ADC reading of analog channel 1. This value is 0xFFFF (65535) if the controller detects the input is disconnected. | 0=0 V, 4095=3.3 V |
13 | AN1 raw value | unsigned 16-bit |
The 12-bit ADC reading of analog channel 1. This value is 0xFFFF (65535) if the controller detects the input is disconnected or if the signal is outside of the error max/error min channel calibration settings. | 0=0 V, 4095=3.3 V |
14 | AN1 scaled value | signed 16-bit |
The scaled version of the AN1 raw value (based on analog channel 1 calibration settings). This value is 0 if the raw value is 0xFFFF, else it ranges from −3200 to +3200. | internal units |
16 | AN2 unlimited raw value | unsigned 16-bit |
See AN1 unlimited raw value. | 0=0 V, 4095=3.3 V |
17 | AN2 raw value | unsigned 16-bit |
See AN1 raw value. | 0=0 V, 4095=3.3 V |
18 | AN2 scaled value | signed 16-bit |
See AN1 scaled value. | internal units |
Diagnostic variables
The following variables can be used to monitor various internal conditions of the Simple Motor Controller G2, such as the input voltage, the board temperature, the and the motor speed.
ID | Name | Type | Description | Units |
---|---|---|---|---|
20 | Target speed | signed 16-bit |
Motor target speed (−3200 to +3200) requested by the controlling interface. | internal units |
21 | Speed | signed 16-bit |
Current speed of the motor (−3200 to +3200). | internal units |
22 | Brake amount | unsigned 16-bit |
When speed=0, this variable indicates whether the controller is braking or not. A value of 0 indicates coasting, and a value of 32 indicates braking. Otherwise, it has a value of 0xFF (255). The high byte of this variable is always zero. | 0=coast, 32=brake |
23 | Input voltage | unsigned 16-bit |
Measured voltage on the VIN pin. | mV |
24 | Temperature A | unsigned 16-bit |
Board temperature. Temperatures below freezing are reported as 0. Errors measuring the temperature are reported as 3000 (300 °C). | 0.1 °C |
25 | Temperature B | unsigned 16-bit |
Board temperature measured at a different location. See temperature A, documented above. | 0.1 °C |
26 | RC period | unsigned 16-bit |
If there is a valid signal on RC1, this variable contains the signal period. Otherwise, this variable has a value of 0. | 0.1 ms |
27 | Baud rate register | unsigned 16-bit |
Value of the controller’s baud rate register (BRR). Convert to units of bps with the equation 72,000,000/BRR . In automatic baud detection mode, BRR has a value of 0 until the controller has detected the baud rate. |
seconds per 7.2e7 bits |
28 | Up time (low) | unsigned 16-bit |
Two lower bytes of the number of milliseconds that have elapsed since the controller was last reset or powered up. | ms |
29 | Up time (high) | unsigned 16-bit |
Two upper bytes of the number of milliseconds that have elapsed since the controller was last reset or powered up. | 65,536 ms |
Motor limits
These variables contain the user-imposed limits on the motor output, such as maximum speed, acceleration, and deceleration. These variables are initialized to the hard motor limit settings (see Section 5.2) every time the controller is powered up or reset and every time the “Apply settings” button is pressed in the Simple Motor Control Center G2. Most of these limits can be changed while the controller is running to impose stricter/safer limits than the hard motor limit settings (see the Set Motor Limit command in Section 6.2.1 and Section 6.3.1).
ID | Name | Type | Description | Units |
---|---|---|---|---|
30 | Max speed forward | unsigned 16-bit |
Maximum allowed motor speed in the forward direction (0 to 3200). | internal units |
31 | Max acceleration forward | unsigned 16-bit |
Maximum allowed motor acceleration in the forward direction (0 to 3200; 0 means no limit). | Δspeed per update period |
32 | Max deceleration forward | unsigned 16-bit |
Maximum allowed motor deceleration from the forward direction (0 to 3200; 0 means no limit). | Δspeed per update period |
33 | Brake duration forward | unsigned 16-bit |
Time spent braking (at speed 0) when transitioning from forward to reverse. | ms |
34 | Starting speed forward | unsigned 16-bit |
Minimum allowed motor speed in the forward direction (0 to 3200). | internal units |
36 | Max speed reverse | unsigned 16-bit |
Maximum allowed motor speed in the reverse direction (0 to 3200). | internal units |
37 | Max acceleration reverse | unsigned 16-bit |
Maximum allowed motor acceleration in the reverse direction (0 to 3200; 0 means no limit). | Δspeed per update period |
38 | Max deceleration reverse | unsigned 16-bit |
Maximum allowed motor deceleration from the reverse direction (0 to 3200; 0 means no limit). | Δspeed per update period |
39 | Brake duration reverse | unsigned 16-bit |
Time spent braking (at speed 0) when transitioning from reverse to forward. | ms |
40 | Starting speed reverse | unsigned 16-bit |
Minimum allowed motor speed in the reverse direction (0 to 3200). | internal units |
Current limiting and measurement
ID | Name | Type | Description | Units |
---|---|---|---|---|
42 | Current limit | unsigned 16-bit |
The hardware current limit currently being used. See Section 5.2. | internal units |
43 | Raw current | unsigned 16-bit |
The raw motor current measurement. See Section 5.2. | internal units |
44 | Current | unsigned 16-bit |
Measurement of the motor current in milliamps. | mA |
45 | Current limiting consecutive count | unsigned 16-bit |
The number of consecutive 10 ms time periods in which the hardware current limiting has activated. | count |
46 | Current limiting occurrence count | unsigned 16-bit |
The number of 10 ms time periods in which the hardware current limit has activated since the last time this variable was cleared. Reading this variable clears it, resetting it to 0. | count |