Advertisement
Advanced Time: 5–6 weeks Electronics Engineering

Battery Management System (BMS)

Design and build a full-featured BMS for a 7S Li-ion battery pack with cell balancing, SOC estimation, temperature protection, and CAN bus telemetry.

BMSLi-ionCell BalancingSOCProtection ICBattery Pack
DifficultyAdvanced
Duration5–6 weeks
Components10 items
Steps4 steps

Introduction

Design and build a full-featured BMS for a 7S Li-ion battery pack with cell balancing, SOC estimation, temperature protection, and CAN bus telemetry. This comprehensive guide covers everything from design through implementation, testing, and deployment.

Theory & Background

Li-ion batteries require strict control to prevent: overcharge (>4.20V per cell → electrolyte decomposition, thermal runaway), over-discharge (<2.5V → copper dissolution, permanent capacity loss), overcurrent (short circuit → rapid self-heating → thermal runaway → fire), over-temperature (>60°C → accelerated aging, thermal runaway risk). BMS functions: Cell voltage monitoring (each cell individually), Current monitoring (charge + discharge), Temperature monitoring (cells + PCB), Protection switches (disconnect pack on fault), Cell balancing (equalize cell SOC), SOC estimation (remaining capacity), Communication (telemetry to host).

Advertisement

Components & Requirements

10 components required for this project.

#ComponentPurposeQty
1BQ76940 Battery Monitor IC (15S capable)Cell voltage and temperature monitoringx1
2BQ76200 High-Side FET driverCharge/discharge MOSFET switchingx1
3N-channel MOSFETs (100V, 30A) × 2Pack charge and discharge switchesx2
4Passive balancing resistors (2Ω, 1W per cell)Cell voltage equalizationx7
5NTC thermistors (10kΩ) × 4Cell and PCB temperature sensingx4
6STM32G0 MCU (BMS host)SOC algorithm and CAN telemetryx1
7SN65HVD230 CAN transceiverCAN bus communicationx1
8Current sensor (ACS758, ±50A Hall effect)Pack charge/discharge currentx1
9Li-ion cells (Samsung 21700, 5Ah) × 7Battery cells (7S configuration)x7
10Coulomb counter (LTC4150)Integrated current-time for SOCx1

Step-by-Step Implementation

Follow these 4 steps carefully.

1
Battery Safety and BMS Functions

Li-ion batteries require strict control to prevent: overcharge (>4.20V per cell → electrolyte decomposition, thermal runaway), over-discharge (<2.5V → copper dissolution, permanent capacity loss), overcurrent (short circuit → rapid self-heating → thermal runaway → fire), over-temperature (>60°C → accelerated aging, thermal runaway risk). BMS functions: Cell voltage monitoring (each cell individually), Current monitoring (charge + discharge), Temperature monitoring (cells + PCB), Protection switches (disconnect pack on fault), Cell balancing (equalize cell SOC), SOC estimation (remaining capacity), Communication (telemetry to host).

2
BQ76940 Cell Monitoring

BQ76940 monitors up to 15 series cells. Each cell connected to VC+ and VC- pins. Integrated ADC measures cell voltages with ±1mV accuracy. Temperature inputs: NTC thermistors via TS1–TS3 pins. Communication: I2C to MCU at 400kHz. Registers: CELLVOLTAGE1–15 (16-bit each), SYS_STAT (fault flags: OV, UV, OCD, SCD, OVRD_ALERT). Alerts: OV (over voltage), UV (under voltage) hardware comparators with programmable thresholds (via OV_TRIP, UV_TRIP registers). SCD (Short Circuit in Discharge): hardware latch within 70µs — far faster than MCU response.

3
State of Charge (SOC) Estimation

SOC estimation methods: Coulomb Counting (integrate current over time: SOC = SOC_initial - ∫I×dt / capacity). Accurate when reset is possible, accumulates drift over time. Voltage-Based: OCV (Open Circuit Voltage) vs SOC table lookup. Accurate at rest (after 2h equilibration), useless during load. Kalman Filter: combines Coulomb Counting with OCV correction, accounts for temperature and aging effects. Battery model: equivalent circuit (V_oc + R_internal + RC pairs for transient response). Extended Kalman Filter is industry standard for EV BMS.

