6.4. Controller Variables

The Simple Motor Controller maintains a set of variables that contain real-time information about the controller’s inputs, outputs, and state, and these variables, in conjunction with the user settings, determine the behavior of the controller. These variables are all displayed in some way under the Status Tab of the Simple Motor Control Center (see Section 3.3), and they can all be requested via the serial interface (see the Get Variable command in Section 6.2.1 and Section 6.3.1) for use by custom control programs. The serial interface 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 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.4 for error descriptions.)
  • Bit 0: Safe Start Violation
  • Bit 1: Required Channel Invalid
  • Bit 2: Serial Error
  • Bit 3: Command Timeout
  • Bit 4: Limit/Kill Switch
  • Bit 5: Low VIN
  • Bit 6: High VIN
  • Bit 7: Over Temperature
  • Bit 8: Motor Driver Error
  • Bit 9: ERR Line High
  • Bits 10-15: reserved
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.4 for serial error descriptions.)
  • Bit 0: reserved
  • Bit 1: Frame
  • Bit 2: Noise
  • Bit 3: RX Overrun
  • Bit 4: Format
  • Bit 5: CRC
  • Bits 6-16: reserved
3 Limit Status The set bits of this variable indicate things that are currently limiting the motor controller.
  • Bit 0: Motor is not allowed to run due to an error or safe-start violation.
  • Bit 1: Temperature is active reducing target speed.
  • Bit 2: Max speed limit is actively reducing target speed (target speed > max speed).
  • Bit 3: Starting speed limit is actively reducing target speed to zero (target speed < starting speed).
  • Bit 4: Motor speed is not equal to target speed because of acceleration, deceleration, or brake duration limits.
  • Bit 5: RC1 is configured as a limit/kill switch and the switch is active (scaled value ≥ 1600).
  • Bit 6: RC2 limit/kill switch is active (scaled value ≥ 1600).
  • Bit 7: AN1 limit/kill switch is active (scaled value ≥ 1600).
  • Bit 8: AN2 limit/kill switch is active (scaled value ≥ 1600).
  • Bit 9: USB kill switch is active.
  • Bits 10-15: reserved
127 Reset Flags Flags indicating the source of the last board reset. This variable does not change while the controller is running and is not reported under the Status Tab of the Simple Motor Control Center. You can view it 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).
  • 0x04 (4): RST pin pulled low by external source.
  • 0x0C (12): Power reset (VIN got too low or was disconnected).
  • 0x14 (20): Software reset (by firmware upgrade process).
  • 0x24 (38): Watchdog timer reset (should never happen; this could indicate a firmware bug).

RC Channel Inputs

The raw and scaled signals measured on the RC channel inputs are always available through serial 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 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 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 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, 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 how hard the controller is braking with a value from 0 (full coast) to 32 (full brake). 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 unsigned
16-bit
Board temperature as measured by a temperature sensor near the motor driver. Temperatures below freezing are reported as 0. 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 System 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 System 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

Temporary 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. These temporary limits can be changed via the serial interface 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
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

The Simple Motor Controller uses an internal system of units, labeled internal units in the above tables, where 3200 represents the maximum possible motor speed in the forward direction, 0 represents a stopped motor, and -3200 represents the maximum possible motor speed in the reverse direction. The RC and analog channel inputs are scaled from their raw units into this internal “-3200 to +3200” unit system using the channel calibration settings.