1. Introduction and Research Context
The rapid growth in production and sales of electric vehicles represents a fundamental transformation of the automotive industry. In 2023, new energy vehicle production and sales in China surpassed 9 million units, with a market penetration exceeding 30%. Under the national strategic goals of peak carbon emissions and carbon neutrality, electric vehicles have become a crucial pathway toward energy security and environmental sustainability. My research focuses on the central component that governs the performance and safety of the EV battery pack: the Battery Management System, abbreviated as BMS.
The EV battery pack comprises numerous individual cells connected in series and parallel configurations. The BMS performs essential functions including state monitoring, charge control, cell balancing, thermal management, and fault diagnosis. The safety and reliability of the EV battery pack directly determine the performance, range, and lifetime of electric vehicles. Consequently, the testing and verification of BMS functionality represent critical steps in the development and production phases.

Through extensive investigation of the current state of BMS technology, I identified that contemporary battery management systems have evolved through three distinct phases: the unmanaged phase, the simple management phase, and the comprehensive management phase. In the first phase, periodic manual inspections of battery inconsistencies formed the basis of battery management. The simple management phase introduced automated monitoring of external parameters such as voltage, current, and temperature. The comprehensive management phase, which characterizes modern systems, integrates sophisticated algorithms for state estimation, active balancing strategies, thermal management, and safety protection.
Conventional BMS testing relies heavily on physical battery systems, which present multiple challenges. Physical battery experiments require extensive test times and offer limited flexibility in adjusting experimental conditions. Repeatability is difficult to ensure, and the associated costs of laboratory equipment and personnel are substantial. Furthermore, certain battery states remain inaccessible through direct measurement, and testing under boundary conditions raises significant safety concerns. These limitations motivated my investigation into hardware-in-the-loop testing methodologies that can evaluate BMS performance in real-time without exposing physical test setups to excessive risk.
Hardware-in-the-loop testing, abbreviated as HIL, provides an innovative solution to these challenges. HIL testing integrates real electronic control units with real-time simulation models of the controlled objects. This methodology enables comprehensive evaluation of BMS functionality under diverse operating conditions while maintaining flexibility, repeatability, and safety. I selected the Speedgoat real-time simulator as the core platform for the HIL testing infrastructure because of its seamless integration with MATLAB/Simulink and its capacity for running complex battery models in real-time. The development of the BMS HIL testing platform described in this thesis addresses key challenges in BMS development and verification, effectively reducing the frequency of real-vehicle road testing and substantially lowering engineering costs.
2. BMS Architecture and Functional Analysis
2.1 Topological Configurations of BMS Systems
BMS systems assume various topological configurations depending on their application requirements. The four primary architectures that I analyzed in this research are centralized, modular, master-slave, and distributed systems. Each presents distinct advantages and limitations.
Centralized BMS architectures integrate all electrical components onto a single control board. These systems feature compact structure, simplified circuit design, lower cost, and convenient maintenance. However, the long sensing wires to individual cells complicate harness design and introduce voltage drops. The number of sensing channels is limited, and system extensibility suffers. Centralized BMS architectures are suitable mainly for smaller battery systems such as low-voltage packs used in hybrid electric vehicles.
Modular BMS architectures share similarities with centralized systems but employ multiple identical sub-modules, one of which serves as a master module for external communication. Each sub-module contains its own controller and measures battery parameters locally. Modular systems reduce wire harness complexity and improve reliability through distributed processing, but hardware costs increase because not all module processing capabilities are fully utilized.
The master-slave BMS architecture pairs one master module with multiple identical sub-modules. The master module handles communication and computation exclusively, while sub-modules perform only data acquisition functions. This functional division reduces costs relative to fully modular systems while retaining many of their benefits. My research selected a master-slave BMS with open software and hardware resources as the test subject because it balances functional complexity with accessibility for development and testing.
Distributed BMS systems place monitoring units directly on individual battery cells. This approach minimizes wire harness requirements and provides physical separation between sensing and control functions. However, distributed configurations have complex structures and reduced electromagnetic interference immunity, which complicates installation and maintenance.
| Architecture Type | Main Advantages | Primary Limitations |
|---|---|---|
| Centralized | Compact design, low cost, simplified wiring on PCB | Long sensing wires, limited channel count, difficult expansion |
| Modular | Flexible expansion, distributed processing, shorter wire runs | Higher cost, potential processing resource waste |
| Master-Slave | Optimized cost with distributed acquisition, clear functional partition | Restricted to acquisition in slave modules |
| Distributed | Minimal interconnecting wires, localized sensing | Complex circuitry, lower noise immunity, harder installation |
2.2 Hardware Resources of the Test BMS
The BMS under test uses a master module and slave modules connected via internal Controller Area Network (CAN) bus. The master control unit contains a microcontroller supported by operational amplifiers, reference voltage sources, isolators, and analog-to-digital converter chips. Its external interfaces include two CAN communication channels for internal and external communication, a 12V ignition signal detection port, current and voltage sensing inputs, and driver outputs for cooling fans, heaters, smoke sensors, contactor power, and grounding circuits.
The slave control module provides connections for individual cell voltage sensing, power and ground ports, one CAN interface for communication with the master module, and additional pins for signal filtering and microcontroller input/output protection. The slave module uses the LTC6811 integrated circuit from Analog Devices for cell parameter acquisition. I determined that this chip offers high-precision analog-to-digital conversion with a sampling range of 0 to 5 volts, with additional temperature sensor inputs.
2.3 Functional Decomposition of the BMS
I decomposed the BMS functionality into several interconnected domains. The data acquisition function measures terminal voltages of individual cells, overall pack voltage, pack current, and cell temperatures. These raw measurements feed into higher-level algorithms and optimization functions. In the physical BMS hardware, the LTC6811 chip collects cell voltages and temperatures, then transmits these values over a Serial Peripheral Interface bus to an MC9S12XS128 microcontroller. The microcontroller subsequently sends the acquired data through the CAN bus to the master control module.
State of charge estimation is a central function in battery management. The state of charge, or SOC, denotes the remaining capacity of the battery pack expressed as a fraction of its rated capacity. SOC cannot be measured directly and must be estimated from easily obtainable parameters such as terminal voltage, current, and temperature. State of health estimation, similarly, quantifies battery degradation by comparing actual capacity to rated capacity.
Condition monitoring covers charge and discharge processes as well as temperature profiles. BMS charging control algorithms optimize charging voltage, current, and power according to battery characteristics and the capabilities of the connected charger. During discharge, the BMS monitors voltage stability to protect cells against over-discharge and monitors temperature to activate cooling or heating systems when required. I examined the temperature control module in the test BMS, which uses a BTS5020 driver chip to control cooling fans and battery heaters through specific output pins.
2.4 Balancing Management
Cell manufacturing tolerances, thermal gradients, and differential aging cause inconsistencies among cells within a battery pack. These inconsistencies, if unmanaged, lead to premature aging of the weakest cells and reduce the usable capacity of the entire EV battery pack. Balancing equalization is therefore essential. Balanced strategies are classified into two broad categories: active equalization and passive equalization.
Active equalization transfers charge from higher-voltage cells to lower-voltage cells using energy storage elements such as inductors or capacitors. This approach achieves higher energy efficiency and improved charging speed but requires complex circuits and sophisticated control algorithms. Passive equalization dissipates excess energy through resistors connected across the highest-voltage cells. This method offers lower cost and circuit simplicity, but is less efficient since the excess energy is wasted as heat.
For small-capacity, low-cell-count EV battery packs, passive balancing is a suitable choice due to its inherent simplicity. In this thesis, however, the target BMS employs an active equalization approach using a Buck-Boost bidirectional topology with a power inductor, which I will discuss in detail in a later section.
2.5 Safety Protection and Fault Diagnosis
BMS safety protection and fault diagnosis involve detecting abnormal conditions such as overvoltage, undervoltage, overcurrent, overtemperature, insulation degradation, and internal communication faults. These conditions are classified into approximate severity levels: slight faults, major faults, and critical faults. The BMS executes corresponding protective actions that range from warning notifications to power derating or immediately disconnecting high voltage. When confirming that data communication to the vehicle controller is functioning normally, the BMS transmits a status message. If a fault occurs, a diagnostic trouble code is stored for retrieval during maintenance procedures.
| Fault Type | Detection Metric | Severity Level | Protective Action |
|---|---|---|---|
| Overvoltage | Cell voltage exceeds threshold | Major | Reduce charge current |
| Undervoltage | Cell voltage below threshold | Major | Limit discharge power |
| Overtemperature | Cell temperature high | Critical | Functional cutoff |
| Overcurrent | Charge/discharge current excessive | Critical | Reduce torque / disconnect |
| Short circuit | Sudden current spike | Critical | Immediate high voltage cutoff |
| Isolation fault | Insulation resistance too low | Major | Warning and power limiting |
| Communication error | CAN message timeout | Major | Safe state entry |
2.6 Communication Management
BMS connectivity is organized into internal and external communication channels. The internal CAN connects the master control unit to slave modules, while an external CAN interface provides communication with other vehicle controllers such as the vehicle control unit (VCU). A separate diagnostic CAN bus serves the instrument cluster and diagnostic tools. The test BMS integrates these communication interfaces using the industry-standard CAN protocol, and the communication architecture was designed carefully to provide deterministic timing and adequate bandwidth for high-frequency battery data streams.
3. Hardware Design of the BMS HIL Testing Platform
3.1 Comparison of Mainstream HIL Platforms
Multiple commercial HIL platforms are available, each with distinctive technical characteristics and constraints. A thorough comparative analysis guided the selection of the appropriate real-time simulation platform for this project. National Instruments developed the NI-PXI platform, which offers comprehensive solutions and a broad product portfolio. NI-PXI provides an intuitive graphical environment through LabVIEW. However, development depth in specialized HIL domains may be limited, and for complex high-fidelity automotive simulation, additional expertise is often required.
dSPACE offers the SCALEXIO platform, which is known for excellent real-time performance and reliability. The system adheres closely to industry standards and is widely adopted in automotive electronic control unit testing. However, hardware and software arrangements are expensive, and end users face significant challenges in performing secondary development or customization.
Speedgoat’s real-time target machines provide a compelling alternative through seamless compatibility with MATLAB/Simulink. The system operates straightforwardly, offers excellent reliability, and provides flexible expansion options. Speedgoat works in close partnership with MathWorks, which ensures ongoing synchronization between the latest MATLAB features and Speedgoat’s hardware and software capabilities. The primary drawback is the higher cost relative to similar systems, but this is offset by operational simplicity, particularly for organizations already using MATLAB/Simulink for model-based design. RTDS Technologies provides the NovaCor platform, which offers broad adaptability without requiring third-party software. However, NovaCor is targeted primarily at power system simulation and is less suited as a generic automotive BMS HIL platform.
| Platform | Advantages | Disadvantages |
|---|---|---|
| NI-PXI | Rich solution set, intuitive LabVIEW environment | Less specialized depth in HIL industrial applications |
| SCALEXIO | High reliability, strong real-time execution | High cost, harder to perform custom modifications |
| Speedgoat | Perfect MATLAB/Simulink integration, practical and reliable | Relatively higher price |
| NovaCor | Adaptability without third-party modules | Mainly for power grid/energy applications |
My analysis concluded that Speedgoat offers significant advantages for this research. The developer uses a Simulink-based workflow in which all modeling and configuration tasks take place in the MATLAB environment. This setup lowers the barrier to entry, eliminates the need for deep expertise in low-level hardware details, and allows me to focus on validating the logic and mathematical correctness of the battery and vehicle models. I selected the Speedgoat real-time target machine as the core device for my BMS HIL testing platform.
3.2 Operating Principle of the BMS HIL Testing Platform
The HIL testing approach establishes a closed-loop feedback system that incorporates both real hardware components and simulated plant models. In this platform, the controlled object, namely the EV battery pack and portions of the vehicle system, is represented using real-time mathematical models executing on the Speedgoat target machine. The actual BMS hardware under test is connected through precision I/O interfaces and communication channels to interact with these simulated models in real time.
The basic operating principle of the platform is as follows. In the Simulink environment, I built comprehensive simulation models of the controlled objects. These models include the battery equivalent circuit, the vehicle dynamic model, and the corresponding I/O board drivers, together with communication modules. The real-time executable code generated from these models is then deployed to the Speedgoat target machine, where the central processing unit executes the code at a deterministic rate. The real-time internal state variables of the models are output through dedicated I/O boards and communication interfaces. The BMS acquires these signals through its wired connections and performs its control functions. Simultaneously, the BMS sends control commands back to the Speedgoat target machine, enabling it to update the simulated plant state in response to the applied control actions. This creates a complete hardware-in-the-loop system.
Operation monitoring and parameter adjustment are accomplished using Simulink Real-Time Explorer software running on the host personal computer. This software maintains real-time graphical and numerical views of selected model signals, allowing immediate adjustments to model parameters and observation of both command and response trajectories.
3.3 Hardware Components of the Testing Platform
3.3.1 Host Computer
The host computer provides the Windows-based operating environment for the MATLAB software suite. My configuration uses a Windows 10 operating system, 16 gigabytes of RAM, and a central processing unit with a clock speed of 2.6 gigahertz. The host runs MATLAB Release 2022a together with the required add-on toolboxes. Its primary functions in the HIL platform include model construction, compilation, parameter adjustment, and data monitoring and storage.
3.3.2 Real-Time Target Machine
The Speedgoat Baseline real-time target machine, model S, is the central execution unit of the test platform. The main performance specifications include an Intel Celeron central processing unit running at 2 gigahertz with four cores, 4 gigabytes of double data rate third-generation random access memory, and a 32 gigabyte solid-state drive for storage. The real-time operating system is Simulink Real-Time. The target machine provides one Ethernet interface for communication with the host computer and two additional Gigabit Ethernet ports supporting real-time user datagram protocol, EtherCAT master functionality, XCP master functionality, and TCP/IP connectivity. Power is supplied in the range from 9 to 36 volts DC.
| Component | Specification |
|---|---|
| CPU | Intel Celeron, 2 GHz, 4 cores |
| Real-time OS | Simulink Real-Time |
| Memory | 4 GB DDR3 RAM |
| Storage | 32 GB SSD |
| USB ports | 1 x USB 3.0, 2 x USB 2.0 |
| Serial ports | 2 x RS232, up to 120 kb/s |
| Display | 1 x DisplayPort, 1280×1024 max |
| Gigabit Ethernet | 2 ports, supports UDP, EtherCAT, XCP, TCP/IP |
| Supply range | 9–36 V DC |
The I/O configuration includes three distinct board types. The I/O191 analog board delivers 8 single-ended analog input channels configurable as 4 differential inputs. These channels provide 16-bit resolution over voltage ranges from ±0.64 V to ±20.48 V, with a maximum sampling rate of 125 kilosamples per second. The board also supplies 4 analog output channels with 16-bit resolution and configurable voltage ranges of ±10 V, ±5 V, ±2.5 V, and 0 to 10 V. Additionally, it offers 16 general-purpose digital TTL I/O lines. The I/O397 configurable FPGA board provides additional flexibility with 4 analog input channels spanning ±10 V and 4 analog output channels with 16-bit resolution. The 14 digital I/O channels on this board support the definition of customized functionality such as PWM generation, SPI communication, I2C communication, and encoder signal decoding. The I/O691 CAN board provides 2 controller area network channels with high-speed connectivity. This suite of boards was selected to meet the varied requirements for the BMS testing infrastructure.
3.4 Hardware Platform Integration
The complete BMS HIL testing platform hardware architecture follows a structured topology. The Speedgoat target machine uses Ethernet connections to communicate with the host computer. The two CAN channels of the I/O board link the target machine to the BMS under test. One CAN channel facilitates bidirectional communication with the BMS master module, while the second is available for diagnostic or auxiliary communication purposes. Furthermore, the programmable power supply controlled through the Speedgoat board simulates cell voltage and battery pack state changes, providing a reference baseline for fault injection and load simulation.
The BMS test sample includes the master control module and slave control module connected via the internal CAN bus. This setup allows the HIL platform to simulate the complete battery pack dynamics and provide realistic information to all BMS control units. After carefully designing the interconnect architecture, I physically connected all hardware components, verified electrical continuity, and validated communication links between the host computer, target machine, and BMS.
4. Software Design of the BMS HIL Testing Platform
4.1 Software Architecture
The software system for the BMS HIL testing platform comprises the controlled object models, the I/O interface and driver modules, the signal interaction components, and the host computer user interface. The controlled object models simulate the dynamic behavior of the EV battery pack and the vehicle system. The I/O interface components translate signals between the simulated environment and the physical electrical interfaces of the BMS. The communication and signal interaction layer implements data exchange between the operational layers, and the host interface at the top provides intuitive monitoring and manual override capabilities.
I constructed the software components in the MATLAB/Simulink environment while using Speedgoat’s I/O driver libraries. These libraries contain driver blocks that match the specific I/O boards installed in the target machine. Simulink Real-Time Explorer, part of the Simulink Real-Time toolbox, provides the visualization environment for development and operation. During project execution, the model under test is compiled and downloaded to the Speedgoat target machine and then monitored in real time to observe outputs, tune parameters interactively, and record signals for offline analysis.
4.2 Modeling the Battery System: PNGV Equivalent Circuit
Battery modeling represents a critical step in the development of an effective HIL platform. The model must capture the essential voltage and state behavior of the EV battery pack within acceptable accuracy while remaining computationally tractable for real-time execution. Equivalent circuit modeling approaches are widely used for such purposes because they are compact, straightforward to parameterize, and computationally efficient. These models approximate battery dynamics by combining ideal voltage sources, resistances, and capacitances in circuit configurations that mirror the observed electrical behavior.
I compared several candidate topologies for the equivalent circuit model. The simple internal resistance model connects a nonlinear voltage source in series with a resistance. As shown in Eq. (4.1), the model is easy to parameterize but cannot accurately simulate the transient response and the polarization effects of the battery.
$$U_{t} = U_{OC} – R_{0} \, I_{L} \tag{4.1}$$
The first-order Thevenin model adds an RC network consisting of a polarization resistance \(R_{p}\) and polarization capacitance \(C_{p}\) in parallel. The polarization voltage \(U_{p}\) evolves according to
$$\dot{U}_{p} = -\frac{U_{p}}{R_{p} \, C_{p}} + \frac{I_{L}}{C_{p}} \tag{4.2}$$
$$U_{t} = U_{OC} – R_{0} \, I_{L} – U_{p} \tag{4.3}$$
The double-polarization model introduces a second RC network to improve the dynamic response fidelity. The PNGV model, which I ultimately selected for this application, expands on these concepts by introducing a capacitance \(C_{b}\) in series with the ideal voltage source to represent the effects of accumulated charge throughput on the open-circuit voltage. Figure 4.6 in the original work depicts the circuit structure with the voltage source \(U_{OC}\), series resistance \(R_{0}\), parallel polarization impedance \(R_{p}C_{p}\), and the capacitor \(C_{b}\). The PNGV model was proposed in the PNGV Battery Test Manual published by the United States Council for Automotive Research and subsequently documented in the FreedomCAR Battery Test Manual. I chose the PNGV model because it delivers a good trade-off between accuracy and implementation simplicity while aligning well with standard parameter identification procedures from the published literature. The governing equations for the PNGV model are:
$$\dot{U}_{p} = -\frac{U_{p}}{R_{p} \, C_{p}} + \frac{I_{L}}{C_{p}} \tag{4.4}$$
$$\dot{U}_{b} = \frac{I_{L}}{C_{b}} \tag{4.5}$$
$$U_{t} = U_{OC} – R_{0} \, I_{L} – U_{p} – U_{b} \tag{4.6}$$
4.3 Parameter Identification Using HPPC Testing
Accurate values for model parameters are essential for meaningful simulation outcomes. The internal parameters of lithium-ion batteries vary with state of charge, temperature, cycle number, and current direction.
The Hybrid Pulse Power Characterization (HPPC) test provides a standardized method for obtaining these parameter values at various SOC operating points. I performed HPPC tests on a lithium iron phosphate battery cell at a controlled temperature of 25 degrees Celsius. The test sequence begins by fully charging the cell and allowing for a one-hour rest period. The cell then undergoes repeated discharge-rest-pulse cycles at 10 percent depth-of-discharge increments until reaching 10 percent SOC. Each HPPC profile consists of 60 seconds: a 10 second discharge pulse at a 1 C rate, 40 seconds of rest, and then a 10 second charge pulse at 0.75 C, followed by a one-hour rest period. The rest period is critical for allowing the cell to achieve electrochemical and thermal equilibrium before the next measurement.
I derived model parameters from the HPPC current-voltage responses mathematically. The open-circuit voltage \(U_{OC}\) is measured directly during the rest period. The ohmic resistance \(R_{0}\) is calculated from the instantaneous voltage drop at the onset of the discharge pulse:
$$R_{0} = \frac{\Delta U}{I} = \frac{U_{1} – U_{2}}{I} \tag{4.7}$$
where \(U_{1}\) is the voltage before the pulse, \(U_{2}\) is the voltage at the end of the pulse, and \(I\) is the discharge current. The polarization resistance \(R_{p}\) is derived from the voltage relaxation between the end of discharge and the end of rest:
$$R_{p} = \frac{U_{5} – U_{4}}{I} \tag{4.8}$$
The capacitance values \(C_{b}\) and \(C_{p}\) are determined from energy balance and voltage transient analysis as follows:
$$C_{b} = \frac{\Delta Q}{\Delta U_{cap}} = \frac{\int I \, dt}{U_{1} – U_{5}} \tag{4.9}$$
$$C_{p} = \frac{(t_{3} – t_{2})}{R_{p}} \times \frac{1}{\ln\left(\frac{U_{5} – U_{4}}{U_{1} – U_{4}}\right)} \tag{4.10}$$
Through this systematic procedure, I identified model parameters at each tested SOC point. The following table presents the extracted parameters at 25 degrees Celsius:
| SOC | R₀ (mΩ) | Rₚ (mΩ) | Cₚ (F) | τ (s) | C_b (F) | U_OC (V) |
|---|---|---|---|---|---|---|
| 0.9 | 1.1283 | 0.6117 | 47652.03 | 23.89 | 78922.08 | 3.2333 |
| 0.8 | 1.1433 | 0.6583 | 42784.51 | 23.45 | 73074.07 | 3.2317 |
| 0.7 | 1.1600 | 0.7000 | 41106.35 | 24.26 | 63516.13 | 3.2314 |
| 0.6 | 1.1800 | 0.7517 | 40428.78 | 25.00 | 51173.91 | 3.2268 |
| 0.5 | 1.1917 | 0.7617 | 34225.63 | 24.31 | 67965.52 | 3.1964 |
| 0.4 | 1.2067 | 0.8183 | 30212.09 | 23.42 | 67965.52 | 3.1917 |
| 0.3 | 1.2317 | 0.9050 | 26652.03 | 23.26 | 61500.00 | 3.1905 |
| 0.2 | 1.2167 | 1.0300 | 23936.22 | 23.19 | 48586.78 | 3.1824 |
| 0.1 | 1.2367 | 1.2117 | 20054.81 | 22.29 | 40095.89 | 3.1477 |
To validate the battery model, I used a DST (Dynamic Stress Test) driving cycle. This test profile represents a dynamic current sequence over a 360-second period that simulates the varying power demands of an electric vehicle in urban traffic. The validation process subject both the physical battery and the simulation model to the same DST current sequence and compare the output voltages. The measured voltage and simulated voltage show good agreement throughout the entire test sequence, with the average voltage error remaining below 0.05 V. This result confirmed that the battery model meets the accuracy requirements for the intended HIL testing applications.
4.4 SOC Estimation with Extended Kalman Filtering
Battery SOC estimation methods are broadly classified into ampere-hour counting, open-circuit voltage lookup, and model-based state estimation methods such as Kalman filtering. Ampere-hour counting integrates the measured current over time and is simple to implement and computationally inexpensive. However, this method suffers from cumulative error due to current sensor bias and initial SOC uncertainty, making it less accurate over time.
Open-circuit voltage at equilibrium shows an approximately monotonic relationship to SOC for the tested cell chemistry. Yet this approach has significant drawbacks because the battery must rest for long durations before the open-circuit voltage can be measured accurately. Furthermore, the open-circuit voltage versus SOC relationship varies with temperature, aging, and other factors. These limitations point toward model-based estimation methods, and I selected the extended Kalman filter algorithm for state estimation in my BMS HIL test platform.
The Kalman filter is an optimal state estimator for linear systems that computes the state estimate as a weighted combination of the predicted state and a measurement correction term. The EKF algorithm extends this methodology to non-linear systems by linearizing the non-linear functions around the current state estimate at each time step. Given a nonlinear discrete-time system of the form:
$$x_{k} = A_{k-1} \, x_{k-1} + B_{k-1} \, u_{k-1} + w_{k-1} \tag{4.11}$$
$$z_{k} = C_{k} \, x_{k} + D_{k} \, u_{k} + v_{k} \tag{4.12}$$
where \(x_{k}\) represents the state vector, \(u_{k}\) represents the input vector, \(z_{k}\) represents the measurement, and \(w_{k}\) and \(v_{k}\) denote process and measurement noise, respectively. For the battery SOC estimation problem, I selected the state vector containing the two polarization voltages and the SOC:
$$x = \begin{bmatrix} U_{1} \\ U_{2} \\ SOC \end{bmatrix} \tag{4.13}$$
The discrete-time state transition matrices derived from the PNGV model are:
$$A = \begin{bmatrix} 1 – \frac{T_{s}}{R_{1}C_{1}} & 0 & 0 \\ 0 & 1 – \frac{T_{s}}{R_{2}C_{2}} & 0 \\ 0 & 0 & 1 \end{bmatrix}, \quad B = \begin{bmatrix} \frac{T_{s}}{C_{1}} \\ \frac{T_{s}}{C_{2}} \\ -\frac{T_{s}}{Q_{n}} \end{bmatrix} \tag{4.14}$$
$$C = \begin{bmatrix} -1 & -1 & 0 \end{bmatrix}, \quad D = -R_{0} \tag{4.15}$$
In these equations, \(T_{s}\) denotes the sampling time and \(Q_{n}\) denotes the nominal battery capacity. The EKF recursion consists of two steps. The prediction step projects the state estimate and error covariance forward in time:
$$\hat{x}_{k}^{-} = A_{k-1} \, \hat{x}_{k-1}^{+} + B_{k-1} \, u_{k-1} \tag{4.16}$$
$$P_{k}^{-} = A_{k-1} \, P_{k-1}^{+} \, A_{k-1}^{T} + Q_{k-1} \tag{4.17}$$
where \(Q_{k-1}\) is the process noise covariance matrix. The correction step then uses the new measurement \(z_{k}\) to refine the state estimate:
$$K_{k} = P_{k}^{-} \, C_{k}^{T} \, \left(C_{k} \, P_{k}^{-} \, C_{k}^{T} + R_{k}\right)^{-1} \tag{4.18}$$
$$\hat{x}_{k}^{+} = \hat{x}_{k}^{-} + K_{k} \, \left(z_{k} – C_{k} \, \hat{x}_{k}^{-}\right) \tag{4.19}$$
$$P_{k}^{+} = P_{k}^{-} – K_{k} \, C_{k} \, P_{k}^{-} \tag{4.20}$$
The Kalman gain \(K_{k}\) weights the residual between the actual measurement and the model prediction. This systematic update loop corrects for model errors and measurement noise, which mitigates the accumulation problem inherent in pure ampere-hour counting. I implemented the EKF algorithm in a MATLAB/Simulink block to generate real-time SOC estimates during HIL testing. The battery model outputs the terminal voltage, which is compared with the measured voltage to compute the EKF correction.
4.5 Modeling of Cell Balancing Circuitry
The BMS control strategy activates balancing when voltage differences among cells exceed defined thresholds. To test this function on the HIL platform, I developed a simulation model of the proposed active balancing circuit. The topology uses a buck-boost converter structure with power inductors to implement bidirectional energy transfer between adjacent cells.
The balancing circuit connects two cells with an inductor in a configuration where each cell has its own transistor and diode. The control algorithm decides which cell transfers charge based on the measured cell voltages. If the upper cell has a higher charge, its control switch turns on with a specific duty cycle, allowing current through the inductor to increase. The switch then turns off, and the inductor current freewheels into the lower cell, thereby charging it. This charge transfer continues until the cell voltages reach an acceptable balance threshold.
In the first phase, the state equation is:
$$V_{1} = L \, \frac{di_{L}}{dt} + R_{on} \, i_{L}, \quad 0 \le t \le t_{on} \tag{4.21}$$
The maximum inductor current at the end of the on-period is:
$$i_{L,max} = \frac{V_{1}}{R_{on}} \left(1 – e^{-\frac{R_{on} \, t_{on}}{L}}\right) \tag{4.22}$$
During the second phase, the inductor connects through the second cell’s diode, and the current decays while charging the receiving cell:
$$i_{L}(t) = -\frac{V_{2} + V_{D}}{R_{off}} + \left(i_{L,max} + \frac{V_{2} + V_{D}}{R_{off}}\right) e^{-\frac{R_{off} (t – t_{on})}{L}} \tag{4.23}$$
where \(V_{2}\) is the lower cell voltage and \(V_{D}\) is the diode forward voltage drop. The process repeats cyclically at a switching frequency of 10 kHz with a duty cycle of 50 percent.
I constructed a Simulink model of this balancing circuit using two series-connected lithium-ion cells, each with a nominal voltage of 3.6 V. This simulation model runs alongside the battery model to enable verification of the balancing strategy in the closed-loop HIL environment. The model outputs relevant information about cell voltage trajectories and equalization currents, enabling verification of the BMS balancing functions.
4.6 Integration of the Vehicle Model
Embedding the battery system in a vehicle model improves the fidelity of the overall simulation environment and enables functional testing of the BMS in a broader context. A complete electric vehicle simulation model consists of the driver model, the electric motor model, the vehicle dynamics and the battery pack. The driver model uses a PID controller to compute accelerator or brake pedal requests from the error between the desired and the current vehicle speed.
The electric motor model describes the dynamic behavior of a permanent magnet synchronous motor based on its mathematical model. The electrical vehicle is represented in terms of longitudinal dynamics incorporating resistance forces and the tractive effort generated at the wheels. Motor and vehicle dynamics interact with the battery through power exchange, thus creating an energy feedback loop in the vehicle model. The resulting overall vehicle simulation model provides the HIL platform with realistic operating conditions for the BMS.
4.7 Software Configuration and Real-Time Execution
Several considerations were required to build a stable and deterministic real-time system on the Speedgoat target machine. The MATLAB software suite initially had to be installed together with the Real-Time Simulink Support Packages for deployment of the application model. The Speedgoat I/O driver library was installed on the host computer to interface Simulink models with the target machine’s I/O boards.
Communication between the host computer and the target machine uses the TCP/IP protocol over an Ethernet connection. The host is configured to a static IP address in the same network range as the Speedgoat target’s default gateway of 192.168.7.x. Windows network settings must be aligned properly, and the MATLAB level target configuration must match the network settings to establish a robust communication link.
Once connected, the model is compiled into a C++ code via Simulink Coder. This code is subsequently compiled into an executable file with the extension that the target machine can process. The final step deploys this file to the target and initiates real-time execution. While the model is running, the engineer can use the Simulink Real-Time Explorer interface to modify parameters, observe signals graphically, and log data for further analysis.
4.8 Interface Development
The developed user interface is the central point for monitoring and managing the test process. I built it using the Simulink Real-Time Explorer environment. The interface displays key information such as the instantaneous values of temperature, the cell voltages, the pack voltage, the pack current, and the SOC. It allows the operator to configure input parameters, such as the initial SOC, temperature, and fault logic, and to trigger specific test procedures. The interface also contains a graphical status panel with battery cells, an indicator lamp that shows the operating condition, and waveform displays for detailed analysis. Switching between different driving cycles, such as HPPC, DST, and NEDC, is also available from the computer interface. The developed HIL interface greatly improves the user-friendliness and visibility of the overall testing process, thereby increasing test efficiency and reliability.
5. Functional Testing and Results Analysis
The completed BMS HIL testing platform needs to meet the technical requirements for BMS testing described in the national standard GB/T 38661-2020. I designed and executed tests on data acquisition, SOC estimation, cell balancing, and fault diagnosis. In this chapter, I present the methodology for and the results of these tests, along with a short comparison to the criteria in the standard.
5.1 Data Acquisition Functional Test
The data acquisition test focused primarily on the voltage measurement accuracy of the BMS. Cell voltage accuracy is critical for algorithms estimating the SOC, operating the balancing converter, and making control decisions. According to standard GB/T 38661-2020, the measurement accuracy of a lithium-ion cell’s terminal voltage should be within a relative error of ±0.5% and an absolute error of less than 10 mV.
To evaluate the BMS voltage measurement module, I set specific voltage values of the cell models in the HIL software interface. The values were chosen to represent a relevant range of cell operating points. The Speedgoat analog output board generated the corresponding analog voltages that were read by the BMS. The BMS then processed the sampled voltages and transmitted the data through the CAN bus back to the HIL interface for display and comparison.
The comparison between the programmed analog output value (used as a reference) and the value reported by the BMS voltage acquisition circuit shows that the maximum measured voltage error stays below 10 mV. This is within the permissible tolerance over the tested range. The relative deviation also remains within ±0.5% of the full-scale voltage, which fulfills the required accuracy threshold and demonstrates that the BMS under test achieves suitable data acquisition precision.
5.2 SOC Estimation Performance Evaluation
The SOC estimates generated by the BMS were examined under three representative driving cycles: HPPC, DST, and NEDC. The BMS relies on its internal EKF algorithm, an integral part of its embedded firmware, to compute SOC. The output of the BMS, i.e., the reported SOC values, was captured in the HIL environment. As the reference value, the measured battery capacity determined by the high-precision charging and discharging instrument was used. Using the known ampere-hour count, I calculated the reference SOC at corresponding times.
Under the HPPC operating condition low dynamics typical of moderate driving, the maximum absolute deviation between the measured SOC and the observed value was less than 1.6 percent. Under DST, which has larger and faster current changes, the accuracy of the SOC estimated by the BMS remained within 1.6 percent as well, confirming that the estimation algorithm is able to correct disturbances introduced by driving dynamics. Even with the highly dynamic NEDC driving cycle, the observed largest error after a full test is no more than 2.8 percent. This result demonstrates that the estimated SOC is able to track the actual battery charge state and also ensure robustness with respect to measurement noise and model inaccuracies.
I observed that the error is largest during the middle portion of the discharge event when the voltages are closest to the plateau region, and it is reduced at lower SOC values because the open-circuit voltage exhibits a higher slope with respect to the SOC. The recorded maximum cumulative error does not exceed 3 percent under the most demanding test, complying with the minimum requirement of 5 percent cumulative error established by the standard.
5.3 Cell Balancing Functional Test
Cell voltage differences arise from manufacturing variations or thermal gradients. BMS balancing circuits compensate for those differences. The BMS under investigation activates its balancing resistors when the voltage difference between the lowest and the highest cell is greater than or equal to 40 mV.
In the equalization test I set all cells in the model to the same initial voltage of 3.20 V. The voltage of a single cell was increased gradually in steps of 10 mV while the voltage of the remaining cells remained unchanged. The state of the balancing channel was observed in the HIL interface. The result shows that the balancing function is deactivated at the beginning of the test, as expected, because the measured voltage differences are below the activation threshold. When the difference between the cell voltages reaches the set value of 40 mV, I detected that the BMS closes the balancing switch on the specific channel and thereby enables a balancing current of 32 mA. The balancing process succeeds in reducing the voltage difference and allows safe continuation of the charging process.
These observations demonstrate that the BMS equalization control strategy correctly detects voltage differences between individual cells, initiates the required equalization actions at the correct threshold values, and performs the process using the designated hardware resources. Therefore, the tested BMS carries out the balancing management function in accordance with its design and specifications.
5.4 Fault Diagnosis Functional Test
Fault diagnosis capability is decisive for BMS functional safety. I therefore performed extensive testing of the BMS failure mode detection logic using the real-time platform. The fault injection function was carried out from the host computer HIL interface. The fault management system implemented in the model enables the generation of carefully controlled system states such as overvoltage, undervoltage, overcurrent, overtemperature and SOC jumps.
During a test, a specific fault scenario was activated in the simulation. The target machine changed the corresponding voltage or current in real time, thereby injecting the defined signal fault into the BMS. I then observed both the BMS reaction in the HIL interface and the status information transmitted by the BMS via CAN. The objective of the test was to verify that the BMS enters the designed safe state or issues the appropriate warning messages within the specified time limit.
For example, a model cell voltage was set to 3.26 V, which exceeds the maximum voltage threshold of 3.20 V configured for this specific experiment. The BMS should detect an overvoltage condition. The fault injection triggered a voltage rise at the corresponding input pin. My recorded observations show that the BMS reacted to the anomalous condition by correctly identifying the overvoltage fault. The results in the fault diagnosis interface show the increased cell voltage in real time, and the warning indicator on the screen lights up after a response period of approximately 3.5 seconds.
| Test Description | Test Setting | Expected Result | Measured Result | Compliance |
|---|---|---|---|---|
| Voltage acquisition | Cell voltage from 2.8 V to 3.6 V | Error < 10 mV | Error < 10 mV | Yes |
| SOC HPPC | Dynamic HPPC profile | Max. error < 5% | Max. error ~1.6% | Yes |
| SOC DST | Dynamic DST profile | Max. error < 5% | Max. error ~1.6% | Yes |
| SOC NEDC | Dynamic NEDC profile | Max. error < 5% | Max. error ~2.8% | Yes |
| Overvoltage detection | Cell voltage raised to 3.26 V | Fault code display | Fault indicated ~3.5 s | Yes |
| Cell balancing start | Cell difference > 40 mV | Balancing active ~32 mA | Balancing activated | Yes |
The fault diagnosis testing results confirm that the BMS successfully identifies various simulated faults when they occur, appropriately raises the diagnostic flags, and communicates the corresponding warning messages to the operator. The reaction behavior of the tested BMS and the timing of the fault signals correspond to the functional specifications. By performing these fault injection tests on the HIL setup, the BMS system is always exposed to extremely demanding situations that could be dangerous to test in an actual vehicle setup. The HIL test platform is therefore a reliable and efficient verification infrastructure for fault handling strategies.
6. Summary, Innovation and Outlook
In this thesis, I have designed and developed a BMS HIL testing platform based on the Speedgoat real-time target and successfully applied it to a series of BMS functional tests. The primary contributions and conclusions of my work are summarized in the following points.
First, I investigated systematically the structures and functions of different BMS system architectures, mainly focusing on master-slave topologies, and evaluated the hardware and software resources and related test requirements of a freely developed BMS. This analysis defined the starting point for a suitable BMS HIL architecture and thereby the design of the test platform.
Second, I compared various commercial HIL simulation systems and analyzed in detail the properties and interactions of their key components. Based on this comparison, the hardware concept was established. In addition to the actual components included in the test bench, I configured the peripheral wiring and the analog and digital interface boards in such a way that the system can be used flexibly for a variety of test tasks. The result is a functional HIL test environment built around the Speedgoat device.
Third, I constructed the necessary simulation models and implemented the connecting software and configuration steps. The battery model, developed as a PNGV equivalent circuit, was parameterized using data from a comprehensive HPPC test series. Model validation under DST produced satisfactory agreement with the measured cell voltage. The average model error was less than 0.05 V over the entire DST current profile. In addition to the battery model, the SOC estimator, which is based on the extended Kalman filter (EKF), the cell balancing circuit model and the complete electric vehicle model were configured for real-time on the Speedgoat system. I developed the test and control interface with the Simulink Real-Time Explorer software and implemented a fault-diagnosis user interface to execute fault scenarios and to display the resulting status in a user-friendly environment.
Fourth, the performance of the test subject was analyzed by performing functional tests with the new HIL platform. The BMS was tested regarding data acquisition accuracy, state-of-charge estimation under various operating conditions, cell balance control, and diagnosis reaction. Test results showed that the voltage error of the acquisition circuit is less than 10 mV, which is compliant with relevant requirements. The SOC estimation error stayed below 3% for all tested cycles, thereby satisfying the specified error margin of 5% and demonstrating the excellent estimation quality and stability of the BMS algorithm. Active cell balancing was successfully activated at the desired threshold and the fault diagnosis function correctly detected all fault scenarios within the expected response time.
With regard to the innovation, I have made the following contributions to the current state of research:
Real-time SOC estimation based on the extended Kalman filter method has been successfully integrated into the test environment. By using the EKF to supplement ampere-hour counting, the drawback of selective error accumulation is minimized, which improves the robustness and accuracy of the SOC estimation function across different driving conditions.
I built the HIL system using Speedgoat, a simulator offering seamless, high-level MATLAB/Simulink integration. As a result, users do not need to handle complicated interface circuitry or low-level implementation details. The system configuration and the replacement of the battery pack model or even the entire vehicle model can be done directly at the Simulink model level.
The HIL test software includes a self-designed user interface for test control and fault insertion. The fault-injection function can be used to simulate various electrical and signal errors in a safe way. Since the test procedure is automated and the system state can be monitored at any time, this approach contributes to accelerated and more cost-effective validation of BMS design iterations.
Several aspects of my research would benefit from further improvements and expanded studies. Due to the long charge or discharge times of comprehensive battery test experiments, the number of battery data points from battery pack measurements was limited and the environmental conditions that could be investigated were restricted to a single reference temperature. With improved test infrastructure and more battery samples, future testing campaigns should include a broader range of operating temperatures and more battery cells in different aging stages to better characterize the battery and validate the model under various conditions. In addition, the HIL platform was operated with manually configured test parameters; hence an automated test sequence definition and execution capability would significantly reduce testing effort. The implementation of scripting to generate parameter sets, start tests, evaluate the resulting data and produce a complete test report substantially improves the efficiency. Finally, the BMS also contains thermal management features that could not be fully examined within the scope of this thesis. Extending the platform with a temperature control model and adding test sequences for thermal cycling and thermal protection mechanisms would be a logical and valuable next step in the further development of this work.
