Estimating battery state of charge (SoC) is difficult and complex because of the non-linear
character of the batteries and the internal environment assessments. Neural networks and NXP’s
model-based design toolbox (MBDT) help simplify the development of a battery SoC estimation
Modern battery management systems (BMS) ensure cell packs' safe and efficient operation in various
solutions within electric vehicles, power supplies, smartphones, MP3 players and most
battery-driven equipment. Calculating the battery state of charge (SoC) is one of the most
critical roles of BMS, an estimation the system assesses –like the battery percentage displayed in
a phone. An accurate estimation of SOC protects the battery, prevents discharge/overcharge and
improves its life; it also lets the solution perform control strategies for energy-saving.
Traditionally, an engineer would need to build a very accurate battery model to get reasonable
estimations, but that is often hard to characterize. This problem fueled the search for an
alternative in which artificial intelligence brought its contributions. Battery power management
developers started to use adaptive systems, like neural networks (rather simple ones), to create
data-driven models of the cell and use them to get a very accurate SoC estimation by evaluating
the history of voltage, current and ambient temperature.
Model-Based to the Rescue
Estimating battery SoC is challenging and complex because the cell configuration is non-linear
(making it hard to model it correctly), and the internal environment is hard to assess (comparing
laboratory versus real-world conditions) –thus raising the instability of the battery1.
Model-based algorithms are the most investigated techniques for estimating SoC in lithium-ion
(Li-ion) batteries2. Engineers found in model-based a change in the paradigm to design
and deploy robust solutions.
Model-based design (MBD)
implies putting together graphical elements that implement specific functionalities to design an
application. Building a solution using MBD is relatively simple. The diagram for the application
logic is transcribed into a model-based software environment to implement the control algorithm.
Diagram example to control a vehicle through input from a camera and its translated algorithm on
a model-based software environment (Simulink® from MathWorks®)
Developing applications in those MBD environments help to:
- Simulate: verifying algorithms before interacting with hardware saves time and money
Generate code automatically: avoiding many hand-written code issues while increasing design
Reuse: the functionality can be reused in any other model once the model is ready and thoroughly
Focus on the application itself: looking at a diagram representing the application (algorithms,
logic...) instead of studying numerous code lines, searching for the embedded comments to
understand their meaning –not being entangled in minor details but
Using the MBD viewpoint helps compensate for the increased complexity of modern applications. It
also takes advantage of the software abstraction layers commonly used for embedded designs
development (hardware optimized device drivers, plus middleware and libraries that implement
specific functionalities) while enhancing drivers' code optimization and reusability.
Compared to a typical development workflow, which implies writing the (C code) application
algorithm and integrating it with specific hardware function calls, code is automatically
generated from the model in the MBD development. Furthermore, it can work together with necessary
hardware-specific software, transforming the programming into block parameters configuration.
MATLAB and Model-Based Design Toolbox
Also, we provide the S32 Design Studio IDE
where programming is executed with build, debug and configuration embedded tools (allowing setting
and initializing drivers, middleware, and libraries used inside the design in a graphical manner).
Besides the classical debugger options, we also offer FreeMASTER, our data visualization tool enabling real-time application debugging for validating the system
behavior for imposed performances. FreeMASTER features options like writing and reading
variables, memory locations, and monitoring desired signals on the embedded target.
MBD applications can be verified and validated inside the Simulink ecosystem using its simulation
functionalities, while test and verification can be performed starting from the requirements
definition phase. Simple models can be designed and simulated to validate the algorithm's
high-level behavior. After that, certain functionalities and subsystems of the design can be
modeled, tested and simulated independently at a more detailed level; also, results can be
displayed and analyzed — all in a PC-enabled environment to check the feasibility of the ideas.
Code can be generated and executed on the host PC for the design after the simulation results are
satisfactory for the imposed system behavior. SiL provides an idea of how the implemented logic
will be transcribed into code, creating the context for code optimization and efficiency
improvements before the application runs on the target.
Various models or parts of the application can be directly tested on the target. PiL provides
relevant information related to the capability of the chosen hardware to run the developed
application logic. Engineers can compare the results obtained in all of these phases, allowing
testing the design at every development step.
MCU Final Application
MBDT simplifies building the application from the previously tested and validated modules and
deploying it as a final solution. Engineers can use MBDT at any stage to take advantage of its
functionalities: mathematical functions simulations, code generation and MCUs drivers
configuration and control.
MATLAB and Model-Based Design Toolbox
To better experience download the
On top of the robust MBDT capabilities and features, our MBDT team made available a broad online
engineering support community packed with code examples, forum answers, quick start guides, 101
tutorials and more resources to get started designing, verifying and deploying embedded
MBDT community . They also developed a series of webinars, from beginner to advanced level,
showcasing motor control (guiding how to build a PMSM or BLDC application from scratch, walking
step by step through the development process) or battery management systems application (including
Deploying a Deep Learning-based State-of-Charge Estimation Algorithm to NXP S32K3 MCUs
training with MathWorks)
Using model-based design toolbox (MBDT) helps power embedded software development for battery
management systems (BMS) by simplifying the battery state of charge (SoC) estimation algorithm
development. MBDT takes advantage of the software abstraction layers to automatically generate
code from the SoC algorithm model, easily transforming the programming into block parameters
Ingvild B. Espedal, Asanthi Jinasena, Odne S. Burheim, and Jacob J. Lamb; Current Trends for
State-of-Charge (SoC) Estimation in Lithium-Ion Battery Electric Vehicles; Energies 2021 – 14,
Shi Li, Changfu Zou, Mirco Küpperc, and Stefan Pischingera; Model-based state of charge
estimation algorithms under various current patterns; Energy Procedia – Volume 158, 2019;