Hardware-in-the-loop (HIL) testing is a technique used by engineers for testing and validating embedded systems software. HIL works by electronically connecting a control unit running the software to an accurate simulation of the sensors and actuators controlled by an embedded system.
The simulated system can consist of both virtual and physical models representing real-world systems. Engineers use HIL test systems to test the functionality of their software in real time in a controlled environment before deploying their solution in actual vehicles, machines, devices, or systems. As the products and software they use become more complex and involved in safety-critical applications, HIL testing’s importance has grown.
The key components of a hardware-in-the-loop simulation system are either part of the control device, the simulation plant, or the simulated hardware (sometimes called a digital twin). When combined, these components create a closed-loop, real-time simulation of the control system.
The software under test is the primary component in the control unit part of the test setup. It consists of the actual code loaded onto the hardware and is the software portion of the control device.
The electronic control unit is the device that runs the software and provides inputs and outputs (I/O) to the plant it controls. A key advantage of HIL testing is that it checks the software on the real-world electronics hardware it will run on when deployed.
In the final product, the control unit is connected directly to sensors and devices. For an HIL testing environment, specialty HIL devices and software from companies like National Instruments (NI) or dSPACE connect the components that simulate the actual plant to an ECU. Also called an HIL testing system, this provides test management, I/O configuration, and automation tools. It may consist of a single unit or multiple units.
Testers use mathematical representations of some subsystems they don’t have access to or systems they can’t simulate as fast or as easily as real hardware. Each virtual component can receive commands and data inputs and produce the same electrical outputs, either digital or analog, as the actual system. These virtual simulations can be as simple as an equation and as complex as a multiphysics simulation of an antenna system mounted on a satellite in orbit.
Many system test setups use real-world hardware that may be the final production product, a prototype, or a physical representation of a subsystem. However, simulated systems can also contain physical components connected to virtual components. This is especially common for systems in which the sensors are represented with a virtual version in the hardware loop.
Many complex control systems, especially safety-critical ones, use a technique similar to HIL called software-in-the-loop (SIL) testing. Physical hardware is used for I/O in HIL, but in an SIL system, the setup uses a software tool to emulate the behavior of the ECU’s microprocessor or field-programmable gate array (FPGA) and the network of electrical connections used for I/O.
SIL is usually carried out early in the product development process before the physical ECU is available. Software development teams leverage SIL for validating algorithms, logic, and overall software behavior before integrating with real hardware. SIL enables low-cost testing without the need for physical hardware or a physical space.
Yet even when teams use thorough SIL testing, HIL testing is still required because the software needs to be validated on the ECU and with real-world signals, including latency and noise. Many use cases involve ECU behavior that software can’t simulate. HIL testing ensures that the hardware and software work together for safety testing and comply with industry standards common in aerospace, medical, and automotive applications.
Hardware-in-the-loop testing offers significant advantages in terms of schedule, cost, safety, and performance. In some industries, it is even required for certification. The impact of these benefits depends on the accuracy of the simulations used, the cost of creating those simulations in hardware or software, the potential automation of time-consuming steps, and the thoroughness and efficiency of the test plan.
Some of the more significant benefits of HIL simulation include:
HIL can deliver improvements to a product’s development schedule in several ways. The most significant benefit is that HIL testing is much faster, enabling around-the-clock testing with multiple test benches running in parallel. Another reduction in development time involves introducing HIL testing earlier in the development process. Teams can identify issues early with only a minor impact on the production schedule. Automation opportunities enabled by HIL also reduce the time needed to conduct testing. And, most critically, HIL can significantly reduce a product’s time to market.
Because there are usually a limited number of full physical prototypes, only a few tests can be conducted at the same time. With HIL testing, engineers can run more tests in parallel to greatly shorten the development cycle.
HIL’s positive impact on a product’s development schedule also helps reduce costs. In addition, the highly scalable nature of this testing technique makes conducting multiple tests much more cost-effective. On top of that, using HIL can remove or reduce the cost of creating the physical hardware and software needed for the final plant design. Automation for multiple test scenarios also reduces labor and test cell time, or the time hardware setups are in use.
Developing robust control algorithms is easier when engineers can test their ideas in a consistent and reproducible manner. The uncontrolled and unpredictable environment of real-world testing can introduce too much variability.
Few things in a development program are as expensive and damaging to a production schedule as failing a final certification or performance test. If a testing process includes both SIL and HIL testing, most failure modes can be discovered and corrected early in the process.
Many systems controlled by embedded systems software require safety validation testing, yet many cannot be tested in a safe environment. For example, testing an advanced driver-assistance system (ADAS) requires putting a vehicle into dangerous situations to check how the ADAS responds. This is not only expensive but also dangerous for the driver and may damage the vehicle. HIL testing with virtual components and test automation removes that danger to testers, validates the safety of the system, and reduces costs.
Any product that uses embedded systems software for device control can benefit from HIL testing as part of the controller design process. However, some industries will benefit more than others because the advantages listed above are more significant in their production processes. Here are six major industries in which hardware-in-the-loop testing is widespread:
The automotive industry is one of the most prolific users of HIL, especially with the growing movement toward designing software-defined vehicles (SDVs). The cost and safety issues around real-world vehicle testing, not to mention the long lead time before a prototype is available, make HIL an important part of automotive vehicle design.
For example, HIL can be used to test the camera used in an ADAS system. Ansys AVxcelerate Sensors software and NI’s RDMA can produce the raw signal from a virtual car’s camera, convert that into the signal the camera’s embedded processing will see, and then feed the output from that subsystem to the ECU.
Three of the biggest challenges in developing control systems for aerospace applications are stringent specification adherence, the cost of creating hardware, and the difficulty and cost of testing actual aerospace modules in the field. Each of these challenges makes HIL the preferred testing method, and it is often required for certification. The introduction of autonomous systems in aerospace only increases the need for HIL.
Power plants that generate energy for electrical systems or mechanical propulsion benefit from the use of embedded system controllers. ECUs in such applications use sensors that detect operating conditions and send commands to optimize efficiency, reliability, and power production. This can be as simple as the power electronics for energy production or as complex as the pollution monitoring and minimization in a natural gas power plant.
A growing number of industrial machinery manufacturers and manufacturing facilities that use industrial equipment, including robotics, use HIL simulation to optimize the efficiency of the machines or the manufacturing process before building out a new production line.
The increased use of smart devices, stringent safety certification, and real-world testing challenges in the medical industry also drive development teams to increasingly use HIL testing. Embedded software can be checked in safety-sensitive systems like pacemakers or insulin delivery devices by using HIL early in the design process and in the verification and validation phase.
When HIL testing is applied to battery management systems (BMS), it can accelerate battery development in automotive, aerospace, and power generation applications. The closed-loop validation of BMS in an HIL environment ensures all safety and performance functions operate without error. A battery system-level model developed through computer-aided engineering (CAE) simulations can be integrated with HIL systems to represent the physical battery. It can also connect with physical battery systems to validate BMS performance under different conditions such as overvoltage, overcurrent, overtemperature warning, cell balancing, short circuit response, and other critical events the BMS is designed to manage.
Numerical simulation, especially the types of tools found in Ansys multiphysics software, plays an important role in most HIL simulation endeavors. When a simple equation or lookup of empirical data won’t provide the fidelity or range needed, or when using a physical simulation is not feasible or cost-effective, numerical simulation provides a solution.
The advantage of numerical simulation is that it is very accurate. Additionally, engineers may already have models of the hardware, and the team can capture the impact of the control system on that module in the system.
Here are some ways to use virtual components in an HIL study:
Modeling vehicles undergoing many driving situations, coupled with input from sensors that accurately mimic real-world sensors, is key to HIL testing when developing ADAS/AV solutions. That is why an entire suite of digital modeling tools like Ansys AVxcelerate solutions is used by engineers across the automotive industry to model inputs to embedded systems software.
Two great examples are Ansys AVxcelerate Sensors software for modeling camera and lidar input and Ansys AVxcelerate Headlamp software to show engineers what changes to headlamps actually look like to drivers, other vehicles, and pedestrians.
Regardless of how the numerical simulation models generate results from the provided inputs, they need to be passed into the HIL system. One simple way to do this is with a scripting capability like PyAnsys to connect software through the Python language. A model-based systems engineering (MBSE) tool like Ansys ModelCenter software or the Ansys Thermal Desktop (AEDT) platform provides an accurate view of real-time system-level behavior.
A common addition to the digital components in a HIL simulation are numerical solvers representing components’ structural, thermal, and dynamic behavior. A general-purpose tool like Ansys Mechanical software or specific solutions like Ansys Motion software for multibody dynamics can be used for this purpose. Additionally, engineers can use a tool like Ansys optiSLang software to generate reduced-order models (ROMs) that can be inserted into an MBSE system model.
Electromagnetic sensors and actuators play an important role in many systems driven by embedded systems software, so fast and accurate electromagnetic modeling tools like Ansys Maxwell software and Ansys HFSS software are often integrated as digital components in the plant.
Contact an Ansys representative today to learn how our industry-leading software solutions can help you.