State Machine๐
The firmware uses the state machines described below to sequence its behavior.
A high level state machine is accessible over CAN (see the 0x016 (State ID) packet). Underneath, a lower level state machine is responsible for sequencing behavior that needs to happen at the switching frequency.
High-level state machine๐
The high-level state machine is depicted below. Detailed transitions descriptions are found in the table below.
stateDiagram-v2
state "0 ยท Init" as Init
state "1 ยท ReadyToSwitch" as ReadyToSwitch
state "2 ยท ActivelySwitching" as ActivelySwitching
state "3 ยท Faulted" as Faulted
state "5 ยท Disabling" as Disabling
state "6 ยท Faulting" as Faulting
[*] --> Init: power on
Init --> ReadyToSwitch: Initialized<br/>sensors ready
ReadyToSwitch --> ActivelySwitching: Enable<br/>cmd 0x01 / 0x02 / 0x04
ActivelySwitching --> ReadyToSwitch: Disable<br/>cmd 0x00 (or 0xFF)
ActivelySwitching --> Disabling: Disable<br/>still winding down
Disabling --> ReadyToSwitch: Disabled<br/>switching has stopped
Disabling --> ActivelySwitching: Enable<br/>cmd 0x01 / 0x02 / 0x04
Disabling --> Faulted: Fault<br/>slow or fast fault, or CAN timeout
ActivelySwitching --> Faulting: Fault<br/>still winding down
Disabling --> Faulting: Fault<br/>still winding down
Faulting --> Faulted: Stopped<br/>switching has stopped
ReadyToSwitch --> Faulted: Fault<br/>slow or fast fault
ActivelySwitching --> Faulted: Fault<br/>slow or fast fault, or CAN timeout
Faulted --> ReadyToSwitch: Clear Faults<br/>cmd 0xFF, no active faults
class Init init
class ReadyToSwitch idle
class ActivelySwitching active
class Disabling idle
class Faulting fault
class Faulted fault
State Number |
State |
Description |
|---|---|---|
0 |
Init |
Awaiting initialization of all sensors |
1 |
ReadyToSwitch |
The motor controller is disabled and has no latched faults. |
2 |
ActivelySwitching |
The motor controller is actively switching. |
3 |
Faulted |
The motor controller has stopped itself in response to a fault condition (see below) |
5 |
Disabling |
A disable has been commanded, but the motor controller is still switching while it winds down (e.g. out of flux weakening). It stops switching on its own and moves to ReadyToSwitch. |
6 |
Faulting |
A fault has been detected, but the motor controller is still switching while it winds down (e.g. out of flux weakening). It stops switching on its own and moves to Faulted. Faults cannot be cleared until then. |
4, 7-8, 17-18 |
Reserved |
These are reserved debug states. |
The transitions are described in greater detail here.
Transition Name |
Description |
|---|---|
Initialized |
The low-level state machine reports that all sensors are initialized and reading properly (current sense, temp sense, resolver) |
Enable |
Valid Enable command is provided over CAN with a valid actuation command request. |
Disable |
A disable or clear faults command has been sent to the motor controller while it was switching. If it cannot stop switching immediately, it passes through Disabling first. |
Disabled |
The motor controller has finished winding down and stopped switching. |
Stopped |
After a fault, the motor controller has finished winding down and stopped switching. |
Fault |
The motor controller has detected a critical fault. Detailed fault descriptions are found below. |
Clear Faults |
The motor controller has received over CAN a ClearFaults message and has determined that the previous fault case is no longer applicable. |
Low-level state machine๐
The high-level state machine (controllable over CAN) controls a lower level state machine that runs at the full 32kHz control rate of the inverter
stateDiagram-v2
[*] --> Initializing: power on
ResettingResolver --> Initializing: next tick
Initializing --> Disabled: Initialized<br/>current sense & resolver ready
Initializing --> Faulted: Fault<br/>fast fault
Disabled --> Switching: Enable<br/>STATE = ActivelySwitching
Switching --> Disabling: Disable<br/>STATE โ ActivelySwitching
Disabling --> Disabled: next tick
Switching --> Faulting: Fault<br/>fast fault
Disabled --> Faulting: Fault<br/>fast fault
Disabling --> Faulted: Fault<br/>fast fault
Faulting --> Faulted: next tick
Faulted --> Disabled: Clear Faults<br/>cmd 0xFF, faults acknowledged
Faulted --> ResettingResolver: Clear Faults<br/>cmd 0xFF, after RDC_FLT
class Initializing init
class ResettingResolver init
class Disabled idle
class Disabling idle
class Switching active
class Faulted fault
class Faulting fault
class ResettingResolver transient
class Disabling transient
class Faulting transient
Commands๐
The state machine can be commanded into a new state using the CAN packet 0x019 (Command Packet).
Data Word |
Description |
Scaling (Divide by X to get real value) |
Datatype |
|---|---|---|---|
COMMAND |
Command sent from user. See Command Table below. |
N/A |
u8 |
DATA |
The data supplement used with the command packet. Interpretation depends on the COMMAND byte. |
Command-dependent |
i32 |
Command Name |
Command ID |
Description |
Data Scaling (Divide by X to get real value) |
|---|---|---|---|
Disable |
0x00 |
Disables switching on the motor controller. DATA unused, leave as 0x00 |
N/A |
Enable (Torque Control) |
0x01 |
This instructs the motor controller to go into torque control mode. It will transition to ActivelySwitching and attempt to drive a desired torque. DATA is desired torque in Newton-Metres |
10 |
Enable (Velocity Control โ edeg/s) |
0x02 |
This instructs the motor controller to go into velocity control mode. DATA is desired velocity in electrical degrees per second. |
1 |
Enable (Velocity Control โ MRPM) |
0x04 |
This instructs the motor controller to go into velocity control mode. The conversion from mechanical to electrical RPM uses the configured EEPROM Configuration value for number of motor pole pairs. DATA is desired velocity in mechanical RPM. |
1 |
Clear Faults |
0xFF |
Attempt to clear latched faults. DATA unused, leave as 0x00 |
N/A |
Fast faults๐
Fast faults are evaluated by the low-level state machine. They trigger the low-level state machine to fault.
Fault Name |
Evaluation Interval |
Trigger Packet |
Description |
|---|---|---|---|
|
32ฮผs |
|
|
|
32ฮผs |
This alarm may indicate internal FET damage, particularly if it fires immediately upon entering |
|
|
32ฮผs |
This alarm may indicate internal FET damage, particularly if it fires immediately upon entering |
|
|
32ฮผs |
N/A |
|
|
32ฮผs, must persist for 500 control ticks (about 15.6 ms) |
N/A |
A phase carries no current while voltage is applied. |
|
32ฮผs |
|
|
|
32ฮผs |
N/A |
Lost communication with the current sense ADCs, so no current sample is available. |
|
32ฮผs |
N/A |
A hardware watchdog has tripped due to excessive cycle skips in the low-level state machine. This likely indicates an issue with the flashed firmware. |
Slow faults๐
Slow faults are evaluated by the high-level state machine, and trigger the Disable path in the low-level state machine.
Fault Name |
Evaluation Interval |
Trigger Packet |
Description |
|---|---|---|---|
|
50ms |
N/A |
|
|
50ms, debounced over 1.2 seconds |
|
|
|
50ms |
N/A |
|
|
50ms, debounced over 500 ms |
N/A |
|