paint-brush
Developing Software for Battery Management Systems (BMS)by@andreysolovev
6,565 reads
6,565 reads

Developing Software for Battery Management Systems (BMS)

by Andrey SolovevOctober 9th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A battery management system (BMS) operating in your smartphone is similar to the one controlling the battery of an electric car. However, the functionality of these two systems may be totally different. The design complexity depends on the battery characteristics that you need to monitor with your BMS. Here, you will get to know more about BMS functionality, as well as battery states and how you can estimate them.

Coin Mentioned

Mention Thumbnail
featured image - Developing Software for Battery Management Systems (BMS)
Andrey Solovev HackerNoon profile picture

A battery management system (BMS) operating in your smartphone is similar to the one controlling the battery of an electric car. However, the functionality of these two systems may be totally different. The design complexity depends on the battery characteristics that you need to monitor with your BMS. Here, you will get to know more about BMS functionality, as well as battery states and how you can estimate them.

Nowadays, a battery management system (BMS) is a must for any smart system operating on a rechargeable battery. A BMS takes control of the battery performance, protects it from anomalous behavior, and communicates with battery-powered devices.

A rechargeable battery is a grey box system that operates with the aid of physical processes and electrochemical reactions. So, on the one hand, it is easy to measure the battery’s parameters, depending on the physical quantities, but on the other hand, some characteristics are hard to measure without taking a battery to pieces.

BMS software helps you look inside the battery to see the actual state of things. It provides estimations of the battery characteristics and ensures its operational stability. 

Writing reliable BMS software is challenging, but there are some recommendations on how to do this properly. We would like to share them with you.

What is BMS?

In short, a BMS is an electronic system responsible for the correct and safe operation of a rechargeable battery.

A BMS finds a use in a wide range of electronics: from consumer devices, like smartphones, to life-critical medical equipment and electric vehicles. BMS functionality directly depends on the system requirements.

The minimum set of BMS components includes a:

  • Control unit
  • Measurement unit
  • Charger
  • Battery

A simple device, like a power bank, needs a simple BMS. You can implement its functionality at the hardware level without any software development.

Minimum BMS structure

The architecture of high-end BMSes has the same principle, but it is multilevel. Complex BMSes may have extra power supplies, sensors, contactors, fans, and other units. The multilevel BMS developed by our engineering team includes:

  • An energy management system (EMS)
  • A sensing subsystem
  • A protection subsystem
  • A security subsystem


Example of multilevel BMS structure

Like any other embedded system, a complex BMS consists of hardware based on a microcontroller (MCU) and firmware. Advanced BMSes perform a wide range of functions. They can:

  • measure and control current and voltage input/output;
  • monitor critical parameters;
  • control battery environment;
  • calculate, store, and report battery data to the user or a higher-level system.

Multifunctional battery management systems require comprehensive BMS software development. For example, a control unit uses software to control BMS components’ interaction and coordination. A measurement unit needs software to collect and transmit battery data. For a high-end BMS, you can implement automated testing software. 

Voltagecurrent, and temperature belong to the physical parameters that a BMS can measure directly. Yet, a BMS with extended functionality may require estimations of the battery states that depend on many factors. Such states rely on physical quantities, chemistry, and the operating conditions of the battery. They include: 

  • State-of-charge (SOC)
  • State-of-health (SOH)
  • State-of-energy (SOE)
  • State-of-power (SOP)

These characteristics can be crucial for some systems, but there is no explicit way to measure them. Alternatively, you can estimate them. The accuracy of the state estimation is essential for system reliability. 

By developing BMS software with simulation, you can create a more accurate mathematical model used for battery state estimation. Our engineers build models using MATLABGNU Octave, and other simulation software.

Simulation makes it possible to reproduce the behavior of the battery and its operating environment. Battery models are implemented with the help of different algorithms that serve as estimators. You can use simulation to validate the BMS algorithms. 

Mathematical modeling often uses an equivalent circuit as an analog of a battery cell. It represents electrical characteristics and processes, including voltage, current, internal resistance, charging, and discharging.

You can replace an equivalent circuit with an approximate battery model based only on the data from the manufacturer’s datasheet. Anyway, you can use both types of models - equivalent circuits and approximations - to estimate battery parameters with the help of the Kalman filter or any other algorithm.

A model helps you estimate the battery states and characteristics with the measured data. For example, by measuring the charging/discharging time, you can estimate the battery capacity and SOC. You can also program the model for testing the BMS algorithms.

The complexity of algorithms depends on system requirements and BMS responsibilities. Advanced systems need sophisticated algorithms. But sometimes, you may not need complex battery management system algorithms, or even any software at all, because you may not need to estimate all the battery characteristics and states. 

Before proceeding to the development of BMS software, you should know for sure which state estimations are mandatory for your particular device. In case your system requires data of all the battery states, you should know how to estimate them.

How to Estimate State-of-Charge

State-of-charge or SOC shows the charging level of the battery from 0% (completely discharged) to 100% (fully charged). SOC estimation depends on the charging/discharging rate and capacity of the battery. 

Correct estimations of the SOC are necessary to avoid overcharge and over-discharge of the battery. For Li-ion batteries, over-discharge is critical and may lead to battery death. Lead-acid batteries are over-discharge-resistant.

Battery chemistry is one of the key factors that you need to consider as you write algorithms to estimate state-of-charge. You can use a BMS with different batteries, and you should develop it according to your battery type. The most common types include: 

  • Li-ion batteries (LiCoO2, LiMn2O4, LiNiMnCoO2, LiFePO4)
  • Nickel-based batteries (NiCd, NiMH)
  • Lead-acid batteries (sealed lead-acid, valve-regulated lead-acid)

Lead-acid batteries are simpler in use. Their physical parameters, such as voltage and charge/discharge capacity, have direct proportions. So lead-acid battery characteristics are easier to calculate with the help of datasheets and formulas.

You can estimate the capacity and SOC of such batteries by measuring the voltage and using the voltage-capacity relationship (discharge curve) from the battery specification chart. Normally, manufacturers provide specifications for every battery model that include charts or graphs showing the dependencies of battery parameters. 

Discharge curves are different for the open-circuit voltage (OCV) and the closed-circuit voltage (CCV). In the case of the closed-circuit voltage (CCV), the load is connected, and the discharge curve depends on the battery current too. 

The OCV provides a more explicit discharge curve, and it’s the easiest way to estimate the battery SOC. In this case, the current load is disconnected, and you can only measure the battery voltage. 

The discharge curve method is not very accurate since it relies on the minimum number of battery parameters. Besides, it works for batteries with the proportional voltage-capacity relationship.

In Li-ion batteries, the voltage dynamics are not distinct for both charge and discharge characteristics. For some temperature values, you can’t define the charging level of the battery by the voltage. Estimating the SOC for such a battery type, you will need to build a more complex mathematical model and algorithm.


Discharge curves of lead-acid and Li-ion batteries

Coulomb counting or current integration is another method on how to implement state-of-charge (SOC) estimators. It is more complicated, but it provides an accurate measurement of the electric charge that correlates with the battery capacity. The idea of this method is to calculate the electric charge by measuring the battery input and output current flowing at regular time intervals.

You can use coulomb counting together with the Kalman filter, which helps implement BMS algorithms using real-time simulation. This will increase the filtration accuracy of the changes in battery parameters and calculations of its derivatives. The Kalman filter takes into account the physical models of real-time processes running in the system.

How to Estimate State-of-Health

State-of-health (SOH) shows the battery wear level and comprises capacity, internal resistance, age, and other battery parameters.

A 100% SOH is the condition of a newly manufactured battery. As a battery wears down, the SOH level gets lower. SOH shows the present condition of the battery and helps predict when you should replace it. 

SOH estimation doesn’t depend on the battery chemistry directly. When you decide how to implement state-of-health (SOH) estimators, you should consider the operating time, temperature, and charge/discharge cycle of the battery. The more parameters you consider, the more accurate your estimation will be.

Calculation of charge/discharge cycles is one of the SOH estimation methods. This is the simplest method because it does not involve sophisticated BMS state-of-health algorithms. Besides, the battery manufacturer provides information on the guaranteed minimum number of charge/discharge cycles. To make this method more accurate, you can use it together with coulomb counting. 

Capacity is one of the important criteria showing battery degradation. The capacity decreases as the battery ages and degrades. Thus you can estimate the battery SOH by its capacity loss. The coulomb counting method will help you calculate the initial and present capacity of the battery and the capacity fading rate.

The SOH estimation accuracy directly depends on the number of methods you use. Except for the cycle calculation and coulomb counting, you can measure the internal resistance of the battery. To calculate this, you should compare the measurements of the battery parameters with the connected and the disconnected current load. This is a more complicated method that can give you a clearer picture of your battery’s state-of-health. 

It is crucially important for a battery not to exceed the specified temperature range and discharging rate. Batteries degrade much faster if they operate outside the rated values. To prolong your battery life, we highly recommend you consider this while implementing BMS monitoring and control algorithms.

How to Estimate State-of-Energy and State-of-Power

State-of-energy (SOE) shows the relationship between the energy remaining in the battery and the maximum energy that the battery can store.

The SOE tells you how much energy is available for a certain current load to perform a certain operation during a certain time interval. 

To estimate the SOE, it is necessary to consider the complete charge/discharge cycle of the battery. You can count the SOE by calculating the remaining and maximum energy of the battery.

The remaining energy is the difference between the energy consumed during the previous and current charge/discharge cycles. The maximum energy is the energy available for the current battery SOH with the maximum charging level.


State-of-power (SOP) shows the maximum power of the battery available for a certain operation at a particular time. It depends on the discharging level, operating voltage, and temperature.

The estimation of the SOP can be rather simple. To estimate it, you can measure the operating voltage and multiply it by the maximum discharge current, which is a rated value specified in the battery’s datasheet.

However, as the battery degrades, the rated current value changes. The above formulas do not consider internal resistance and self-heating, which can lead to the loss of power and energy of the battery. You have to keep these inaccuracies in mind while estimating SOE and SOP. 

If you want to design a state-of-the-art BMS, you can estimate the SOP by measuring the battery’s maximum output current through the internal resistance. This method provides a more accurate measurement.

How to Balance Cells in a Battery Pack

The battery pack contains several cells that may have different parameters and states, including SOC, SOH, SOE, and SOP. Different cell states negatively affect the overall battery performance and keep the battery from working to its full capacity. 

Cell balancing equalizes the charging level, voltage, and other characteristics of the cells within the pack. 

To balance the battery, you need to increase charge, current, or voltage in a cell with a lack of charge and decrease these parameters in a cell with excess charge. 

Cell balancing is implemented at the hardware level with the help of the charger and measurement unit. But you still need software to monitor and control the balancing process. Balancing resistors are the components of the BMS circuit intended for cell balancing. For example, you can decrease the voltage during the cell charging by connecting a balancing load.


Сell balancing process

The image above shows the battery pack consisting of three cells designed for the voltage of 4V. We need to charge the battery by connecting 12V to the pack. At the present moment, the first cell has a voltage of 4V; the second cell is 3.7V, the third cell is 3.5V. To balance the cells, we need to charge them equally to achieve the voltage of 4V in each cell.

The first cell is fully charged, and to avoid its overcharge, we connect the balancing load that keeps the cell from charging. Meanwhile, we charge the other two cells. As soon as the voltage of the second and third cells reaches 4V, we will connect the load to stop the charging.

BMS Monitoring

Battery states such as SOC, SOH, SOE, SOP rely on the same measurements and provide a comprehensive view of the battery’s condition. However, the battery state estimations have different objectives, and not all of them are vital for the proper system operation. BMS software design entirely depends on the functions your BMS should perform.

The primary goal of any BMS is to monitor the key parameters essential for battery life. Every battery has its own safe operating environment. In other words, it should operate within the specified conditions that include certain voltage, current, and temperature ranges. 

Operating above or under the set limits will lead to the battery’s fault conditions such as:

  • Overvoltage
  • Undervoltage
  • Overcurrent
  • Overheating

To avoid this, you need to provide your battery management system with reliable monitoring software. This software has a two-level implementation.

At the low level, MCU processes input values from sensors and ADC and filters them using filtering algorithms to cut out noise or fluctuations. After that, MCU sends the filtered data to the BMS dashboard or human-machine interface (HMI).

The dashboard is part of BMS monitoring software implemented at the high programming level. It displays the actual parameter values of the battery. If the battery operates outside its safe area, the program notifies the user of the alarm situation. The dashboard receives data about the entire system and then sorts it out, showing the states and parameters of each unit.

The design of the monitoring software depends on the BMS’s complexity. Advanced BMSes require more sophisticated implementations at higher levels. Simple BMSes may not need an HMI or even dashboard at all.

HMI displays battery data and enables the user to interact with the system. Implementing a BMS for a complex industrial solution, our Qt developers created an intuitive full-featured dashboard/HMI. It displays complete data of the entire battery pack, low-level battery elements, and the battery cells. The HMI allows the user to:

  • monitor battery parameters and states;
  • enable/disable battery units;
  • acknowledge and clear errors.

Below is the screenshot of the HMI of our industrial BMS solution. It shows the characteristics of all battery units and allows users to monitor their voltage and SOC. Besides, the dashboard helps keep track of voltage, current, SOC, SOH, and temperature of the entire battery and controls its alarm conditions.

Screenshot of the dashboard/HMI of the industrial BMS solution developed by Integra Sources

Conclusion 

The importance of a battery management system lies in its ability to control the battery and protect it from hazardous conditions. A BMS enables the efficient and long-lasting performance of the battery and the device it powers.

BMSes may have different functionalities. Simple systems may perform a couple of functions like measuring temperature and the battery’s state-of-charge. Complex BMSes monitor a full range of characteristics. To estimate the unmeasurable characteristics, BMS developers implement estimation algorithms.

Algorithms for battery management systems are based on mathematical models and formulas. They can make simple calculations using battery specifications and datasheets. But if you want to introduce more functions and consider a variety of characteristics, your BMS algorithms inevitably get more complicated.

The principal purpose of BMS algorithms is to provide high accuracy of battery state estimations and measurements. Correct estimations ensure battery safety and the reliability of the entire system.

Also published at: https://www.integrasources.com/blog/battery-management-systems-software-development/