Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Jul 22, 2008


Feedback


Yes No

Related Links - Developer Zone

Related Links - Products and Services

Using LabVIEW for Rapid Control Prototyping and Hardware-in-the-Loop Simulation

9 ratings | 4.89 out of 5
Read in | Print | PDF

Overview

This paper discusses how you can accelerate the development of model-based control systems using the techniques of rapid control prototyping and hardware-in-the-loop (HIL) testing with the National Instruments hardware and software.

Product Development Process

Figure 1 illustrates the embedded control "V Diagram" often used to describe the development cycle. Originally developed to encapsulate the design process of many different software applications, several versions of this diagram can be found to describe a variety of product design cycles. Here we have shown one example of such a diagram representing the design cycle of embedded control applications common to automotive, aerospace, and defense applications.



The goal of rapid development is to make this cycle as efficient as possible by minimizing the iterations required for a design. If the x-axis of the diagram is thought of as time, the goal is to narrow the "V" as much as possible by drawing the two legs of the diagram closer, thereby reducing development time. By using the NI platform, you can accelerate the rapid prototyping and HIL phase but we will do a quick review of the modeling and design stage of the V.

Modeling and Design

A key component of shrinking the "V" through model-based design is to begin developing the embedded control as early in the design cycle as possible. Modeling provides the ability to begin simulating control behavior while hardware prototypes are still unavailable. In addition, models from previous designs may be reused to further reduce the effort necessary to produce a model. If prototype or existing hardware is available, the modeling effort may be complemented by using real-world input/output data to produce models with system identification techniques with tools such as the NI LabVIEW System Identification Toolkit.

Software tools such as LabVIEW or MATRIXx offer a variety of advanced control design tools in an interactive environment that helps the designer quickly evaluate a control system without the need for prototype hardware. This capability provides the design engineer with the ability to determine specification, requirements, and modeling errors immediately instead of waiting for testing later in the design flow.

Engineers use various tools to model and design control systems. With the NI LabVIEW Control Design Toolkit, you use graphical tools to design and analyze control systems. The NI LabVIEW Simulation Module integrates dynamic system simulation into the LabVIEW environment. You can model linear, nonlinear, discrete, and continuous plant or control systems in block diagram form within the simulation node, then execute the simulation on Windows or real-time hardware.

The NI MATRIXx product family is an entire control design suite of software that includes SystemBuild, an easy-to-use graphical environment for rapid model development and simulation. SystemBuild is an excellent environment for the development and management of large, complex models.

In addition to the National Instruments modeling and design software tools, the NI platform is open to integrate models and code that have been created with other software, including models developed in The MathWorks, Inc. Simulink® software environment, MSC CarSim, as well as hand-coded models developed in C, Fortran, etc. Because of the open architecture of NI software and hardware, you can instrument models from almost any software.

Connecting LabVIEW and the Simulink Software


The LabVIEW Simulation Interface Toolkit is used to interface with the Simulink environment. In addition, the toolkit adds patented user interface tools for viewing and controlling data in the Simulink environment. Users of the Simulink software can use LabVIEW to perform offline simulations on a desktop or download the dynamic model to a real-time system for rapid control prototyping or HIL testing.

To achieve real-time implementation, The MathWorks, Inc. Real-Time Workshop® software is used with added components from the simulation interface toolkit to generate code from the model that can then be executed in real-time.
The LabVIEW Simulation Interface Toolkit brings the vast suite of user interface functionality of LabVIEW to instrument simulation models. You can use all of the LabVIEW visualization controls and indicators, such as knobs, sliders, graphs, charts, buttons, and LEDs to create your custom front panel.

Creating LabVIEW User Interfaces for Simulation Models

To prepare the model for connection, you simply place the NI Signal Probe block onto the simulation diagram. This NI Signal Probe block is available in the Simulink environment after installing the LabVIEW Simulation Interface Toolkit. Using the SIT Connection Manager, you can then create mappings from the LabVIEW controls and indicators to any signal or parameters of the model.


[+] Enlarge Image



When you have finished the mappings, LabVIEW automatically generates code that establishes the connection from the LabVIEW VI to the model. You can modify the parameters and view the simulation signals as they execute.

Click here for a multimedia demonstration of creating a user interface for a Simulation model

Real-Time Software


After performing software simulation, you can move to real-time implementation of the model. National Instruments has extensive real-time software and hardware that is well suited for deterministic execution of a model and interfacing to a wide range of I/O.

The LabVIEW Real-Time Module extends LabVIEW to be able to target off-the-shelf real-time targets. With LabVIEW Real-Time, LabVIEW code can be made to execute with hard real-time performance with cycle times in the hundreds of microseconds and low jitter. With the LabVIEW FPGA Module, you can create custom HIL devices that generate quickly changing signals such as those from crankshafts, camshafts, and displacement transducers such as LVDTs. Using FPGAs you can also acquire signals and perform onboard processing to modulate PWM signals, decode custom digital protocols, and decimate analog signals.

Real-Time Hardware


National Instruments recommends several platforms for HIL and RCP applications depending on I/O and processing requirements of the application. The National Instruments PXI platform, a high-performance system designed for test and measurement, is ideal for HIL applications. A standard PC can also be used as a real-time target. This solution can be used in the research lab for controllers that use a low number of I/O channels. CompactRIO is a versatile platform that is perfect for control prototyping.


[+] Enlarge Image

LabVIEW Real-Time
PXI
Desktop of Industrial PC
CompactRIO

Rapid Control Prototyping on CompactRIO

