Main Content

Battery Management System

This example models different aspects of a battery management system (BMS), and leverages Stateflow® capabilities to implement system controls. Specifically, Stateflow controls battery safety, implements fault detection, controls the state of a battery, and balances the cells in a battery.

The model includes two main subsystems: BMS Algorithms and Plant Model. The BMS Algorithms subsystem contains the Power System Control area for managing contactors and detecting faults, and the Battery Management area to ensure that the battery uses and charges power safely. Both of these areas rely heavily on Stateflow to function effectively. The Plant Model subsystem simulates the physical aspects of the battery, including charging, discharging, and precharge circuits to manage current flow safely. The Signal Editor block includes three different scenarios for this system: Discharging, Charging, and Standby.

Model of the battery management system.

Managing Battery Safety, Efficiency, and Performance

The BMS Algorithms subsystem is crucial for managing the safety, efficiency, and performance of the battery.

The BMS Algorithms subsystem with two areas named, in order from left to right, Power System Control and Battery Management System. Each area contains two charts and a Simulink block.

This subsystem houses two areas that work together to monitor and control various aspects of the battery system, Power System Control and Battery Management System.

Battery Integration

The Power Control System area represents an electronic control unit (ECU) that integrates the battery with its outer environment, such as an automotive engine. Inside this area are two Stateflow charts: Contactor_Management and FaultDetection.

The Contactor_Management chart manages the opening and closing of contactors to ensure safe operation. Within this chart there are two parallel states: ChargerContactState and InverterContactState that control charging and discharging, respectively.

The Contactor_Management chart. It contains the states CharterContactState and InverterContactState, each of which has several layers of child states.

When the chart first becomes active, it starts in the two parallel fail-safe states: OpenChargerContacts and OpenInverterContacts. Both parallel states have a similar child state layout. When there is a charge or discharge request, the controller checks that there are no faults before transitioning to the CloseChargerContacts or CloseInverterContacts states. Before closing the charger or inverter contacts, the controller closes the pre-charge circuit, which uses a capacitor to ensure equal voltage between the battery and the load. Finally, the controller throws a fault if the voltages are not equal within a certain time.

By using Stateflow to create this control system, you can ensure that the battery safely enters its charging and discharging states.

Detect Faults in the Battery

The FaultDetection chart detects and categorizes faults, including contactor faults, temperature faults, voltage faults, and sensor faults. Within this chart there are four parallel states: MonitorContacts, OvercurrentDetection, MonitorCellTemperature, and MonitorCellVoltage. Each state monitors a different aspect of the battery, and within each parallel state there is a linked atomic subchart to monitor specific faults. Some faults require maturation before triggering, and sensor faults compare measured pack voltage with the sum of cell voltages to ensure accurate detection.

The FaultDetection chart with four parallel states named, in clockwise order starting from the top-left, MonitorContacts, OvercurrentDetection, MonitorCellTemperature, and MonitorCellVoltage.

For example, the ContactFaultMonitoring state monitors the faults in the battery contacts. The system defaults to the NoFault state. However, if a fault is detected for a length of time greater than QualTime, Stateflow transitions to one of the two fault states, Fault1 or Fault2. Once in the fault state, the chart checks if the fault is critical or not. If the fault is critical, the Critical state becomes active and Stateflow sets CriticalFault to true. If not, then the NotCritical state becomes active. When Stateflow detects a fault, the output for the parallel state MonitorContacts becomes true.

The ContactFaultMonitoring state. It contains three substates named NoFault, Fault1, and Fault2.

The Current Power Limits Calculation subsystem calculates safe operational limits based on cell voltages and temperatures. The subsystem also ensures no single cell is in overvoltage or undervoltage and determines current limits based on the weakest cell. The process utilizes supplier-provided tables for maximum current based on voltage and temperature.

The Current Power Limits Calculation subsystem with two inputs named Sensors.Cell_Voltages and Sensor.Cell_Temperatures It uses many connected Simulink blocks to calculate the charge and discharge limits.

