State machine
The BMS has a state machine that defines the behavior of the BMS.
The state is available as a variable:
/driver/state
- string variable, the state name is printed/driver/statemachine/state
- integer variable, the state code is printed
Value | Mode | Description | DSC | CHG |
---|---|---|---|---|
0 | ERR | Permanent ERROR | OFF | OFF |
10 | FAIL | Fail (temporary) state | OFF | OFF |
20 | INIT | BMS is not set, minimum parametrization required | OFF | OFF |
30 | PROTECT | Transient state, verifying that the error(s) has disappeared | OFF | OFF |
40 | UNDERVOLTAGE | Undervoltage of some battery cell detected | OFF | OFF |
60 | STORAGE | Battery is being discharged to storage voltage | OFF | OFF |
70 | STANDBY | BMS switched OFF, no errors | OFF | OFF |
80 | PRECHARGING | Starting by precharging | PRE | OFF |
90 | OVERVOLTAGE | Overvoltage of some battery cell detected | ON | OFF |
100 | IDLE | Idle state - DSC port ON but no discharging or charging current | ON | OFF |
110 | DISCHARGING | Discharging battery | ON | OFF |
120 | REGEN | Charging battery by DSC from motor | ON | OFF |
125 | CHG_IDLE | Charger connected but no charging | ON | OFF |
130 | CHARGING | Charging battery by CHG from charger | ON | ON |
PROTECT state
If the BMS enters PROTECT state, the BMS will log the reason for entering the PROTECT state. The reason is available as a permanent variable protectLog
. The permanent is an array of 20 logs. With a new log, the values are shifted to the right, and the oldest log is deleted. The newest log is always on the first position (most left).
Protect reason (protectLog ) | Value |
---|---|
PROTECT_NONE | 0x0000 |
PROTECT_LEAVE_ERR | 0x0001 |
PROTECT_SHORTCUT | 0x0002 |
PROTECT_CHG_N_SHORTCUT | 0x0004 |
PROTECT_CHG_P_SHORTCUT | 0x0008 |
PROTECT_F_OFF | 0x0010 |
PROTECT_F_ON | 0x0020 |
PROTECT_DSC_OVERLOAD | 0x0040 |
PROTECT_NEG_CH | 0x0080 |
PROTECT_NEG_DSC | 0x0100 |
PROTECT_OVTEMP_D | 0x0200 |
PROTECT_OVTEMP | 0x0400 |
PROTECT_VBAT_DIFF | 0x0800 |
PROTECT_DIFF_CURR | 0x1000 |
PROTECT_PRCH_FAIL | 0x2000 |
PROTECT_UV | 0x4000 |
PROTECT_OV | 0x8000 |
Difference between PROTECT and FAIL/ERROR state:
- PROTECT - protecting the battery pack
- FAIL/ERROR - protecting the BMS (and pack)
FAIL/ERROR state
If the BMS enters FAIL/ERROR state, the BMS will log the reason for entering the FAIL/ERROR state in /permanents/errorLog
. The permanent is an array of 20 logs. With a new log, the values are shifted to the right, and the oldest log is deleted. The newest log is always in the first position (most left).
The only difference between FAIL and ERROR state is that the ERROR state is permanent, and the FAIL state is temporary. If you are in FAIL and the reason for entering the FAIL state is resolved, the BMS will automatically leave the FAIL state. If the BMS is in the FAIL for a longer time than the fail_timeout
, the BMS will enter the ERROR state.
If the BMS is in the ERROR state, the BMS will disable wake from the CAN bus. Before communicating with the BMS, it is necessary to wake up the BMS by pressing the button.
Fail reason (errorLog ) | Value | Description |
---|---|---|
ERROR_NONE | 0 | |
ERROR_MAX_FAILS | 5 | Maximum number of fails reached |
ERROR_MAX_SHORTCUTS | 6 | Maximum number of shortcuts reached |
ERROR_FAIL_TIMER | 7 | Fail timer reached |
ERROR_PANIC | 10 | Battery was overcharged over DSC port. |
ERROR_HARDWARE | 10 | Hardware error |
FAIL_HTISL | 101 | Heatsink isolation failure |
FAIL_BAL_ERR | 102 | Balancer is not responding |
FAIL_BAL_FAIL | 103 | Balancer is not responding |
FAIL_CRIT_UV | 104 | Critical undervoltage: Cell voltage is below /balancing/limiter/CritUnderVoltage |
FAIL_DISBAL | 105 | Disbalance of cells: Overvoltage and undervoltage at the same time |
FAIL_CELL_CHECK | 106 | Cell check error |
State machine configuration
The state machine is configured in the /driver/stateMachine
folder.
Parameter | Description |
---|---|
fail_timeout | If the state is FAIL for longer time than the timeout, the BMS enter ERROR state |
max_fails | Maximum number of fails before entering ERROR state |
max_shortcuts | Maximum number of shortcuts before entering ERROR state |
protect_timeout | Minimum time in PROTECT state before recovering |