Hardware in The Loop
Hardware in The Loop
Hardware in The Loop
A.
<BACK
LEDIN
f e a t u r e
Hardware-in-the-Loop
Simulation
Hardware-in-the-loop (HIL) simulation is a technique for performing system-level testing of embedded systems
in a comprehensive, cost-effective, and repeatable manner. This article provides an overview of the techniques of
HIL simulation, along with hardware and software requirements, implementation methods, algorithms, and rules
of thumb.
FEBRUARY 1999
product development phase, HIL simulation is a valuable tool for performing design optimization and hardware/software debugging.
However, for an HIL simulation (or
any simulation, for that matter) to produce reliable outputs, it is critical to
demonstrate that the simulated environment is an adequate representation of reality. This is where the concepts of simulation verification and
validation must come into play.
Embedded
System
(SUT)
Sensor input signals
Operator commands
Real-Time
Simulation
FEBRUARY 1999
43
BEN FISHMAN
hil simulation
time h seconds into the future (subscript n+1) with a current derivative x n is:
xn +1 = xn + h x n
While it has the advantage of simplicity, Euler integration has poor performance
characteristics in terms of the error in approximating the solution. Its a first-order algorithm, so its local truncation error (the error in the solution after a single step) is proportional to h.
An algorithm that provides much better accuracy while remaining suitable for realtime use is the Adams-Bashforth second order algorithm. It uses the current value of
xn +1 = xn + h 3 x n - 1 x n -1
2
2
This is a second-order method with local truncation error proportional to h2. It is the
most commonly used integration method in real-time continuous system simulations.
Its main drawback is that a significant transient error can occur if there is a discontinuity in the derivative function. It also requires an initial step using the Euler algorithm
FEBRUARY 1999
45
hil simulation
The complexity of the SUT elements and operational environment to be modeled in the simulation software
I/O devices
Many different categories of I/O
devices are used in embedded systems.
Simulation computer
hardware
In addition to the SUT, the hardware
used in an HIL simulation must
include:
The
real-time
performance
requirements for the simulation computer depend on the characteristics of
Embedded Systems Programming
FEBRUARY 1999
47
hil simulation
High-performance CPUs
Support for real-time operations
High data transfer rates
Support for a variety of I/O devices
Simulation software
structure
The simulation software contains sections of code that perform the tasks
needed during real-time simulation. A
diagram of the basic software flow of
an HIL simulation is shown in Figure
2.
As examination of the flow diagram
reveals, the HIL simulation software
can be separated into three basic
parts:
FEBRUARY 1999
hil simulation
ts
20
Multiframing
Some subsystems modeled in a simulation may have time constants that vary
significantly from those of other subsystems. When this occurs, improving
simulation performance is possible by
using the technique of multiframing.
A multiframe simulation has more
than one frame rate. The frame times
h1, h2, and so forth are generally set at
integer multiples of a common factor,
with the fastest frame time called hf.
The simulation updates each model at
the times appropriate for that models
frame rate.
Simulation programming
languages and environments
Over the years, a number of specialized programming languages and
environments have been developed to
ease the task of developing simulations of dynamic systems. Some simulation languages are text-based while
other development environments are
graphical. Graphical tools allow the
user to construct diagrams describing
the system to be simulated. Many of
these tools are intended for use only
in non real-time applications, and
therefore arent suitable for developing HIL simulations. In addition,
many of these languages and tools are
either proprietary or are supported by
only a single company.
Common attributes of full-featured
dynamic simulation languages and
graphical development environments
include:
50
FEBRUARY 1999
hil simulation
In addition to the specialized simulation languages and graphical development tools, it is common to use general purpose programming languages
such as Fortran and C to develop HIL
simulations. Many HIL simulations
have been written from scratch, using
only the tools and libraries supplied
with the target system compiler. While
this approach can succeed, it requires
a great deal of effort developing efficient and correct methods for numer-
Initialization
Initialize simulation
and hardware
Evaluate simulation
models
Dynamic Loop
Write to output
devices
End of run?
No
Integrate state
variables
Shutdown
52
FEBRUARY 1999
Yes
Developing simulation
models
hil simulation
The time it takes to design, develop, verify, and validate the simulation model
The effort required to collect and
analyze experimental data needed
to develop the model
The execution time and memory
space that the models implementation consumes on the simulation
computer
54
FEBRUARY 1999
hil simulation
Video
signal
Image
processor
Video
camera
developers to perform their own system analyses, and they can modify it to
examine the effects of proposed product changes and enhancements.
These changes can then be implemented in the HIL simulation for further testing. This sharing of simulation models among different groups
can result in tremendous benefits to
the product development process.
56
FEBRUARY 1999
Implementation issues
Several issues in the development and
operation of an HIL simulation can be
problematic. Some areas that have created difficulties in past HIL simulations are examined in this section.
Selection of appropriate interface points.
When you are interfacing an embedded system to a simulation computer,
hil simulation
If these items are properly handled, RMS can provide significant benefits in multiframe real-time simulations. Multiframe simulation is used when subsystems must be
simulated at different frame rates. Using RMS allows these different frame rates to run
on a single CPU while I/O operations occur at the correct times for each different frame
rate.
If the RMS-based multiframe simulation is carefully designed, it should be possible
to move tasks to different CPUs with relative ease as new CPUs are added to the system. Tasks can be relocated among CPUs to provide optimization through load balancing.
RMS is a tool that developers can use to implement high-performance, real-time
simulations that make the best possible use of available resources.
58
FEBRUARY 1999
hil simulation
FEBRUARY 1999
A reasonable simulation?
The development of an HIL simulation can be a complex and time-consuming process. Getting system
experts to accept the results of an HIL
simulation as valid is often a formidable obstacle. A simulated operational
environment will never be a perfect
representation of the real thing. Given
the costs and potential difficulties
involved, when does it make economic
and technical sense to develop and
use an HIL simulation?
HIL simulation is a valuable technique that has been used for decades
in the development and testing of
complex systems such as missiles, aircraft, and spacecraft. By taking advantage of low-cost, high-powered computers and I/O devices, the advantages of HIL simulation can be realized by a much broader range of system developers. A properly designed
and implemented HIL simulation can
help you develop your products faster
and test them more thoroughly at a
cost that may be significantly less than
the cost of using traditional system test
methods.
esp
Jim A. Ledin, PE, is an electrical engineer
in Camarillo, CA. He has worked in the
field of HIL simulation for the past 14
years. He is a principal developer of HIL
simulations for several U.S. Navy tactical
missile systems at the Naval Air Warfare
Center in Point Mugu, CA. He can be
reached by email at jledin@ix.netcom.com.