The use of virtual battery technology in the design of test systems can facilitate the development of better products, reduce project risks, and get products to market faster.
The use of rechargeable batteries in consumer products, business applications and industrial systems continues to grow substantially. The global market for all batteries will reach almost €68 billion (US$74b) this year, and rechargeable batteries will account for nearly 82% of that, or €55 billion (US$60b), according to market researcher Frost & Sullivan.

Figure 1: Simulation of thermal runaway using the Li-Ion model from the MapleSim Battery Library
Growth like this means several things. First, large companies have moved or are moving into the market, designing and offering products ranging from hand-held devices to large power back-up systems. Second, as the systems get larger, battery technologies have to match the technical challenges of increasing cell capacity, thermal stability, life extension and disposal.
Meeting the Technical Challenges
Monitoring and controlling larger cell arrays through Battery Management Systems (BMS) helps to minimize charge times and maximize efficiency and battery life. Design and testing of a sophisticated BMS can pose challenges, however, as was discovered by one of the largest producers of electronic products in the world. That’s why they recently relied upon Maplesoft and ControlWorks Inc., a real-time testing systems integrator with deep experience developing BMS test stands, to develop a Hardware-in-the-Loop (HIL) test system for the BMS in one of their large Energy Storage System (ESS) products.
An attractive solution to these testing challenges is to use virtual batteries – mathematical models of battery cells that are capable of displaying the same dynamic behavior as real ones – for early-stage testing of the BMS. Not only have these models proven to be highly accurate, they are computationally efficient and are able to achieve the execution required to deliver real-time performance for batteries containing hundreds of cells on real-time platforms.
The battery modeling technique employed by Maplesoft uses a partial differential equation (PDE) discretization technique to streamline the model to a set of ordinary differential equations (ODE) that can be readily solved by system-level tools like MapleSim. The advanced model optimization features of MapleSim also allow the resulting code to be very fast and capable of running in real-time.
The resulting battery models can also be employed in the prediction of charge/discharge rates, state of charge (SoC), heat generation and state of health (SoH) through a wide range of loading cycles within complex, multi-domain system models. This approach provides the performance needed for system-level studies with minimal loss in model fidelity. The user can also allow for energy loss through heat, making these models useful for performing thermal studies to determine component sizes in cooling systems to manage battery temperature. Not carefully controlling the temperature can lead to reduced operational life or, in extreme cases, destruction or even explosion due to thermal runaway, a common problem in many battery-powered systems.
Model Structure for this Application
For the purpose of this ESS test system development project, the key requirements for the battery model were:
-Up to 144 Li-Ion polymer cells for testing the BMS of the client’s ESS products
-Ease of configuration for different requirements (parallel/series networks)
-Several sensors per cell (current, voltage, SoC, SoH)
-Variation of chemistry make-up due to manufacturing tolerances
-Fault-insertion on each cell (open-circuit, shorting)
-Capacity to run in real-time (target execution-time budget of 1 ms)
-In the case of energy storage systems, like this example, each ESS battery is made of several “stacks” that, in turn, contain several cells. The MapleSim model follows this structure with each cell being a shared, fully parameterized subsystem. Each cell can also be switched to open circuit using logical parameters.

Figure 2: Cell stack model
The stack model is made of 18 cell subsystems connected either in parallel or series, depending on the requirement. Input signals are provided for charge balancing from the BMS. Output signals are provided back to the BMS to monitor the condition of the stack (supply voltage, SoC and SoH). Finally, the full ESS is made of several stacks with IO signals fed to and from the BMS.

Figure 3: ESS Battery model
Model Calibration and Validation
Much of the accuracy of this model is dependent on experimentally derived parameters, determined from charge/discharge test results. Project engineers determined that any deviation in performance due to manufacturing variations needed to be included in order to test the charge-balancing capability of the BMS. Instead of testing every cell, engineers relied on random variants generated from the statistical distribution determined by the charge/discharge test results on 48 cells. This was applied to all 144 cells and then compared with the real test results. The maximum variance of the voltage from the experimental data was 14mV, while from the simulation it was 13mV, acceptable for the purpose of this project.
Maplesoft and ControlWorks Inc. engineers also determined the average cell response using the parameter-estimation tool supplied with the MapleSim Battery Library. This uses optimization techniques to determine the values of cell-response parameters that provide the closest “fit” to the experimental results. This response was then validated against response data from other cells to ensure close estimation of the resulting model.
SoH behavior was implemented as a look-up table based on experimental results. The model determines the capacity and internal resistance based on the number of charge/discharge cycles and depth of discharge (DOD) from the lookup.

Figure 4: SoH simulation showing effect on battery voltage
Finally, the model was converted to ANSI-C through the MapleSim Connector, producing an S-Function of the battery model that can be tested for performance and accuracy with a fixed-step solver on a desktop computer in MATLAB/Simulink® before moving it to a real-time platform. The simplest solver was used and the performance bench showed that the average execution time was approximately 20 times faster than real-time, occupying 5.5% of the real-time system time budget. This shows that the battery model can be easily scaled up, if required.
The end result was a battery model capable of being configured to represent a stack of up to 144 cells that can be connected in any combination of parallel and series networks. Fault modes were also built-in, such as individual cells shorting or opening, as well as incorporating variations in charge capacity from cell to cell, and degradation of capacity over the life of the cells.
The final BMS test station provides the client’s engineers with the ability to configure the battery model (number of cells, series/parallel, etc.) and apply a range of tests to it. The engineer can go back to the MapleSim™ model at any time to make any necessary changes to the model configuration, and then generate the model for use on the real-time platform. In this system, the real-time software is National Instruments’ VeriStand™, driving a PXI real-time system. The MapleSim Connector for NI VeriStand™ automates the model integration process, allowing the engineer to produce the real-time model quickly and reliably.
The ControlWorks Inc. system also integrates real-time platform, signal processing, fault-insertion tools and standard communications protocols (CANbus for automotive, Modbus for industrial applications), allowing the engineer to run the BMS through a range of tests on the battery model, including Constant Current (CC) and Constant Voltage (CC/CV) charge/discharge cycles, as well as Constant Power (CP) and Constant Resistance (CR) discharge cycles.
“We were pleased to be able to partner with Maplesoft on this project,” said Kenny Lee, PhD, Director of Research Center of Automotive Electronics, ControlWorks Inc. “The use of battery models in this case proved to be an effective alternative to the use of real batteries,” he added.
Summary
Test automation and simulation is critical in system-level testing, allowing time and cost of failure analysis, constant development pressure, expense of repeated tests, and lengthy set-up times all to be addressed.
“The use of high-fidelity, ready-made battery models allows the engineer to avoid the risks of damage to batteries, along with subsequent costs, while testing and optimizing the BMS design in a close-to-reality loading environment,” said Paul Goossens, Maplesoft VP of Engineering Solutions.
The use of virtual battery technology in the design of test systems can facilitate the development of better products, reduce project risks, and get products to market faster.
“The MapleSim model of the Li-Ion battery was selected because of its proven ability to achieve real-time performance. The code-generation and compilation tools are very easy to use, making the integration of the model into the HIL system very fast and cost-effective. That, plus the excellent development support we received from Maplesoft’s Engineering Solutions team made this a very smooth project.” Kenny Lee, PhD, Director of Research Center of Automotive Electronics, ControlWorks Inc.