You are on page 1of 9

LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.

com/devzone/cda/tut/p/id/3567

Improve your ni.com experience. Login or Create a user profile.

Document Type: Tutorial


NI Supported: Yes
Publish Date: Dec 29, 2008

LabVIEW FPGA in Hardware-in-the-Loop


Simulation Applications
Overview

Hardware-in-the-loop (HIL) simulation is achieving a highly realistic simulation of equipment in an operational virtual
environment. A typical HIL system includes sensors to receive data from the control system, actuators to send
data, a controller to process data, a human-machine interface (HMI) and a development postsimulation analysis
platform. National Instruments products empower engineers and scientists to define and create their own HIL
systems with an innovative, modular, cost-effective hardware and software platform. The introduction of the
LabVIEW FPGA Module with R Series reconfigurable I/O hardware enhances the National Instruments platform for
HIL implementation.

This document provides an overview of how the enhanced NI platform can help you rapidly design and deploy your
own HIL system.

Table of Contents

1. Introduction
2. HIL Overview
3. Building Your HIL System with NI Products
4. NI Leads HIL Success at the Woodward Governor Company
5. Conclusion

Introduction

Embedded control systems play an important role in controlling the different components of a typical mechanical
system. Consider the design of an autopilot for a small unmanned aircraft. A small error in the design could cause
a $200 million aircraft to crash during traditional testing. Software simulation of the system before actual testing is
not always helpful because it doesn’t run in real time with actual analog and digital signals. This dilemma has led to
the adoption of HIL simulation as a standard method for testing embedded control systems before final
deployment.

HIL simulation is achieving a highly realistic simulation of equipment in an operational virtual environment. A typical
HIL system includes sensors to receive data from the control system, actuators to send data, a controller to
process data, an HMI, and a development postsimulation analysis platform. National Instruments products
empower engineers and scientists to define and create their own HIL systems with an innovative, modular,
cost-effective hardware and software platform. The introduction of the LabVIEW FPGA Module with R Series
reconfigurable I/O hardware enhances the National Instruments platform for HIL implementation.

HIL Overview

HIL in the Design Cycle


Traditional testing, referred to as static testing, is where functionality of a particular component is tested by
providing known inputs and measuring the outputs. Today there is more pressure to get products to market faster
and reduce design cycle times. This has led to a need for dynamic testing, where components are tested while in
use with the entire system, either real or simulated. Because of cost and safety concerns, simulating the rest of
the system with real-time hardware is preferred to testing individual components in the actual real system.
Dynamic testing also encompasses a larger range of test conditions compared to static testing. Employing this
strategy for dynamic testing is known as Hardware-in-the-Loop (HIL) simulation.

1 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

HIL is an integrated part of the design cycle. Figure 1 below represents the design cycle of embedded control
applications common to automotive, aerospace, and defense industries.

Figure 1. Control Design Cycle

The control design cycle consists of several different stages of design and testing. The System Definition step
documents the needs and requirements of the system. The Rapid Prototyping step involves development of
prototype controllers to test the basic ideas and concepts in an actual system. The actual system can be
simulated using software or a combination of software and hardware. The idea of HIL testing is similar in concept
to rapid prototyping in that part of the system is simulated while connected to the rest of the real system. National
Instruments LabVIEW and PXI are used extensively for rapid prototyping applications in the industry.

Figure 2. Rapid Prototyping

After a design has been prototyped and verified, the program must be deployed on the final production controller in
the Targeting phase. After the controller has been developed in the targeting phase, it needs to be tested as part of
the actual system. Often the actual systems are very expensive. It then becomes imperative to test the controller
on a simulation of the actual system. This stage is referred to as HIL simulation. Once the controller performs
satisfactorily in the HIL simulation stage, it is then tested on actual systems.

2 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

Figure 3. Hardware-in-the-Loop

Benefits of HIL
The most evident advantage of HIL simulation is that real-world conditions are achieved without the actual risks
involved. For example, an autopilot can be tested thoroughly without putting a $200 million plane at risk. But, there
are many other benefits to HIL simulation. With HIL, you can test the control units with extreme conditions that
might not be feasible in the real world. You can simulate winter road conditions for the vehicle under test even in
the heat of summer. You can test the control unit to the limits – up to the very maximum speed a car can
theoretically be driven. HIL enables you to isolate deficiencies in the control unit even if they occur only under
certain circumstances. With HIL, outputs can be calculated as a function of existing inputs as well as a
combination of past inputs. A hardware subsystem can be tested using HIL without having the entire system
ready, thus making testing an effective part of the development process, from design to deployment. With HIL,
you can make early decisions on specific design alternatives on a sound basis, which leads to designs that
function effectively in situations that will be encountered by the control unit when it is in the hands of the
customer. Robust, high-fidelity real-time HIL simulations not only enable shorter time to market by reducing the
development period, but also reduce cost by eliminating the need for actual hardware during testing, as well as
associated maintenance costs.

