Battery State of Charge estimation with Kalman filter - Python implementation

At the VéloMix hackathon at IMT Atlantique in Rennes, I met with Guillaume Le Gall (ESIR, Univ Rennes) and Matthieu Silard (IMT Atlantique) working on battery charging monitoring. We ended up working on the problem of State of Charge (SoC) estimation, that is evaluating the charge level of a battery by monitoring its voltage and current along time (and notably not its open circuit voltage).

simple battery equivalent circuit model with open circuit voltage (OCV) + resistive voltage drop

I had heard SoC estimation was often performed by the Kalman filter (and in particular with EKF, its extended version), but I had never had the occasion to implement it. Time was too short to get it working on the day of the hackathon, but now I have drafted a Python implementation, or more precisely three implementations:

  1. Step-by-step literate programming version of the filter, using a sequence of notebook cells, to implement one step of the filter → Nice to see the algorithm crunching the data line-by-line
  2. Generic Kalman filter implementation (all the above steps wrapped in a single function, should work with any state space model)
  3. Compact implementation specialized for SoC estimation with baked-in battery model (this last one should be the most useful to project, ready to convert to Arduino/C++ code)

All these are available in a single Jupyter notebook:

Author: pierre

assistant professor in Electrical Engineering & Control

Leave a Reply

Your email address will not be published. Required fields are marked *