Developing an HIL Simulator for Testing Battery Management System Logic

Sung-Up Hwang, ControlWorks


"We chose NI software and hardware to shorten system development time, guarantee system reliability, simplify test automation scenario implementation, and make maintenance and repair easier."

- Sung-Up Hwang, ControlWorks

The Challenge:

Creating a hardware-in-the-loop (HIL) simulation environment for battery management system (BMS) external connection unit (ECU) quality diagnosis with a cell voltage replica of a high-voltage battery, simulation of current sensor and temperature sensor attached to a high-voltage battery, and simulation of possible errors associated with a high-voltage battery.

The Solution:

Using NI LabVIEW software to easily implement a GUI and support various functions, and a battery model using the LabVIEW Simulation Interface Toolkit to link to models created using MathWorks, Inc. Simulink® software.

We used HIL simulation to test our complex real-time system. This technology is especially effective in providing a platform for checking the control status of testing subjects that need dynamic model applications.


System Overview

We use the BMS HIL system to simulate the high-voltage battery used in an electric or hybrid car to evaluate a BMS control logic and failure diagnosis. We used Simulink to create a battery model and then used the LabVIEW Simulation Interface Toolkit to apply the battery model to the development platform. To ensure reliable operation and high-quality performance, we also used the NI PXI system.


The BMS HIL simulation system can perform quality diagnosis on a variety of test cases. By writing the test automation scenario, we reproduced all possible test cases for the battery system and used NI TestStand to neatly organize many scenarios for implementation.


We used LabVIEW for fast system implementation and NI PXI to quickly produce and collect signals to accurately reproduce changes in the battery cell voltage, including its current and temperature changes, in the BMS.


Furthermore, by using NI TestStand, we can use BMS performance evaluation test cases to implement simplified test automation scenarios.


Benefits of Using NI Products

We chose NI software and hardware to shorten system development time, guarantee secure system reliability, simplify test automation scenario implementation, and make maintenance and repair easier. NI products are also compatible with Simulink.


Hardware System Configuration

The configuration of the BMS HIL simulation system consists of a computer to control the entire system with LabVIEW, a real-time PXI simulator that collects and provides signal output, a cell voltage generator that simulates a battery cell, and a signal conditioning unit. It also includes an error simulation unit that simulates errors in various test case applications, a power supply for the BMS ECU, and a break-out box that connects the HIL simulation system and the ECU.




System Software Configuration

The BMS HIL simulation system software is largely divided into two different systems. With the first system, we can manually produce errors and configure various settings to check the ECU performance. The other is an automatic system that uses NI TestStand to configure various errors beforehand and then automatically checks ECU performance.





When the host computer receives the control comment request generated by the user, the PXI real-time simulator allocates real-time signal collection or output roles. Through a field-programmable gate array (FPGA), these distributed roles perform designated tasks in real time.


Stack voltage, battery temperature, and discharging cell current derived from the battery model are simulated through the FPGA. Because the FPGA supports high-speed performance, we can increase response speed for current generated from each battery cell.


Test Scenario Implementation

By using NI TestStand (see Figure 7), we can sequentially lay out various error situations and configurations that can occur in battery systems, leading to concise test automation scenario configuration.



Our BMS HIL simulation development system reduces the cost and risks associated with testing real batteries from electric or hybrid vehicles. It also provides a testing environment that encompasses stack voltage, current, and temperature, which are hard to collectively configure. In addition, using NI products increases hardware reliability and reduces development time.


By using LabVIEW and the LabVIEW Simulation Interface Toolkit, we quickly implemented the user interface configuration and easily applied the battery model created in Simulink. With NI Teststand, we can configure many test cases derived for BMS performance evaluation for readable, concise test automation scenarios.


Starting with LabVIEW 2013, the LabVIEW Simulation Interface Toolkit has been replaced by the LabVIEW Model Interface Toolkit.


Author Information:

Sung-Up Hwang

Figure 1: BMS HIL Simulation System Hardware Configuration
Figure 2: BMS System Signal Flow
Figure 3: BMS HIL Simulation System Software Configuration
Figure 4: BMS HIL Simulation User Interface Configuration
Figure 5: Battery Model Applied by LabVIEW Simulation Interface Toolkit
Figure 6: Using FPGA to Produce Output of Stack Voltage Derived From Battery Model
Figure 7: Using FPGA to Produce Output of Configured Temperature and Current
Figure 8: Implementing Test Automation Scenario Using NI TestStand