Building Your HIL System with NI Products

Consider that you have just built an electronic diesel control unit (EDCU) for an automobile. Its primary functions
are to control the amount of fuel injected into the engine and the engine timing. Before the EDCU is deployed in a
real automobile, you want to test it in an HIL system containing the EDCU and a simulation of the automobile. To
have the simulation of the automobile as real as possible, you simulate realistic signals that go into the EDCU and
also take into account the dynamics of the system. Such an HIL system involves the use of hardware to generate
and receive realistic signals and software to simulate the dynamics of the system.

You must choose the appropriate components for the application and for integration into a complete HIL system.
Use sensors and actuators to receive and generate signals to and from the EDCU. Use a processing unit to
perform the calculations for the simulation. Use a human-machine interface and a development machine for the
simulation. Often the same machine is used for both tasks. You can use a subsystem for postsimulation analysis.
Figure 4 presents the architecture of a typical HIL system.

3 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

Figure 4. Architecture of a Typical HIL System

There are five main factors to consider when designing your HIL system.

The system should accept a variety of control unit configurations.


A small change in the control unit must not warrant a design of a completely new system.
The system should perform both open and closed-loop testing.
The system should be scalable and open.
Most importantly, the system should be of reasonable cost in terms of components and development time.

Sensors and Actuators


The main purpose of an HIL system is to simulate the real world as closely as possible. Simulating the analog and
digital signals that go into the control unit and receiving signals from it as accurately as possible are two of the
major challenges in designing such a system. The hardware used should have a sufficient number of input and
output channels. The hardware also should be able to generate a wide variety of complex signals as accurately
and deterministically as possible, for example:

Waveforms – variable reluctance sensor, simulated load/vibration


Counters – pulse, pulse-width-modulated
Digital signals

The hardware should provide for flexible signal conditioning interfaces. It must be compatible with industry-
standard protocols such as CAN, RS-422/232/485, J1850 and MIL1553. Most importantly it should be modular,
flexible, and economical.

4 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

Figure 5. National Instruments Hardware Products

Using National Instruments products, you can easily acquire signals from common sensors such as
thermocouples, RTDs, thermistors, strain gauges, dynamic sensors, and LVDTs. You can generate different
analog signals to simulate, for example, the pitch, airspeed, and acceleration in an aircraft. If your application
includes RF outputs from the control unit, you can acquire high-bandwidth frequency signals up to 2.7 GHz using
National Instruments RF products. You can generate digital signals for relays, switches, LEDs and also for
pattern/handshaking I/O. You also can use digital signals for timing applications such as pulse and frequency I/O.
For example, a pulse-width-modulated signal can be used to simulate the signal describing rotor speed. Hardware
for interfacing with the CAN protocol at speeds up to 1 Mb/s is also available in addition to hardware for
RS-232/422/485 protocols. National Instruments also provides a suite of image acquisition and motion control
products with which you can create an extremely powerful HIL system. All National Instruments hardware
products communicate through a common underlying software interface, which facilitates system integration.

The recently introduced National Instruments NI PXI-7831R reconfigurable I/O module considerably enhances the
hardware and software platform for signal generation and acquisition. Because it is based on FPGA technology,
you can configure the board for the specific requirements of the system. The NI PXI-7831R has eight 16-bit A/D
converters with a 4.3 µs conversion time and eight 16-bit D/A converters with a 1.0 µs update time. You can
configure any of the 96 DIO lines as counters, PWM channels, or ports for user-defined digital communication
protocols. Because you configure the NI PXI-7831R at the chip level, you can implement your own triggering logic,
and you can synchronize any analog or digital input or output with any other I/O, all with a resolution of 25 ns. All
this is achieved with the easy-to-use graphical programming interface for measurement and automation, LabVIEW.

For example, having a custom board built containing eighty 16-bit counters would be costly and time-consuming.
The simple LabVIEW program shown below can program one such counter for the NI PXI-7831R. After the
complete program is downloaded to the board, the NI PXI-7831R then functions as a custom-built board containing
80 counters. Such a counter implementation in software running Windows or even a real-time operating system
would not yield the same performance.