4
Cell Balancing Strategy

Passive balancing: excess charge in high cells dissipated as heat through resistor. Simple, reliable, cheap. Energy wasted (efficiency loss). Bypass controlled by BMS: when cell voltage > (pack_average + 10mV), enable balancing resistor. Continue until within 5mV. Only balance near full SOC (cells most divergent at top). Active balancing: transfer energy from high cells to low cells using DCDC converters. High efficiency (80–90%), complex, expensive. Used in premium EV packs. For this project: passive balancing via BQ76940's integrated balancing switches (with external resistors).

Code & Implementation

Core code for bms_soc.c:

bms_soc.c C
// BMS SOC Estimation using Coulomb Counting + OCV correction // Runs on STM32G0, communicates with BQ76940 via I2C  #include <stdint.h> #include <math.h>  #define CELL_COUNT      7 #define CAPACITY_MAH    5000.0f     // 5Ah cell #define COULOMB_PERIOD_MS 100       // SOC update every 100ms  // OCV-SOC lookup table for Samsung 21700 at 25°C // [SOC%]: [OCV in mV] static const float OCV_TABLE[11][2] = {     {0,   2500}, {10,  3400}, {20,  3550}, {30,  3650},     {40,  3700}, {50,  3730}, {60,  3760}, {70,  3800},     {80,  3870}, {90,  3960}, {100, 4200} };  float soc_percent = 50.0f;  // Initial SOC estimate float accumulated_mah = 0;  float ocv_to_soc(float ocv_mv) {     for(int i = 0; i < 10; i++) {         if(ocv_mv >= OCV_TABLE[i][1] && ocv_mv <= OCV_TABLE[i+1][1]) {             float t = (ocv_mv - OCV_TABLE[i][1]) / (OCV_TABLE[i+1][1] - OCV_TABLE[i][1]);             return OCV_TABLE[i][0] + t * (OCV_TABLE[i+1][0] - OCV_TABLE[i][0]);         }     }     return (ocv_mv < OCV_TABLE[0][1]) ? 0 : 100; }  void bms_update_soc(float current_mA, float rest_voltage_mv, bool at_rest) {     // Coulomb counting     float delta_mah = current_mA * (COULOMB_PERIOD_MS / 3600000.0f);     accumulated_mah += delta_mah;     soc_percent -= (delta_mah / CAPACITY_MAH) * 100.0f;     soc_percent = fmaxf(0, fminf(100, soc_percent));      // OCV correction at rest (correct coulomb counting drift)     if(at_rest) {         float soc_from_ocv = ocv_to_soc(rest_voltage_mv);         // Kalman-like update: weight OCV heavily at rest         soc_percent = 0.3f * soc_percent + 0.7f * soc_from_ocv;     } }

Testing & Troubleshooting

Test Battery Management System (BMS) by verifying each subsystem individually before full integration.

!
Troubleshooting Tips

Verify power voltages, check ground connections, use serial monitor for debug.

Real-World Applications

*Electric bicycle battery pack
*Electric vehicle battery system
*Solar energy storage BMS
*Power tool battery management
*Drone battery management
*Portable power station
*UPS battery monitoring
*Grid-scale energy storage system

Extensions & Next Steps

  • Implement electrochemical impedance spectroscopy for battery health
  • Add machine learning SOH (State of Health) prediction
  • Build a battery formation and grading system for cell sorting
  • Implement wireless BMS communication over Bluetooth/CAN
  • Design a second-life battery repurposing testing system

Interactive Playground

Coming Soon

An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.

Frequently Asked Questions

What causes lithium-ion batteries to catch fire (thermal runaway)?
Thermal runaway is a self-amplifying heat cycle: heat generation exceeds heat dissipation. Triggers: internal short circuit (dendrite puncturing separator — caused by overcharging, low temperature charging), external short circuit, overcharging (>4.35V cell, beyond electrolyte stability window), over-temperature (>60°C accelerates exothermic reactions). Sequence: SEI decomposition (~90°C) → electrolyte decomposition with gas generation (>100°C) → separator melts → internal short → rapid temperature rise (>600°C/s) → electrolyte ignites → vent/fire/explosion. BMS prevents by monitoring and disconnecting before temperature reaches critical threshold.
Advertisement