Skip to main content
Firmware Stable

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
ValueModeDescriptionDSCCHG
0ERRPermanent ERROROFFOFF
10FAILFail (temporary) stateOFFOFF
20INITBMS is not set, minimum parametrization requiredOFFOFF
30PROTECTTransient state, verifying that the error(s) has disappearedOFFOFF
40UNDERVOLTAGEUndervoltage of some battery cell detectedOFFOFF
60STORAGEBattery is being discharged to storage voltageOFFOFF
70STANDBYBMS switched OFF, no errorsOFFOFF
80PRECHARGINGStarting by prechargingPREOFF
90OVERVOLTAGEOvervoltage of some battery cell detectedONOFF
100IDLEIdle state - DSC port ON but no discharging or charging currentONOFF
110DISCHARGINGDischarging batteryONOFF
120REGENCharging battery by DSC from motorONOFF
125CHG_IDLECharger connected but no chargingONOFF
130CHARGINGCharging battery by CHG from chargerONON

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_NONE0x0000
PROTECT_LEAVE_ERR0x0001
PROTECT_SHORTCUT0x0002
PROTECT_CHG_N_SHORTCUT0x0004
PROTECT_CHG_P_SHORTCUT0x0008
PROTECT_F_OFF0x0010
PROTECT_F_ON0x0020
PROTECT_DSC_OVERLOAD0x0040
PROTECT_NEG_CH0x0080
PROTECT_NEG_DSC0x0100
PROTECT_OVTEMP_D0x0200
PROTECT_OVTEMP0x0400
PROTECT_VBAT_DIFF0x0800
PROTECT_DIFF_CURR0x1000
PROTECT_PRCH_FAIL0x2000
PROTECT_UV0x4000
PROTECT_OV0x8000
note

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.

note

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)ValueDescription
ERROR_NONE0
ERROR_MAX_FAILS5Maximum number of fails reached
ERROR_MAX_SHORTCUTS6Maximum number of shortcuts reached
ERROR_FAIL_TIMER7Fail timer reached
ERROR_PANIC10Battery was overcharged over DSC port.
ERROR_HARDWARE10Hardware error
FAIL_HTISL101Heatsink isolation failure
FAIL_BAL_ERR102Balancer is not responding
FAIL_BAL_FAIL103Balancer is not responding
FAIL_CRIT_UV104Critical undervoltage: Cell voltage is below /balancing/limiter/CritUnderVoltage
FAIL_DISBAL105Disbalance of cells: Overvoltage and undervoltage at the same time
FAIL_CELL_CHECK106Cell check error

State machine configuration

The state machine is configured in the /driver/stateMachine folder.

ParameterDescription
fail_timeoutIf the state is FAIL for longer time than the timeout, the BMS enter ERROR state
max_failsMaximum number of fails before entering ERROR state
max_shortcutsMaximum number of shortcuts before entering ERROR state
protect_timeoutMinimum time in PROTECT state before recovering