Battery Management System in MATLAB 

 May 6, 2022

By  Sneha

In the 1998 - Early 2000's, smart technologies in all the Engineering fields emerged rapidly. One was Battery Management System (BMS), which was invented in 2006 to monitor Batteries without human supervision to increase Battery life. Why do you think people showed interest in BMS?

Cell Unbalancing

Cell Unbalancing

Battery Overcharging

Battery Overcharging

Observing the above figures, Figure 1 shows How one battery in a group of batteries drained fast yet not been charged due to the other batteries charged level. Figure 2 shows the effect of a battery being overcharged. To avoid the above scenario, people showed interest in the smart Battery Management System, which we will understand through this Blog.


What is BMS? BMS is an acronym for Battery Management System. Battery management systems (BMS) are electronic control circuits that monitor and regulate the charging and discharge of the Battery Pack (Group of Batteries). The battery characteristics to be monitored include detecting battery type, voltages, temperature, capacity, state of charge, power consumption, remaining operating time, charging cycles, and more characteristics. BMS monitors the following factors of Battery Pack:

Discharge Control

Battery DrainBattery Drain

Each battery has its own capacity based on charging and discharging in a Battery Pack. Whenever a Battery is used beyond its discharging capacity, Battery life and its efficiency reduce and increase the temperature of the battery. There is a necessity of balancing charging levels or discharging levels in a Battery Pack. BMS is used to overcome this issue.

SOC (State of Charging) determination

SOC determination

SOC determination

  • The State of charging (SOC) is essential to monitor the charging and discharging. By knowing each battery's charge percentage, we would be able to recognize its State, such as required charging mode or discharging mode. BMS extracts the S0C of each Battery in a Battery pack and maintains the SOC of all Batteries in a safe range.

State of Health (SOH) determination

used used battery vs unused battery

used battery vs unused battery

It is a comparison of the new battery and old used Battery performance. BMS maintains the record of time required by the old used battery to get charged and how long it can energize the passive element by comparing it to the efficiency of the new battery. This record also helps in cell balancing.

Cell Balancing

cell balancingcell balancing

As above mentioned, all the reading and determination are done by BMS to do cell Balancing. Cell Balancing plays a vital role in increasing the productivity of any electric device. Because most of the Electric device depends on Battery life and their performance. 

By understanding the importance of the Battery Management System, Let's now understand its working and Circuit diagram. Later we will go through the steps to build the BMS system in Simulink.


BMS Blockdiagram

BMS Blockdiagram

Let's understand working by studying each component function in BMS.


FETs used in BMS are usually MOSFET. CFET and DFET work as a controlled switch. Basically, these MOSFETs connect to Load and Charger. A Battery does two things: 1. Charging and 2. Discharging. One function has to stop while another part is being carried out. So, there exist two different tasks and setups.

  • CFET is closed when the Battery Pack is charging, whereas DFET is open. This CFET is monitored by a Microcontroller present in BMS, which detects the presence of voltage source from input and closes the CFET to charge the battery pack
CFET Functioning