Because software simulations cannot account for all of the unique behaviors of an actual dynamic environment, a hardware prototype is developed to aid in the testing of the control algorithm in real time. This rapid control prototyping is the second stage of the control design V diagram. As shown in the figure, the controller design is tested in a real-time environment and connected to the real or simulated plant. This step provides excellent verification and validation feedback on the fidelity of the modeling effort and the resulting control design early in the design flow. Further refinements to the controller and hardware designs and requirements can be made prior to finishing the design of the production systems.


[+] Enlarge Image


You can use any of the NI real-time hardware platforms to implement a prototype; however, CompactRIO is ideally suited due to its packaging, ruggedness, and flexibility. The CompactRIO embedded system includes a real-time processor that can execute control algorithms deterministically, perform data logging, serve up Web pages, etc. CompactRIO also has integrated in the chassis an FPGA, which provides the flexibility and performance for high-speed signal acquisition and generation. With CompactRIO you can interface with real-world signals such as analog, digital, CAN, PWM, MIL-STD-1553, and ARINC-429 using off-the-shelf modules.

Read this customer solution to learn how Drivven Inc. saved 21 man-months of engineering time using CompactRIO for prototyping a motorcycle ECU.

Real-Time Implementation of Control Models Developed in the Simulink Environment
Using Real-Time Workshop and the Microsoft Visual Studio compiler, a model developed in the Simulink environment can be used to automatically generate a DLL that can be called by LabVIEW.


[+] Enlarge Image



Using the SIT Connection Manager, you can then easily configure the real-world IO that will be the inputs and outputs of the simulation model. You can configure NI data acquisition devices, FPGA devices, and CAN devices through this interface. LabVIEW then generates the code that instruments the model with I/O acquisition and generation code that interfaces to the plant.

When executing the LabVIEW VI, the code automatically gets downloaded to the real-time hardware for deterministic execution of the model. The operator interface is updated through an Ethernet connection from the target to the host. Let's see a demonstration of this process.

Click here to see an online demonstration of implementing simulation models in real-time with LabVIEW

Targeting

Following this stage, the controller is implemented on target hardware that can be an electronic control unit (ECU), a commercial-off-the-shelf controller and chassis system such as PXI and CompactRIO, or custom hardware. Engineers can hand code the target software based on the controller model, use automatic code generation tools such as LabVIEW Embedded, or use a combination of both to arrive at the target implementation.

HIL Testing with PXI


In HIL testing, the designer can simulate real-time behavior and characteristics of the final system to verify the production system controller without the need for the physical hardware or operational environment. As seen in the figure, the control code is running on the target controller hardware while the plant is simulated in real time on a test computer.


[+] Enlarge Image



During this testing phase, it is important to test the complete functionality of the controller. While you can connect the target hardware with the actual plant, testing against a simulated plant such as an engine offers several advantages. An HIL tester is far more cost-efficient and easier to reproduce than a physical engine. The simulated engine also can simulate a variety of operating conditions or even fault conditions, such as engine stall, that would be difficult, costly, and/or dangerous with the actual plant.

PXI is an ideal platform for HIL systems. PXI is based on the CompactPCI standard. A typical system consists of a chassis, controller, and your choice of I/O modules. The controller includes a processor, permanent storage, memory, etc. When used as a real-time system, the LabVIEW application is downloaded to the embedded processor on the controller. As the application runs, it accesses data from the I/O modules in the system. PXI offers high performance and the ability to scale to many channels in the hundreds or even thousands.

There is an extensive range of I/O available for PXI systems including analog and digital I/O, CAN, PWM, dynamic signals, motion control, image acquisition, and third-party modules. As with the CompactRIO platform, you can use FPGA modules and program them with LabVIEW for ultimate customization. PXI systems also integrate well with the standard buses needed for HIL systems, such as CAN, Ethernet, MIL-STD 1553, and ARINC 429. Because PXI is an open architecture, custom or third-party PXI or cPCI modules can easily be integrated in a PXI system as well.

HIL Simulation Architecture

An HIL system can have several components within it. The main part is the plant model simulation, which executes in real-time and simulates the dynamic characteristics of the plant. I/O modules are used to receive the controller outputs and respond with simulated signals from the plant back to the controller.


[+] Enlarge Image



With FPGA you can create custom IO to suit the particular needs of the simulation. Other components of an HIL system can include test data logging as well as sequencing of test vectors. To complete the system, a host PC with an operator interface, a test automation interface such as NI TestStand, and tools for post processing such as DIAdem are used.



Click here to learn how Micronova created an innovative HIL solution based on FPGAs for a 12 cylinder fuel injector simulator.

National Instruments Partners


One of the advantages of the National Instruments approach is the focus on technologically advanced products. Using our extensive network of Alliance Partners and select integrators, NI and partners can provide full solutions for RCP and HIL needs. Examples of partners that specialize in HIL and RCP include MicroNova, Wineman Technologies, Averna, and KGC.

Furthermore, NI continually develops product partnerships to provide customers with an open and flexible solution. Examples of partners include MSC CarSim and TESIS DYNAware, providers of vehicle dynamics modeling tools; and manufacturers of bus interfaces such as Condor Engineering.

LabVIEW Platform Advantages


LabVIEW provides an open platform for your dynamic system control design and testing needs. Using the NI platform you can use your choice of design software with scalable, modular hardware platforms to implement model-based designs in real-time.

For a demonstration of LabVIEW or to request a visit from your local field engineer contact National Instruments at (800) 433-3488.

Simulink® and Real-Time Workshop® are registered trademarks of The MathWorks, Inc.

9 ratings | 4.89 out of 5
Read in | Print | PDF

Reader Comments | Submit a comment »

It is desirable to have a demonstration example for PCI-7831R
- Konstantin, SPbGTURP. crkt@gturp.spb.ru - Nov 2, 2006

 

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/).