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 real-time systems and how building one can benefit your projects. Review this information by reading 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 OS. NI 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, NI automatically uses the NI Linux Real-Time OS software based on the Wind River VxWorks or Phar Lap ETS OSs.
1. Choose an NI Development Environment and Optional Debugging Tools
Development Option: LabVIEW Real-Time Graphical Programming
To program NI-supported real-time hardware graphically, you must purchase LabVIEW along with the LabVIEW Real-Time Module. LabVIEW Real-Time gives you the ability to create reliable, hard real-time applications; download them to your hardware; and then debug and run them using one tool.
You can use most of the built-in math and signal processing algorithms that come with LabVIEW in your real-time applications; popular proportional integral derivative (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 the run arrow and your application is automatically transferred to your real-time hardware via Ethernet and begins 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 a configurable timing source, period, priority, and more.
Figure 2. Specify the priority and processor assignment of different code sections using the LabVIEW Timed Loop structure.
LabVIEW Real-Time supports multicore processing and automatically maps parallel sections of your code to individual OS threads, which eliminates the need 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 wanted. 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.
Troubleshooting Option: Debugging With the Real-Time Trace Viewer
For advanced multicore debugging, you can use the Real-Time Trace Viewer 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 Trace Viewer to optimize application performance by identifying unwanted execution characteristics and difficult-to-find race conditions. The LabVIEW Real-Time Module 2013 and prior releases packaged the Real-Time Trace Viewer as a separate toolkit (Real-Time Execution Trace Toolkit).
Development Option: LabWindows/CVI Real-Time Module
If your organization standardizes on ANSI C, you can use the 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 LabWindows/CVI Real-Time 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 LabVIEW Real-Time to develop your applications.
2. 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 LabVIEW Real-Time 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 an I/O bus interface. Some hardware platforms even feature an onboard 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 can 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, an embedded controller, and plug-in I/O modules. Serial, USB, Gigabit Ethernet, and GPIB ports are also built into the controller. PXI real-time hardware can be programmed using either LabVIEW Real-Time or LabWindows/CVI Real-Time.
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 multimodule synchronization.
CompactRIO and Single-Board RIO
CompactRIO combines a real-time processor, an FPGA, and C Series I/O modules. In addition, serial, USB, and Ethernet ports are built into 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 wanted.
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 LabVIEW Real-Time. You can also choose to develop code for the onboard FPGA using LabVIEW FPGA, or skip this step and use the NI Scan Engine built into LabVIEW Real-Time 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 a shorter time to market.
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.
Evaluate the LabVIEW Real-Time and LabVIEW FPGA modules with reconfigurable I/O (RIO) hardware with the LabVIEW RIO Evaluation Kit.
CompactDAQ is a rugged, modular DAQ system that provides sensor and electrical measurements on the benchtop, in the field, and on the production line. The 4- or 8-slot controllers with a built-in RTOS can connect to a host computer over Ethernet and operate stand-alone, and also feature 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. 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 LabVIEW Real-Time. You can also purchase the 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 RS232 serial port, and two Gigabit Ethernet ports.
Figure 8. Smart Cameras feature an onboard real-time processor that can be programmed using LabVIEW Real-Time.
Compact Vision System hardware incorporates an embedded real-time processor, 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 LabVIEW Real-Time, and you can customize the FPGA (which communicates with the digital inputs and outputs) using LabVIEW FPGA.
Finally, Embedded Vision System hardware provides a rugged, fanless high-performance option for vision applications. Embedded Vision System controllers feature support for both Gigabit Ethernet and IEEE 1394 cameras, and also incorporate 29 digital I/O lines, serial, USB, and Ethernet connections. You can program the onboard real-time processor using LabVIEW Real-Time, and you can customize the FPGA using LabVIEW FPGA.
NI vision hardware is ideal for automating part inspection, reading 1D and 2D bar codes, reading or verifying text, and even taking heat measurements using an infrared camera. Vision systems can provide an accurate, nondestructive way to take measurements in your project.
Other Hardware Options
NI industrial controllers feature a rugged, fanless chassis; high-performance processor; and single PCI or PCI Express 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 the LabVIEW Real-Time or LabWindows/CVI Real-Time modules.
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 MXI-Express 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 or LabWindows/CVI Real-Time).
3. Speak With an NI Representative Today
Still have questions? NI representatives can help you choose the right software, hardware, and I/O for your real-time program—no matter the size of your system. You can also request a demonstration from an engineer in your area and ask about training opportunities for getting your first NI real-time system up and running in as little time as possible.
Call (800) 531-5066 to speak with an NI representative now.
Simulink® is a registered trademark of The MathWorks, Inc. The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.