CFET Functioning

  • DFET is closed when the battery is discharged through the load, whereas CFET is open. This DFET is monitored by the Microcontroller present in BMS, which detects the absence of voltage source from input and closes the DFET to run the load.
  • DFET Functioning

    DFET Functioning

    Fuel Gauge / Current Amplifier

    Current Amplifier

    Current Amplifier

    The current Amplifier is used to measure the charge flow into and from the battery while charging and discharging to report it to Microcontroller. The figure above shows that the current Amplifier is connected across a resistor. It collects the voltage dropout and sends the signal to the MCU. A microcontroller (MCU) consists of an Analog to digital converter which converts the signal obtained by the Current Amplifier to digital and uses the received data to identify the direction of the charge flow and accordingly switches on or off the CFET and DFET.

    Cell Balancing

    BMS uses lithium-ion Batteries, and its nominal voltage ranges from 2.5V to 4.2V. Therefore, each lithium-ion Battery has its own nominal voltage in a battery pack. So, when charging a Battery Pack, one battery may charge faster than other Batteries. If the charge flow continues to the one accused, the battery's temperature rises and reduces its life. And when discharging, if one battery has low nominal voltage and gets drained faster than other Batteries, that battery's temperature rises and reduces its life. BMS can avoid these scenarios.

    cell unbalancing

    cell unbalancing

    There are two types of the circuit for Cell Balancing in BMS:

    • Passive Cell Balancing
    • Active Cell Balancing

    Passive Cell Balancing:                   

    Passive Cell Balancing

    Passive Cell Balancing

             Here each battery is connected to a resistor, Capacitor, and a MOSFET (Switch), usually open State. When charging, if any Battery has a charge more than other Batteries, BMS switches on such battery-connected MOSFET, allowing charge from the battery to dissipate through the resistor. It follows the same process when discharging. Passive Cell Balancing is more efficient than Active Cell Balancing.

    Active Cell Balancing

    Active cell Balancing

    Active cell Balancing

    We use Capacitors and SPDT switches; capacitors connect between low voltage Battery to High voltage Battery through an SPDT switch. So, whenever the high voltage Battery has a higher charge than the low voltage, the SPTD switch closes the Capacitor's path with the high voltage Battery. The Capacitor stores the charge from that battery. After storing the charge, the SPTD switch closes the switch path, connecting the Capacitor with a low voltage Battery. The capacitor discharge to that battery. In this way, the Capacitor balances the adjacent Batteries. Active Cell Balancing is less efficient than passive cell balancing.


    BMS also consists of Thermistor, which monitors the heat dissipation. Whenever there is high heat dissipation, the Thermistor alerts the MCU, and MCU will turn off the process till the temperature of BMS is reduced.

    Real-time clock

    BMS consists of a real-time clock that is connected to the MCU. When the Battery pack is doing nothing, the real-time clock alerts the MCU by sending a signal. BMS switches off the BMS, which saves charge in the Battery (The main purpose of smart technology).

    Simulink Implementation:

    In Simulink, we can have three models for Discharging, Passive Cell Balancing, and Charging. We can combine all three models in one model.

    Steps to follow to model the BMS in Simulink are:

    1. Install the Simscape package.
    2. Build charging model: You need a Lithium-ion Battery; keep parameters as

                       Select Type-->Lithium-ion

                       The nominal voltage between 2.4V- 3.7V

                       Rated Capacity between 2.5Ah-3Ah

                       Initial State of Charge-->low (to check the charging process)        

    lithium ion Battery in Simulink

    lithium ion Battery in Simulink

  • The battery should be connected to a DC constant voltage through a resistor.
  • Battery output should be connected to the Bus-Selector. Then select signals such as SOC% or current or voltage.
  • Connect digital display output or if you want waveforms, then connect the scope to Bus- selector signal.
  • Regulate full charging using a relational operator and a MOSFET.
  •  3.Build Passive Cell Balancing
    Passive Cell Balancing

    Passive Cell Balancing

    • Connect 3-4 Batteries in a series. Follow the parameters as above mentioned except Initial SOC (depends upon the charging or discharging cell balancing)
    • Connect the ideal switch or MOSFET to each of the Battery through Resistor. Take series RLC load and disable inductance and capacitive reactance by making it to zero. Set the Nominal voltage of the resistor to 4 and Frequency to 0.1hz because we have to use dc voltage for each battery.
    • Take MATLAB Function and design so that one Battery's SOC is greater than another. Then, battery's switch should be closed.
    • Connect scope or display to get the analog or digital output to the MATLAB Function.

    4.Build Battery discharging model

    • Take 3-4 Batteries and connect them in series.
    • Connect a MOSFET across the Battery pack through a resistor with a resistance of 4ohm. The resistor one end should be connected to the drain of MOSFET, and the Source of MOSFET is connected to the battery negative end.
    • To control the MOSFET, which acts as a switch, uses a relational operator with a Bus selector to the battery.
    • Relational Operator input can be any of the parameters, either SOC, current, or Voltage. Still, the relational operator is different for different parameters. Relational operator output should be connected to the gate of MOSFET.
    • Let's consider SOC as input to the relational operator. The relational operator should be not equal to, and other input of the relational operator should be zero. So, if the battery charge reaches zero, the MOSFET turns off, and discharges stop.
    • The above three models should consist of Powergui of Simscape. Because BMS includes components of Simscape, which works only when there is Powergui. Since Powergui itself is a model that describes a basic model's equation.

    Get Access to
    Simulink Model

    Designing Battery Discharging, Charging, and Passive cell balancing using BMS Technique in Simulink; Developed in MATLAB R2021b with Simulink and Simscape


    The Li-ion battery disadvantages include:

    Protection/battery management system required: Lithium-ion cells and batteries are not as robust as other rechargeable technologies. They require protection from being overcharged and discharged too far. In addition to this, they need to have the current maintained within safe limits. Accordingly, one lithium-ion battery disadvantage is that they require protection circuitry incorporated to ensure they are kept within their safe operating limits.

    Fortunately, modern integrated circuit technology can be relatively easily incorporated into the battery or within the equipment if the battery is not interchangeable. Combining the battery management circuitry enables Li-ion batteries to be used without special knowledge. They can be left on the charge, and after the battery is fully charged, the charger will cut the supply.

    The battery management system built into lithium-ion batteries monitors several aspects of their operation. The protection circuit limits the peak voltage of each cell during charge as excessive voltage can damage the cells. They are typically charged in series as there is usually only one connection for a battery. Therefore, as different cells may require different levels of charge, there is a possibility of one cell experiencing a higher than the required voltage.

    Also, the battery management or protection circuitry prevents the cell voltage from dropping too low on discharge. Again this can happen if one cell can store less charge than others on the battery and its charge becomes exhausted before the others.

    A further aspect of the battery management system is that the cell temperature is monitored to prevent temperature extremes. Most packs' maximum charge and discharge current are limited to between 1°C and 2°C. Some do become a little warm on occasions when fast charging.

    Get instant access to the code, model, or application of the video or article you found helpful! Simply purchase the specific title, if available, and receive the download link right away! #MATLABHelper #CodeMadeEasy

    Ready to take your MATLAB skills to the next level? Look no further! At MATLAB Helper, we've got you covered. From free community support to expert help and training, we've got all the resources you need to become a pro in no time. If you have any questions or queries, don't hesitate to reach out to us. Simply post a comment below or send us an email at [email protected].

    And don't forget to connect with us on LinkedIn, Facebook, and Subscribe to our YouTube Channel! We're always sharing helpful tips and updates, so you can stay up-to-date on everything related to MATLAB. Plus, if you spot any bugs or errors on our website, just let us know and we'll make sure to fix it ASAP.

    Ready to get started? Book your expert help with Research Assistance plan today and get personalized assistance tailored to your needs. Or, if you're looking for more comprehensive training, join one of our training modules and get hands-on experience with the latest techniques and technologies. The choice is yours – start learning and growing with MATLAB Helper today!

    Education is our future. MATLAB is our feature. Happy MATLABing!

    About the author 


    I am Sneha G.K . I am an Electronic and Communication Engineering Student. I am a passionate Programmer and a researcher too. I enjoy exploring new things everyday and experimenting it.

  • Satyam Singh says:

    Battery Management System used to monitor Batteries without human supervision to increase Battery life becouse sometimes due to overcharging battery got fire. Battery management systems (BMS) are electronic control circuits that monitor and regulate the charging and discharge of the Battery Pack or Group of Batteries. The characteristics which is to be monitored are detecting battery type, voltages, temperature etc.
    it’s also used so that Battery could not used beyond its discharging capacity and also used for the Cell Balancing ( Active and Passive both), State of Health (SOH) and State of Charging (SOC) determination.
    FETs used in BMS are usually MOSFET.There are two types of FETs are used in which DFET is used during charging and CFET is used during discharging.
    The current Amplifier is used to measure the charge flow into and from the battery and to report it to Microcontroller.
    BMC contains thermister for monitering of the Heat dessipation and a real time clock when Battery pack is doing nothing,real time clock alert MCU and BMC switches off.
    Sometimes it happens that background functions of the system takes uses of the battery so if it possible then we should make a system in which only ongoing task can use the battery.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    MATLAB Helper ®

    Follow: YouTube Channel, LinkedIn Company, Facebook Page, Instagram Page

    Join Community of MATLAB Enthusiasts: Facebook Group, Telegram, LinkedIn Group

    Use Website Chat or WhatsApp at +91-8104622179