Creating an Electric Vehicle HIL Test Using LabVIEW and CompactRIO

  Read in   |   Print Print

"Thanks to CompactRIO and LabVIEW FPGA programming, we implemented a complex HIL system that makes highly dynamic responses to differential equations in microseconds, and in the case of the engine model, in up to just 1 µs."

- Jaume Martínez, Asoindel

The Challenge:
Developing a rapid-response, hardware-in-the-loop (HIL) system for several complex models, created in MathWorks, Inc. Simulink® software, to achieve simulation loop speeds under 20 µs.

The Solution:
Using NI CompactRIO with LabVIEW FPGA programming for a highly deterministic calculation speed and high-speed simulated hardware response.

Author(s):
Jaume Martínez - Asoindel

In the production industry, manufactured device tests are often costly. Testing a system with a real device has important implications regarding cost, time, and available resources.

To test electric vehicle engine management electronics, we need to physically feed electronic power to the engine and use a load system to oppose engine movement. Many times, we do not have the necessary infrastructure to do so.

The HIL system uses a computer to electronically model this infrastructure. It simplifies setup because a small device can emulate several physical systems. The principle is simple: The HIL I/O interface must correspond to the devices emulated regarding voltage, power, and response times. The system digitizes the entries, and inside the HIL, a mathematic model simulates the physical system. The system variables, such as speed and torque, are calculated from the model entries and status. These variables are converted to electrical signals that simulate real physical device sensors and repower the control system.

This way, we can substitute the physical system with hardware inside the control loop. Obviously, the response is only as good as the model is realistic. Calculation speed is also important, as it should be high enough that the closed-loop control system dynamic supervising the HIL is not negatively affected by substituting a real (continuous) system for a discreet one.

Because the system is software based, we can make changes in the model parameterization. For example, we can verify what happens when power source voltage decreases, engine parameters change, or vehicle mass changes—all without acquiring a new physical device.

System Setup

Due to model dynamics, we needed an FPGA-based system to host the mathematical model. We chose NI CompactRIO because it is a compact, powerful system that we can position in the testing area.

We started with various Simulink diagram implementation models, including signal filtering; inverter; rectifier; engine; and vehicle model (load) against which the engine works, including vehicle incline rate condition. Because these models include differential equations, we needed an integration step of mere microseconds.

To correctly execute the model at the necessary speed, we needed significant development time. Along the way, we had to discard several FPGA programming strategies because they used tremendous resources and could not host the model, or because calculation times were too long. Finally, we developed a programming architecture that optimally meets all requirements. Using the techniques we learned, we can add new blocks to the model in a matter of weeks.

For the complete model, we obtained execution loops of 5 µs to 10 µs. For the most critical engine part, which requires more precise integration, we achieved execution loops of up to 1 µs.

In addition to interface models that connect with the outside, we also have entry signals, such as counters and insulated gate bipolar transistors, that stimulate the model. The exits correspond to simulated physical sensors; for example, FPGA encoder pulse generation registers speed. Other analog exits report model internal variable status, such as currents, engine torque, and acceleration. The signal level adapts via customized external electronics.

Thanks to FPGA speed, we implemented certain necessary digital responses in the region of tens of nanoseconds. The analog signals are slower (kilohertz) due to generating limitations, but they still meet requirements.

We executed the whole model using NI CompactRIO and FPGA. We initially chose an NI CompactRIO real-time CPU to make auxiliary calculations, but eventually we changed our plans and only use the real-time CPU for data transmission between the user interface and the FPGA.

The user interface executes on a Windows-based PC. From the interface, we can parameterize the whole model and launch the HIL. We also can show the most important data and model internal variable status at 10 kHz in different charts. Finally, we can change simulation parameters such as vehicle angle inclination and voltage-fed values, and even some internal parameters, on the fly.

Conclusion

Using CompactRIO and LabVIEW FPGA programming, we implemented a complex HIL system that makes highly dynamic responses to differential equations in microseconds, and in the case of the engine model, in up to just 1 µs. All entries and exits correspond to the real physical system, except for signal levels that adapt through customized electronics.

The resulting system is extremely useful because clients can use it in various development stages: system signal verification and internal programming; vehicle speed and torque control algorithm development and testing; and finally, vehicle model control parameter tuning.

Because we have fielded many requests for our HIL system, and we are using it for much more than we had originally planned, we added new modules to increase functionality. Most recently, we developed an HIL launcher for executing different models (such as vehicles with both synchronous and asynchronous engines and energy recuperation systems) using the same NI CompactRIO platform.

Simulink® is a registered trademark of MathWorks, Inc.

Bookmark and Share


Explore the NI Developer Community

Discover and collaborate on the latest example code and tutorials with a worldwide community of engineers and scientists.

‌Check‌ out‌ the‌ NI‌ Community


Who is National Instruments?

National Instruments provides a graphical system design platform for test, control, and embedded design applications that is transforming the way engineers and scientists design, prototype, and deploy systems.

‌Learn‌ more‌ about‌ NI