Manage Battery Operations

The Battery Management System area represents an ECU that manages the states of operation for the battery. This area also contains two Stateflow charts: Battery Control and Cell Balancing. The SOC Estimation subsystem estimates the state of charge (SOC) for the battery.

The Battery Control chart manages the initial state and transitions of the BMS.

The Battery Control chart. It contains the states Discharging, Standby, Charging, and Fault.

When the Battery Control chart becomes active, it starts in the Standby state. Initially, the chart checks for any critical faults. If a fault is detected, Fault becomes the active state, and BMS_State is set to BMS_State_Enum.BMS_Fault. If a fault is not detected, Stateflow then checks to see if there is a request for first for discharging, and then for charging. If either request exists, then Stateflow transitions to the corresponding state.

The Cell Balancing state ensures that there is even voltage distribution across cells to maintain battery health. This state also calculates the difference between the highest and lowest cell voltages and generates a command vector for the desired voltage differences. In this chart, the BalancingOFF state is first active. When the conditions for balancing are all true, the chart transitions to the BalancingON state. As the default child state, BalActive becomes active.

The CellBalancing state with two states named, in order from top to bottom, BalancingOff and BalancingOn. The BalancingOn state contains two substates named BalActive and BalNotActive.

When the value of BalancingCompleteFlag becomes true, the BalNotActive state becomes active. The BalNotActive state uses an exit port to return to the BalancingOFF state.

The SOC Estimation subsystem estimates the State of Charge (SOC) using coulomb counting, integrating current over time to provide an accurate estimation of the charge state of the battery. During discharging, it integrates current over time to estimate the charge state.

The SOC Estimation subsystem with two inputs named Sensors.Pack_Current and Sensors.Cell_Temperatures.

Simulate Battery Behavior

The Plant Model subsystem simulates the physical aspects of the battery system, providing a realistic representation of the battery behavior under various conditions.

The Plant Model subsystem with three subsystems named, in order from left to right, Pre-Charge Circuit, Charger and Load, and Battery Pack.

This subsystem includes several key components:

  1. Charger and Load: This subsystem simulates the current demands placed on the battery, whether for charging or discharging. It helps in understanding how the battery responds to different charging rates and load conditions.

  2. Battery Pack: The battery is modeled after an RC equivalent circuit to estimate the voltage and current, It uses lumped thermal capacity model to estimate the temperature change during charge or discharge. These models help simulate the dynamic behavior of the battery, including voltage changes and internal resistance.

  3. Pre Charge Circuit: This critical subsystem prevents a massive rush of current when connecting the battery to a load or charger. It uses a large resistor to gradually equalize the voltage, ensuring a safe connection. The precharge circuit includes an enabled subsystem with an integrator that holds its value, charging a capacitor when the circuit is opened. The resistor charges until its voltage matches the battery's voltage, at which point the full circuit connects, preventing potential damage from high inrush currents.

Overall, the Plant Model subsystem provides a dynamic simulation of the physical properties of the battery system, enabling accurate testing and validation of the BMS algorithms and ensuring safe and efficient battery operation.

Results

When you simulate this model, the system goes through three different scenarios that are defined in the Signal Editor block: Discharging, Charging, and Standby.

A Signal Editor scenario that discharges for roughly 2500 seconds, then charges for roughly 2000 seconds, then moves to standby for the remainder of the simulation.

The pack current, pack voltage, and cell temperature are all visibly affected by the change in scenario.

A Simulink Data Inspector graph demonstrating how the changing operating modes in the Signal Editor scenario impact three variables named Pack_Current, Pack_Voltage, and Cell_Temperature.

Additionally, you can see where the PackOverCurrentFault was detected.

A Simulink Data Inspector graph that displays eight possible faults. The fault named FaultBus.PackOverCurrentFault becomes active between 2750 seconds and 3250 seconds. No other faults are activated.

See Also

Topics