File Exchange

image thumbnail

Lithium Ion Battery Pack with Cell Balancing

version (310 KB) by Javier Gazzarri
A 3s1p lithium ion battery pack is charged with a CCCV profile and passive balancing


Updated 28 Jun 2018

View License

Battery management is of paramount importance for lithium ion cells to ensure safe operation and durability. Charging needs to happen in a controlled way, typically using a constant-current / constant-voltage profile. It is also essential to ensure that individual battery cells are kept in balance to avoid under-utilization of the pack capacity.
In this example, Simscape® components model the behavior of a single battery cell, which is in turn replicated to create a series connection. A 3-RC + R equivalent circuit represents the electrical phenomena, linked in turn to thermal effects via a thermal mass and the assumption of Joule effect being the only source of heat.
Additionally, Simscape Electronics(TM) components provide the semiconductor devices responsible for the selective charge bleed that enables the balancing while charging. Temperature buildup is non-uniform because of the uneven current flow and the non-symmetrical thermal design: insulation on one end and natural convection on the other end. A supervisory logic strategy implemented in Stateflow® establishes the moment and duration of the charging current bleeding.
The Stateflow® block can generate embeddable C-Code by right-clicking and selecting C/C++ Code -> Build This Subsystem (requires Embedded Coder(TM)).

Cite As

Javier Gazzarri (2019). Lithium Ion Battery Pack with Cell Balancing (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Is this compatible with R2018a, LiCell library not found is the error!

Jin Kusaka

is the cell balancing done by fixed shunting resistor method?

Afiq Aiman

can you explain about the stateflow or do you have any paper to support this project ?

James Ang


For Latest Simulation Projects,Please Contact

Can you give me the same file which compatible with MATLAB 2014


If using a MATLAB version different from R2018a please run the README.m file the first time to generate the battery cell library blocks.

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux