Battery Management System

Algorithmic Architecture for BMS

Ather Engineering
Ather Engineering
Published in
11 min readJul 14, 2021

--

by Shivaram N V, Hari Vasudevan

A battery management system or BMS is core to the functionality of an EV. While much has been documented, written and talked about the mechanical, electrical and software architecture of a BMS, not much has been written about the algorithmic architecture of the BMS. Of-course a relevant question that could be asked at this point is — is the time spent in creating an algorithmic platform worth it? Here at Ather, developing and deploying such an architecture has helped us immensely in creating a robust and reusable platform. In this post we are going to detail the basic algorithmic structure of the Ather BMS and how it has helped accommodate the many different use cases of the 450X.

Algorithm Fragmentation

A cursory search of BMS algorithms often yields a number of various algorithms, dealing with charging, protection and discharge. Take charging for instance, even the very basic CC-CV charging flow that is common to most chargers has a number of caveats related to temperature, voltage and charging currents. What makes this trickier is that a variety of such chargers are encountered by the vehicle. For eg, fast chargers have different charging current capacities, temperature limits and protections when compared with a slow home charger. In addition to this the EV will most likely encounter multiple generations of these chargers each with its own rules. In fact since Ather continually upgrades the public charging infrastructure to improve the access and reliability of the fast charging network, it causes much (happy) consternation internally as now the algorithms will need to track these changes also. Similarly, discharge of a battery pack also needs to be handled by the BMS algorithms. Discharge control of the battery pack needs to ensure that we are able to maintain the right cell temperatures, avoid drops in individual cell voltages and gracefully transition to a lower power mode at low States of Charge (SOC). The BMS also needs to ensure consistency in performance even as the battery pack ages as part of natural degradation in cell capacity. Last but not least, the BMS also needs to compute the right SOC for display to the user.

Optimality & Robustness

The most commonly known charging algorithm like the CC-CV belongs to a class of heuristic algorithms that gets the job done but not necessarily in the most optimal way. In the case of charging, we’re chasing minimum charging time while adhering to battery safety constraints. Similarly take the case of SOC — there are quite a few heuristic methodologies to estimate the SOC to a “decent” extent. But to maximise the usable energy consumption from a battery, it is necessary to have an algorithm that is not only accurate but also robust to a whole bunch of noise factors that a Battery Management System is exposed to.

Accommodating all of the above functionality with a multiple different algorithms paired up with the corresponding hardware or vehicle platform or scenario will eventually lead to fragmentation of the code. Finally the maintainability of the code-base will also take a hit as verification and validation start to consume increased time and effort. To get around these issues on the 450X we have developed a scalable BMS algorithm architecture (Figure 1 below) that attempts to provide a framework wherein all the above described optimality criteria and variations can be accommodated.

Figure 1: Battery Charge & Discharge Vehicle Application Architecture

SOC & The Kalman Filter

Literature on the SOC estimation of a cell or battery pack is available in plenty. In fact a cursory glance through literature on this leads to various formulations of the Kalman Filter for the estimation of SOC. Literature is peppered with various Kalman Filter formulations for SOC such as the Extended Kalman Filter (EKF), or the Sigma Point Kalman Filter (SPKF) and further varieties of these with each providing added benefits for added complexity. However often literature on SOC estimation is the end in itself and further development of the Kalman filter towards an LQG (Linear Quadratic Gaussian) controller for discharge/charge regulation is overlooked. Here at Ather, we have developed a framework that can further put the state estimate obtained as part of the Kalman filter structure to create a flexible and powerful framework to accommodate most charging and discharge functions of the BMS.

Cell Dynamics & State-Space formulation

A number of cell models are generally used for formulation of the Kalman Filter. In Figure 1 below we present a simplified lumped parameter model that is in widespread use. A description of these parameters is given in 1. It is important to understand that all the RC parameters in this model are functions of SOC. Estimation of the RC parameters is a topic in itself and will be the contents of a subsequent blog post.

Additionally we would like to point out that our model is a second order model, whereas higher model orders may be used for higher accuracies with the trade off of complexity. Given the above model and parameters, the equations that define this system are as shown below. The voltages V₁ and V₂ are described by the dynamic equations 4, 5, while SOC dynamics by 6. The OC voltage Voc is linearized (in equation 2) and re-written to cast it in a form suitable for LTI state-space analysis. This assumption is valid as long as the SOC does not change very fast, or in other words the rate of change in SOC is an order of magnitude different from V₁ and V₂ dynamics, which thankfully is the case.

Figure 2: RC parameter Model

Using these above equations we are now able to formulate a state-space model for an individual cell. This formulation is described in the following equations, with the state equation 7 and output equation 8 formulated as shown.

State Estimators

In the prior section we have a model for cell dynamics, we now explain the basis for formulating a state estimator. Of-course the way we have described the cell dynamics model is by no means the only way to describe the dynamics. Ours is a current input and voltage output system, and there exist equally valid models with voltage in and current out. Furthermore, we have not included the Voc hysteresis in this model, which for certain cell chemistries can be dominant.

All state estimators function via a ‘plant’ model that mimics the dynamics of the system under observation and a ‘correction’ term which is usually a measurable output of the system. Eventually the plant model and the correction term are fused together to arrive at a state estimate that is more accurate than either relying on the model or the sensor alone. The beauty of the Kalman filter is of-course that it estimates the least squares optimal estimate of the state even under varying noise conditions. A basic state estimator and its formulation is described below in equations 9 and 10.

In state estimator design of course the main question is how we design the correction gain ‘L’. Whether we are designing a Luenberger or a Kalman Filter, there’s tons and tons of literature on how best to pick ‘L’. We would like to refer the reader of this blog to the excellent webpage of Dr. Gregory L. Plett, Professor, University of Colorado. A thorough description of Kalman Filter equations is described in his course notes on Battery management and Control.

Charge & Discharge Controllers

At this point if our intent was to only describe a better way to estimate the State of Charge (SOC), we would be done. However, while the state estimator is a great way of arriving at the true SOC of the cell, it can also be put to other uses namely in the charge and discharge control of the battery pack.

Charging Controllers

The most widely used charging controller for EV is the CC-CV controller, meaning that the charger charges at a constant current until it hits a terminal cell voltage and then transitions to a CV charging mode, which applies a constant voltage until the cell voltage rises to equalize this voltage and the charging current drops to zero. This transition from CC to CV on chargers is what mostly causes much of the grief in creating a scalable architecture.

Figure 4: Thermal Lumped Mass Model
Figure 3: Charge & Discharge Control Architecture

Incorrect transitions, transitions at the wrong voltage, delayed transitions etc. are a subset of the problems that come up regularly while using this method. Furthermore, as discussed at the beginning of this blog, accommodating a variety of chargers with their own quirks and nuances results in code and algorithm fragmentation.

Additionally, Lithium ion batteries have idiosyncratic thermal behaviour, especially when coupled with the voltage dynamics. This makes the case for combining the thermal dynamics of batteries within the same formulation so one can control all aspects of safety and performance within one overarching framework. Before going into the control architecture, let’s quickly look at a first order linear thermal model of a battery. Refer to Figure 4 above for a diagrammatic representation of the same.

Now that we have the full state estimate

along with

we realized that designing a feedback controller for charging and discharge was the next step. Figure 3 shows the overall algorithmic architecture of the controller.

As can be seen the system consists of two controllers — one for the charge path and another for the discharge path. Both controllers are driven off the state estimate from the Kalman Filter. Both controllers include a temperature controller for additional control of battery pack temperature. The controller gains itself can be arrived at by various techniques such as pole-placement, LQR etc… Figure 5 shows various common scenarios handled by the charging controller. Various comparisons in the plots show:-

Fast Charging alone: Shows the effect of unrestricted charging at max charger current. Note that the terminal voltage of the cells is hard to control in this case.

Charging with terminal voltage control: Given the state output equation 8 it is possible to control the terminal voltage of the cells during charging so we don’t exceed any prescribed charging voltage limits.

Temperature Control: Additionally it is possible that the cell temperature may need to be controlled, so as to not exceed safety limits. This is very likely in a tropical country such as India where the ambient over concrete or tar might touch 45°C and the cells need active temperature regulation to not over heat during charging.

Slow Charging: Finally, we also illustrate how a slow charger operates at a lower current and how it is possible to charge with a different charger using the same framework.

We should also note that this framework employs the constant current (CC) capabilities of the charger. We never request a transition to the CV mode. However, it is not necessary that this be the only way to design a charging controller, we could design a controller to work in charger CV mode entirely

Discharge Controllers

With our new scooter, the 450X, featuring the much anticipated WARP mode, it is more important than ever to ensure that we are able to maintain the right cell temperatures and avoid drops in individual cell voltages in an optimal and consistent manner without compromising on the unending performance this mode is guaranteed to provide. Additionally, it is also critical to gracefully transition to a lower power mode at low SOCs. It is worth noting that the problem is similar to the one described above of charging a battery in the fastest possible manner without breaching safety constraints on voltage and temperature. Figure 3 above shows the discharge control architecture to achieve this. And Figure 6 shows a common discharge profile as dictated by the discharge controller.

Normal: Shows the effect of unrestricted discharging at max possible drive currents with graceful transition to low power with lower SOCs. Note that the terminal voltage of the cells is hard to control in this case.

Riding with terminal voltage control: Given the state output equation 8, it is possible to control the terminal voltage of the cells during charging so we don’t drop below any prescribed discharging voltage limits.

Temperature Control: Additionally, it is possible that the cell temperature may need to be controlled, so as to not exceed safety limits. This is very likely in a tropical country such as India where the ambient over concrete or tar might touch 45°C and the cells need active temperature regulation to not over heat during a drive.

Another important point to note that along with doing this in the most optimal and consistent manner as described above, it is also important to maintain a “smooth” maximum discharge current profile to prevent jerky behaviour during a ride.

Figure 6: Discharge Profile

Conclusions

After all the math and result plots shown above, we wanted to circle back to what was the intent of this blog post. We began by describing how a traditional CC-CV methodology becomes hard to handle given algorithm fragmentation and why we wanted to create a unified framework for the BMS. We then introduced the design for the Kalman filter to estimate the BMS SOC, at this point realized that the state estimates of the Kalman filter can be put to greater use than just computing the SOC. Using standard modern control theory we then extended the functionality of the EKF to create an LQG controller for both charge and discharge of the battery pack. Furthermore, given the flexibility of the LQR design process we can now explore various measures of optimality on both charge and discharge of the battery pack.

However, there are many parts of this write up that refer to extensive cell characterisation that must be accomplished before we can enable such a framework. These include:

• Cell RC parameter estimation

• Kalman filter design and implementation

• BMS current, voltage, and temperature sensing

We will cover these items in future blog posts, stay tuned…..

References

• Lectures by Dr. Gregory L. Plett — University of Colorado Colorado Springs — ECE5720: Battery Management and Control — Notes 3

• Gene F. Franklin, Michael L. Workman, and Dave Powell. Digital Control of
Dynamic Systems
. Addison-Wesley Longman Publishing Co., Inc., USA, 3rd edition, 1997.

Originally published at https://blog.atherenergy.com on July 14, 2021.

--

--