1. Introduction: Three Steps for Building an NI Real-Time System
To build an NI real-time system, you need to choose two major components: your development software and hardware platform. Detailed information on the options for each of these components is provided in the following sections. Before reading this paper, it is useful to have a basic understanding of what a real-time system is, and how building a real-time system can benefit your projects. For a review of this information, read the paper: Do I Need a Real-Time System?
Note that when building any real-time system in general, you typically must select a real-time capable operating system. National Instruments real-time development tools come packaged with all necessary real-time OS (RTOS) software, meaning that you do not need to choose this component separately. Depending on the hardware platform that you download and run your real-time programs on, National Instruments automatically uses the NI Linux Real-Time RTOS or RTOS software based on the Wind River VxWorks, or Phar Lap ETS operating systems.
2. Choose an NI Development Environment and Optional Debugging Tools
Development Option: LabVIEW Real-Time Graphical Programming
To program NI supported real-time hardware using graphical programming, you must purchase LabVIEW along with the LabVIEW Real-Time Module. The LabVIEW Real-Time Module allows you to create reliable, hard real-time applications, download them to your hardware, and then debug and run them using just one tool.
You can use most of the built-in math and signal processing algorithms that come with LabVIEW in your real-time applications, and popular PID control functions are also included. In addition, you can run textual math scripts on your real-time system with the optional LabVIEW MathScript RT Module, or integrate models that you create in The MathWorks, Inc. Simulink ® software or other modeling environments using the optional LabVIEW Model Interface Toolkit.
LabVIEW Real-Time: Developing, Downloading, and Running Applications
When developing real-time applications in LabVIEW, you use the LabVIEW Project Explorer to organize your programs (VIs) and categorize them by the hardware platform that they will run on. Note that you develop your code on a general-purpose Windows host computer, and then connect to your real-time hardware using Ethernet to download and run the application.
Figure 1. Manage LabVIEW programs (VIs) and assign them to real-time hardware using the LabVIEW Project Explorer.
Developing real-time programs in LabVIEW is nearly identical to developing standard LabVIEW applications for your PC. Several additional functions specific to real-time systems are packaged in the Real-Time VIs palette, including:
- Watchdog functions to automatically restart some hardware targets if your program stops running
- Functions to communicate data deterministically between parts of a real-time program
- Utilities to configure load balancing on systems with multiple CPU cores
- Timing functions to precisely control the execution of loops in your real-time programs
To test your LabVIEW Real-Time code on your hardware platform, simply click on the run arrow and your application will automatically be transferred to your real-time hardware via Ethernet and begin running. You can use standard NI debugging tools such as highlight execution, single stepping, and breakpoints from your development system even though your real-time program is actually running on a separate system.
When you have finalized your real-time program, you can build an executable in LabVIEW and download it to your real-time hardware as a startup application. After rebooting your real-time hardware, your program will automatically run in a reliable, stand-alone fashion.
LabVIEW Real-Time: Assigning Priorities to Parallel Code Sections and Multicore Processing
The dataflow programming model of LabVIEW frees you from the sequential architecture of text-based programming languages. Because the execution order is determined by the flow of data between nodes and not by sequential lines of text, you can easily create applications that execute multiple operations in parallel. Additionally, LabVIEW makes it easy to assign thread priorities with the Timed Loop structure. As shown below, each loop can contain a separate task with configurable timing source, period, priority and more.
Figure 2. You can specify the priority and processor assignment of different code sections using the LabVIEW Timed Loop structure.
The LabVIEW Real-Time Module supports multicore processing and automatically maps parallel sections of your code to individual operating system threads - eliminating the need for you to manually create and manage them. By default, these threads are also automatically balanced across the CPUs available on your real-time hardware.
To further increase the performance and reliability of a real-time system, you can choose to manually assign Timed Loops to specific processor cores if desired. For example, you can dedicate one core of a processor to execute one time-critical loop and isolate it from less important tasks that run on different cores.
Development Option: LabWindows/CVI Real-Time Module
If your organization standardizes on ANSI C, you can use the NI LabWindows/CVI development environment to create text-based measurement and control applications that take advantage of NI signal processing algorithms as well as a wide variety of I/O modules. By adding the LabWindows/CVI Real-Time Module, you can develop, download, and run these applications deterministically on certain NI supported real-time hardware targets.
Note that the LabWindows/CVI Real-Time Module supports only the real-time PXI, Industrial Controller, and PC hardware discussed below in this paper. For access to a wider variety of NI real-time hardware targets, consider using the LabVIEW Real-Time Module to develop your applications.
Additional Software Option: Debugging with the Real-Time Execution Trace Toolkit
For advanced multicore debugging, you can use the Real-Time Execution Trace Toolkit to verify the performance of your LabVIEW or LabWindows/CVI real-time programs without halting or pausing execution of the code. With minimal modifications to your real-time code, you can log application performance to a file and send it to a host computer for viewing and analysis. The trace tool viewer graphically displays multithreaded code execution while highlighting thread swaps, mutexes, and memory allocations. You can use the Real-Time Execution Trace Toolkit to optimize application performance by identifying undesirable execution characteristics and difficult-to-find race conditions.
3. Select an NI Hardware Platform and I/O Modules
All NI real-time hardware platforms are based on a common architecture, which means that programs that you write with the LabVIEW Real-Time Module will work across different pieces of NI supported hardware with only minor modifications. Specifically, each hardware platform features off-the-shelf computing components including a microprocessor, RAM, nonvolatile storage, and I/O bus interface. Some hardware platforms even feature an onboard Field Programmable Gate Array (FPGA) that you can program using the LabVIEW FPGA Module.
Each NI real-time platform has distinct characteristics geared toward a particular subset of use cases. Whether you are looking for cutting-edge multicore performance or a compact, rugged form factor, NI real-time hardware can meet your project needs. All NI real-time hardware platforms have the ability to function as autonomous systems.
PXI (PCI Extensions for Instrumentation)
The industry standard PXI platform consists of a rugged chassis with integrated timing and triggering lines, embedded controller, and plug-in I/O modules. Serial, USB, Gigabit Ethernet, and GPIB ports are also built in to the controller. PXI real-time hardware can be programmed using either the LabVIEW Real-Time Module or LabWindows/CVI Real-Time Module.
Do you have an existing PXI controller running Windows that you would like to change to a real-time controller? You can purchase a LabVIEW Real-Time Deployment License to convert your controller, or even set up a dual-boot system.
You can assemble your own PXI real-time system including controller, chassis, I/O modules, and software using the online PXI Advisor.
Figure 3. PXI hardware provides a rugged, high-performance option for your real-time projects.
NI PXI hardware is often used for high-performance real-time systems such as hardware-in-the-loop testing of electronic control units and vibration analysis for machine-condition monitoring applications. When using a real-time PXI system, your applications have access to advanced timing and synchronization hardware features that simplify precise I/O triggering and multi-module synchronization.
CompactRIO (Compact Reconfigurable I/O) and Single-Board RIO (Single-Board Reconfigurable I/O)
NI CompactRIO combines a real-time processor, a Field-Programmable Gate Array (FPGA), and C Series I/O modules. In addition, serial, USB, and Ethernet ports are built in to the controller. When using CompactRIO, your I/O modules are connected to the FPGA for fast processing in hardware, and then you exchange data between the FPGA and real-time processor as desired.
You can assemble your own CompactRIO system including controller, chassis, I/O modules, and software using the online CompactRIO Advisor.
Figure 4. CompactRIO provides a flexible, rugged, and portable option for real-time applications.
You can program the real-time processor on CompactRIO hardware targets using the LabVIEW Real-Time Module. You can also choose to develop code for the onboard FPGA using the LabVIEW FPGA Module, or skip this step and use the NI Scan Engine built into the LabVIEW Real-Time Module to read from your I/O modules.
Figure 5. The LabVIEW RIO architecture features a real-time processor, reconfigurable FPGA, and I/O modules, all programmable in LabVIEW.
CompactRIO hardware is often used for industrial applications including machine condition monitoring, motion control, and data logging. In addition, CompactRIO is ideal for quickly prototyping embedded systems for faster time to market.
NI Single-Board RIO systems are identical in architecture to CompactRIO systems, only in a single circuit board form factor. Single-Board RIO hardware features a real-time processor and programmable FPGA just as with CompactRIO, and several I/O modules are also available in a board-only form factor.
Figure 6. Single-Board RIO hardware features the same architecture as CompactRIO systems, only in a single circuit board form factor.
High-volume applications that require flexibility, reliability, and high performance can benefit from using Single-Board RIO hardware. Use cases include medical device control and monitoring, robotics and unmanned vehicle control, and more.
You can evaluate the LabVIEW Real-Time and LabVIEW FPGA Modules with RIO hardware with the NI LabVIEW RIO Evaluation Kit.
NI CompactDAQ is a rugged, modular data acquisition system that provides sensor and electrical measurements on the benchtop, in the field, and on the production line. The 8 or 4 slot controllers with a built-in real-time OS can connect to a host computer over Ethernet and operate stand-alone, also featuring nonvolatile storage. It varies from CompactRIO in that the I/O modules are not connected to an FPGA.
You can assemble your own CompactDAQ system including controller, chassis, I/O modules, and software using the online CompactDAQ Advisor.
Figure 7. NI CompactDAQ controllers offer a high-performance platform for embedded measurements and data logging.
Real-Time Vision (Smart Camera, Compact Vision System, and Embedded Vision System)
NI offers a range of vision hardware for real-time applications, including the Smart Camera for all-in-one solutions, the Compact Vision System for processing data from multiple cameras, and the high-performance, fanless Embedded Vision System.
NI Smart Cameras combine industrial, high-quality image sensors and real-time power processors that are programmable with the LabVIEW Real-Time Module. You can also purchase the NI Vision Development Module for quick access to hundreds of image processing and machine vision functions. Smart Cameras also feature two optoisolated digital inputs, two optoisolated digital outputs, one RS 232 serial port, and two gigabit Ethernet ports.
Figure 8. NI Smart Cameras feature an onboard real-time processor that can be programmed using the LabVIEW Real-Time Module.
Compact Vision System (CVS) hardware incorporates an embedded real-time processor, Field Programmable Gate Array (FPGA) and connections for three IEEE 1394 DCAM cameras. Compact Vision System controllers also feature a local video display, an Ethernet port, 15 digital inputs, and 14 digital outputs. You can program the onboard real-time processor using the LabVIEW Real-Time Module, and you can choose to customize the FPGA (which communicates with the digital inputs and outputs) if desired using the LabVIEW FPGA Module.
Finally, NI Embedded Vision System hardware provides a rugged, fanless, high-performance option for vision applications. Embedded Vision System controllers feature support for both GigE and IEEE 1394 cameras, and also incorporate 29 DIO lines, serial, USB, and Ethernet connections. You can program the onboard real-time processor using the LabVIEW Real-Time Module, and you can choose to customize the FPGA if desired using the LabVIEW FPGA Module.
NI Vision hardware is ideal for automated inspection of parts, reading 1D and 2D barcodes, reading or verifying text, and even taking heat measurements using an infrared camera. Vision systems can provide an accurate, non-destructive way to take measurements in your project.
Other Hardware Options
NI Industrial Controllers feature a rugged, fanless chassis, high-performance processor, and a single PCI or PCIe slot for I/O modules. Serial, USB, CompactFlash, and Ethernet connections are built into the controller. NI real-time Industrial Controllers can be programmed using either LabVIEW Real-Time or the LabWindows/CVI Real-Time Module.
NI Industrial Controllers are ideal for running reliable real-time applications in harsh environments that prohibit the use of active cooling fans. To connect with a wide variety of sensors and actuators deterministically, Industrial Controller hardware supports EtherCAT and MXIe connections to expansion chassis.
You can convert a standard desktop PC to work with NI Real-Time software, as long as the hardware meets certain system requirements. To do this, you need to purchase a LabVIEW Real-Time Deployment License in addition to your NI real-time development software (LabVIEW Real-Time Module or LabWindows/CVI Real-Time Module).
4. Talk With an NI Representative Today
Still have questions? NI representatives are glad to help you choose the right software, hardware, and I/O for your real-time program - no matter what size your system is. You can also request a demonstration from an engineer in your area, and ask about the training opportunities available in order to get your first NI real-time system up and running in as little time as possible.
>> Call (800) 531-5066 to talk to an NI representative about your application now
Simulink® is a registered trademark of The MathWorks, Inc.