Deniz Gursoy Electrical Engineering at UPenn · Hardware Design, Robotics, and Embedded Systems
All projects

Controls · Simulation

Simulated 48-cell battery management system

A 48-cell lithium-ion (NMC) pack and the battery management system that runs it, both simulated in Python with no hardware.

Dates
Jul 2026
Context
Personal project
Role
Solo
Status
In progress: phases 1 to 7 of 8 done
0.44%UKF state-of-charge RMSE over all 48 cells on a 2 hour drive cycle, after the first 15 min; EKF 0.71%
2 sfor the UKF to cut a 45-point SOC error at boot to under 2%; EKF 58 s
7.0xfaster LP balancing than a 150 mA passive bleed, to under 1% SOC spread
4 / 4injected fault types diagnosed on the right cell; no false flags in the validation runs

Working only from noisy bus telemetry up to 0.9 s old, an unscented Kalman filter (UKF) tracked state of charge (SOC) to 0.44% RMSE, and in the validation runs a residual detector diagnosed all four injected fault types with no false flags. Seven of eight phases are done; the results write-up is not.

The problem

A pack controller never sees a cell directly. It gets noisy cell voltages up to 0.9 s old, one pack current and two temperature sensors per eight cells. From that it must estimate each cell's state of charge (SOC) and health, balance the pack and catch faults early.

I built the pack and its controller as one Python simulation, with no hardware.

What I built

Each cell is a second-order Thevenin model of a 2.5 Ah NMC cell with hysteresis, aging and temperature-dependent (Arrhenius) resistances. Forty-eight sit in series on a 6 by 8 thermal grid, with seeded manufacturing spread.

The controller reads only telemetry, with 1.5 mV of noise and 1 mV quantization on each voltage.

One five-state filter per cell estimates SOC, two RC voltages, resistance R0 and capacity. I ran an unscented Kalman filter (UKF) against an extended one (EKF). Each late voltage is paired with the current at its own sample time, and the R0 gain is zeroed at low current.

Every 60 s a linear program (LP) schedules 1 A cell-to-pack converters from those estimates. A residual detector compares each cell with the 48-cell median, and a policy answers each diagnosis with a current limit or an open contactor.

A FastAPI and WebSocket dashboard runs the loop live, with fault injection from the browser.

Results

Phases 1 to 6 each end in a scripted validation suite. All 52 checks pass at the current commit.

The estimation test is a 2 hour synthetic drive cycle on a pre-aged pack. Both filters booted at 50% SOC against a true 95%. The UKF was within 2% after 2 s and the EKF after 58 s. After the first 15 min, the UKF held 0.44% RMSE over all 48 cells and the EKF 0.71%. Coulomb counting (integrating current) from the same wrong start sat at 41.7%.

With the pack at rest, the LP balancer closed a 10.5% SOC spread to under 1% in 808 s and lost 0.95 Wh. A 150 mA passive bleed took 5,667 s and burned 21.74 Wh.

The detector diagnosed all four injected faults on the right cell: an internal short in 9 s, a frozen sensor in 12 s, a 60 mV sensor offset in 54 s and 2,000x accelerated aging in 1,302 s. The five validation runs raised no false flags in 96 cell-hours.

SOC tracking from bus telemetry, booted at 50% against a true 95%
SOC for the most-aged cell over the 2 hour cycle and its first 25 minutes: UKF and EKF follow the truth, the EKF starts 2 points low, coulomb counting stays 35 to 45 points low.
Per-cell SOC error at steady state, UKF against EKF
Cumulative distribution of per-cell SOC RMSE over the 48 cells: UKF median 0.37% with every cell under 0.85%, EKF median 0.68% with a tail to 1.15%.
Thermal model: heat from an internal short stays near the cell
Temperatures after a 0.2 ohm internal short at 60 s: the shorted cell reaches 120 °C by 3.6 minutes, adjacent cells about 47 °C, and the far corner stays at 25 °C.
LP balancing against passive bleed, regenerated at the current commit
Left: 48 true cell SOCs converge under active balancing. Right: SOC spread on a log axis reaches 1% in under 15 minutes for the LP balancer and about 95 minutes for passive bleed.
Validation scenario: 0.2 ohm short near 78% SOC, diagnosed in 9 s
Three stacked plots of the short scenario: cell 20 voltage drops from 3.9 V to 3.5 V at 300 s, the diagnosis marker follows at 309 s, and the current limit steps to 0%.
Validation scenario: 60 mV sensor offset, diagnosed in 54 s
Three stacked plots of the sensor offset scenario: cell 8 reports about 60 mV above its true voltage, its SOC estimate steps up 2 points, and the limit drops to 50% at 354 s.

Limits and next steps

The filter and the truth model share one structure, so the tests cover parameter mismatch and bad telemetry only. No cell was measured; parameters are nominal NMC values.

Each fault was validated in one scenario with one seed. The 9 s short was injected near 78% SOC. In the dashboard recording here, near 53% SOC, the onset pushed the shorted cell's SOC estimate up while its true SOC fell. The diagnosis took 125 simulated seconds, with the cell above 100 °C.

A later fix for false aging flags in hour-long dashboard soaks raised the R0 low-current cutoff from 0.5 A to 1.25 A. It also slowed balancing: the same scenario took 473 s before that change.

Phase 8, the results write-up, is not done.

Ask a question about this project

An AI assistant answers from this site's text. It can be wrong; this page is the source.