Overview
A common challenge for design engineers today is the gap between design and simulation software and real-world I/O platforms. It is not uncommon for users of an environment, such as The MathWorks, Inc. Simulink® software, to want to transfer the behavior described by the software model into a real-time platform, such as those provided by National Instruments. This article examines how to use your models built using Simulink software with National Instruments software and hardware platforms.
Table of Contents
Introduction
There are two possible ways to use your software models built using The MathWorks, Inc. Simulink® software in NI LabVIEW software. The first features a combination of products including the LabVIEW Simulation Interface Toolkit (SIT), The MathWorks, Inc. Real-Time Workshop® software, and a C compiler, typically Visual C, to compile a .DLL file that you can execute inside LabVIEW. The second method involves converting the software model into LabVIEW native code using the Simulation Converter included in the LabVIEW Control Design and Simulation Module.
Both options are shown below using an example model built in Simulink.
Figure 1. Model Created Using The MathWorks, Inc. Simulink® Software
LabVIEW Simulation Interface Toolkit
With the LabVIEW Simulation Interface Toolkit, control system design and test engineers have a link between LabVIEW and Simulink. With the LabVIEW Simulation Interface Toolkit, you can easily build custom LabVIEW user interfaces to view and control your simulation model during run time. This toolkit also provides a plug-in for the Real-Time Workshop to import your models created in the Simulink environment into LabVIEW. With these features, you can connect your model to the real world through a variety of real-time I/O platforms (requires the LabVIEW Real-Time Module). With these capabilities, you can easily take your models from software verification to real-world prototyping and hardware-in-the-loop simulation.
Verify Models with a LabVIEW User Interface
Using the LabVIEW Simulation Interface Toolkit, you can build custom user interfaces for models created in the Simulink environment. The SIT Connection Manager offers a configuration-based utility to connect a custom LabVIEW user interface to your models, eliminating the need for any programming knowledge. You can use the custom user interface to easily simulate, analyze, and verify your control model on a desktop PC.
The LabVIEW Simulation Interface Toolkit also provides a plug-in for Real-Time Workshop that helps facilitate the importation of your models into LabVIEW. When used with LabVIEW Real-Time, this capability helps you connect your models to the real world through a variety of real-time I/O platforms and still provides the user interface capabilities used in the verification of the model.
An example of the code generated using the LabVIEW Simulation Interface Toolkit is shown in Figure 3. Note this is ready-to-run code, so no LabVIEW programming skills are needed. Nonetheless, the code is open for developers to add custom functionality implemented in LabVIEW.
Figure 2. LabVIEW Code Generated Using the LabVIEW Simulation Interface Toolkit
LabVIEW Control Design and Simulation Module
With the LabVIEW Control Design and Simulation Module, you can analyze open-loop model behavior, design closed-loop controllers, simulate online and offline systems, and conduct physical implementations.
With this module, you can create models from first principles using transfer function, state-space, or zero-pole-gain representation. With time and frequency analysis tools, such as time step response or Bode plot, you can interactively analyze open- and closed-loop behavior. Use built-in tools for both multiple input, multiple output (MIMO) and single input, single output (SISO) systems and take advantage of simulation capabilities to verify linear and nonlinear system dynamics. You can also use built-in tools to convert your models developed in Simulink to work with LabVIEW.
Similarly, you can expand LabVIEW Control Design and Simulation Module usability with other NI software tools. For example, you can use the LabVIEW System Identification Toolkit to find empirical models from real plant stimulus-response information and the LabVIEW Statechart Module for event-based control design or event-driven simulation. You can deploy dynamic systems to real-time hardware targets with the LabVIEW Real-Time Module for rapid control prototyping and hardware-in-the-loop applications.
The LabVIEW Control Design and Simulation Module adds dynamic system simulation capabilities to core LabVIEW. Because it is built on top of LabVIEW, it inherits all the functionality such as the advanced math library, multicore support, and I/O connectivity.
The module features the Simulation Converter utility to take a user-built Simulink model file and its associated initialization files and create the corresponding code using native LabVIEW Control Design and Simulation Module calls. Once you have successfully converted the code to LabVIEW, you can integrate it with other LabVIEW tools, such as the LabVIEW Real-Time and LabVIEW FPGA modules.
An example of the output from the Simulation Converter is shown in Figure 3, where the software model created using Simulink software shown in Figure 1 has been translated into LabVIEW.
Figure 3. This software model originally created in Simulink has been translated into LabVIEW.
Once you convert the model into LabVIEW, you can use the wide variety of hardware calls to communicate with physical words through analog I/O, serial, CAN, and so on. You can also deploy code used with this path into real-time targets such as NI CompactRIO or PXI hardware using the LabVIEW Real-Time Module. C code generation using the LabVIEW Microprocessor SDK (Software Development Kit) and the LabVIEW Embedded Module for ARM Microcontrollers is also supported.
Method Comparison
Both methods explored in this article present unique benefits and drawbacks. Using the LabVIEW Simulation Interface Toolkit, you have an easy, configuration-based option that does not require programming. While the method involving the LabVIEW Control Design and Simulation Module involves LabVIEW programming, it uses other benefits of the platform such as multicore support and one single toolchain from design to deployment.
Deploying Control Loops from LabVIEW to Hardware
To deploy to National Instruments real-time systems such as the CompactRIO, the software requirements are to have LabVIEW, LabVIEW Real-Time, and LabVIEW Control Design and Simulation Module. To perform deployment, it is required that you create a LabVIEW project with the real-time hardware as the target. The control loop VI must be included underneath the hardware target in your LabVIEW project.
Please note that you should use fixed-step solvers rather than variable-step sized solvers for real-time targets. Fixed-step solvers are less computationally intensive and also allow for better integration of hardware I/O which normally execute at fixed time steps.
Review the LabVIEW Help for the specifics of implementing this process, including the links in the Help References section below.
Conclusion
Simulink users can take advantage of two different paths to close the gap between computer-based software simulation and real-world deployment. With the LabVIEW Simulation Interface Toolkit, you can compile the .MDL files into a .DLL that can be called from LabVIEW. The other path involves using the Simulation Translator to convert your Simulink models into LabVIEW Control Design and Simulation models and leverage both NI hardware and software.
Help References
LabVIEW 2009 Real-Time Module Help: Adding RT Targets to a LabVIEW Project (RT Module)
LabVIEW 2009 Real-Time Module Help: Creating a LabVIEW Project with the Project Explorer Window (RT Module)
LabVIEW 2009 Real-Time Module Help: Building a Stand-Alone Real-Time Application (RT Module)
LabVIEW 2009 Control Design and Simulation Module Help: Considerations for Embedded Targets (Control Design and Simulation Module)
LabVIEW 2009 Simulation Interface Toolkit Help
Simulink® and Real-Time Workshop® are registered trademarks of The MathWorks, Inc. Other product and company names listed are trademarks or trade names of their respective companies.
Reader Comments | Submit a comment »
The pictures are too small. I cannot get
any information from them even when
they are enlarged. I still have no idea at
all on how to deploy the model to my
real-time target after reading your
explaination.
- Jialin Su, Kingston University. J.Su@kingston.ac.uk - Aug 14, 2008
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/).