Figure 6. LabVIEW FPGA Program for a Simple Counter

HMI and Development

5 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

Certain parameters of the simulation must be displayed, and sometimes modified, in real time as the system
executes. To display the simulation in real time, an HMI becomes very important for the system. Typically the
HMI is a computer that also acts as the development machine for writing the simulation and control code that is
ported to the real-time system. The development machine can be a separate PC or a PXI controller.

On the development side, you must choose the right programming environment to interact with all the hardware in
the system and to enable efficient programming. Such an environment needs to be open to be able to import code
modules from other programs, be modular to be able to reuse code, and most importantly be able to interface with
all the hardware easily. The programming environment needs to have powerful hierarchical modeling capabilities
using extensive domain-specific function libraries. The programming environment should have good error-handling
capabilities and should be able to log data to be analyzed later. Many engineers choose to use the same computer
for both development and HMI.

Figure 7. LabVIEW Human-Machine Interface

LabVIEW provides an excellent HMI and development environment in a single package. It delivers the best way to
acquire, analyze, and present data. With LabVIEW you can quickly build data acquisition, instrumentation, and
control systems, boosting productivity and saving development time. With LabVIEW you quickly create user
interfaces for interactive control of your software system. The tight integration of LabVIEW with measurement
hardware facilitates rapid development of data acquisition and control, analysis, and presentation solutions.

The LabVIEW Simulation Interface Toolkit gives engineers a link between LabVIEW and The MathWorks, Inc.
Simulink® software with which you can import your simulation models from the Simulink environment into
LabVIEW. The LabVIEW Real-Time Module and LabVIEW FPGA Module plug into LabVIEW to provide an
integrated development environment for your entire HIL system. You download your program to the respective
real-time and reconfigurable I/O targets through Ethernet.

6 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

Figure 8. LabVIEW Simulation Interface Toolkit

Control and Simulation Calculations


The signals received from the control unit are, in the real world, fed to the mechanical system that it is controlling.
An important part of simulating a mechanical system is modeling the dynamics of this system, which needs to be
executed on a fast, deterministic, computer-based system so the simulation is as close to the real world as
possible. The speed of the simulation system needs to be equal to or greater than the sampling time of the control
unit. Also, I/O handling, such as decoding pulse-width-modulated signals or custom protocols, and composing
output waveforms or pulse trains, must often be done at much faster rates than the main control loop.

Figure 9. LabVIEW Program on the FPGA

The National Instruments platform provides a complete solution for control and simulation calculations in a variety
of configurations, such as the following:

Nondeterministic Windows-based solution running LabVIEW


Deterministic LabVIEW Real-Time solution
Deterministic, completely reconfigurable LabVIEW FPGA Module solution with enhanced timing and
synchronization between high-speed I/O functions
Any combination of the above

The NI PXI-7831R reconfigurable I/O module coupled with the LabVIEW Real-Time Module running on a dedicated
controller provides an excellent solution for control and simulation calculations. The LabVIEW Real-Time Module
delivers deterministic real-time performance with an easy-to-use Windows-based development environment. You
develop your LabVIEW Real-Time application on a development computer and then download it to a PXI controller
(industrial PC) where it runs on a real-time operating system. Computation-intensive operations can be done on the
real-time target while operations needing better timing and synchronization can be performed on the reconfigurable
I/O device. The LabVIEW Real-Time Module and the LabVIEW FPGA Module provide an effective combination for
your control and simulation calculations.

Postsimulation Report Generation


The data that has been logged by the HMI and development subsystem can be used for analysis to improve

7 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

performance and also to replay the simulation, step by step. National Instruments DIAdem is a configuration-based
software package designed specifically for interactive data analysis, report generation, and data management.
With DIAdem, you can perform powerful analysis on test data without writing programs and inspect the results
using a complete set of visualization tools such as graphs and tables. DIAdem can import data from several file
formats as wells as industry-standard databases such as SQL/ODBC/ADO and ASAM, which are very popular in
HIL applications. With DIAdem you can import data logs from different test configurations and generate reports
using a common template. Moreover, it integrates very well with LabVIEW, making it a very promising solution for
post-simulation report generation for your HIL applications.

Figure 10. DIAdem for Postsimulation Report Generation


NI Leads HIL Success at the Woodward Governor Company

The Woodward Governor Company designs, manufactures, and services energy control systems and components
for aircraft and industrial engines and turbines. Woodward has served the power generation, process industries,
transportation, and aerospace markets since 1870. When they set out to develop a custom engine simulator to
test their new line of 128-pin engine controllers, they chose the National Instruments LabVIEW FPGA Module and
the NI PXI-7831R. With the easy programming environment offered by the LabVIEW FPGA Module, they were able
to program the NI PXI-7831R to accurately synchronize a large number of I/O functions without having to use
custom boards. Said Matthew Viele, senior software engineer at Woodward Governor Company, "This system met
or exceeded our specifications and cost 90 percent less than building our own FPGA board. We enjoyed working
with NI. They have an awesome support team and great documentation."

Engine controllers are electronic units that provide engine and power train control for automobiles. They receive
signals such as transmission speed, crank and cam shaft speed, and throttle position. This information is
processed by the module to generate signals to control engine and power train parameters.

To test these engine controllers, the engineers at Woodward need to simulate and monitor various driving
conditions accurately. For a simulation like this, the controller has to think that it is receiving actual signals from
the vehicle. These include synchronous signals at about 24 kHz for measurements such as knock, spark, engine
position sensors, fuel injectors, and manifold pressure. Asynchronous signals at 200 Hz include switches,
temperatures, foot pedal, throttle, and vehicle speed.

Fault testing and regression testing are the two main goals of the simulation at Woodward. Fault testing includes
checking knock, overspeed, and excess temperatures. Failure on any of these would damage the engine
completely. Regression testing ensures the robustness of the platform. Engineers at Woodward need to make sure
that any change made to the controller for one engine does not break any of the engines previously released.

The following list is the main components of the simulation system put together by Woodward:

Engine controller under test


LabVIEW with Real-Time Module and FPGA Module
2 NI PXI-7831R reconfigurable I/O modules
NI PXI-8176 RT high-performance real-time controller with 512 MB RAM
NI PXI-1042 8-slot chassis
Cables and connector blocks

8 of 9 Sunday 07 November 2010 11:23 AM


LabVIEW FPGA in Hardware-in-the-Loop Simulati... http://zone.ni.com/devzone/cda/tut/p/id/3567

Because the system runs at very high speeds, accurate synchronization between the many I/O functions becomes
very important. The NI PXI-7831R outputs a variable reluctance sensor signal to the controller among many
others. It also verifies that the controller turned the fuel injector on and off at the right time and with the correct
current profile. The simulation system sends such engine and power train signals to the controller. Some sets of
signals sent include a knock signal in the system. The controller then detects whether a knock signal is present
based on the parameters received. Outputs from the controller are then monitored to detect if the controller
detected the knock correctly.

The LabVIEW FPGA Module-based system provides Woodward with significant advantages over developing a
custom board for accurate and synchronized waveform generation and acquisition. Not only did the complete
solution cost less, but also it had a very easy learning curve for development with the LabVIEW graphical
programming environment.

Conclusion

With the power and flexibility of today’s computers, engineers and scientists are increasingly using PC-based
systems for HIL simulation applications. A key element of the development of such a system is the integration of
signal generation/acquisition I/O functions with the software used to simulate the system. The main challenge for
HIL simulation applications is synchronization of a very large number of such I/O functions at high speeds and the
rapid conversion of signal data to and from information for inputs and outputs respectively. Because this is a
critical part of any such application, engineers and scientists develop custom boards for this purpose, involving
circuit design and complex VHDL programming, which is not only expensive but is very time-consuming.

National Instruments products empower engineers and scientists with an innovative, modular, cost-effective
hardware and software platform for HIL simulation applications. With the recently introduced LabVIEW FPGA
Module and the NI PXI-7831R reconfigurable I/O module, you can now achieve better synchronization at high
speeds for a large number of I/O functions. You can now develop your own solutions for challenging design
problems without learning complex hardware and software programming. A system developed using the LabVIEW
FPGA Module and the NI PXI-7831R not only saves development time, but also is very cost-effective. Combined
with a suite of products spanning data acquisition, GPIB, motion, vision, and data management, National
Instruments provides a wide variety of off-the-shelf components for you to use in developing your own HIL
simulation applications.

Simulink® is a registered trademark of The MathWorks, Inc.

Reader Comments | Submit a comment »

pdf
pdf-file has a very good quality, much better than screen
- David Dyntar, ETH Zurich. dyntar@imrt.mavt.ethz.ch - Oct 18, 2004

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial
may be made available by National Instruments, the content in this tutorial may not be completely tested and
verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each
new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S
TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/ ).

My Profile | RSS | Privacy | Legal | Contact NI © 2010 National Instruments Corporation. All rights reserved. | E-Mail this Page

9 of 9 Sunday 07 November 2010 11:23 AM

You might also like