CompactRIO Architecture Brochure
OVERVIEW AND BACKGROUND
This guide provides best practices for designing NI CompactRIO control and monitoring applications using NI LabVIEW system design software along with the LabVIEW Real-Time and LabVIEW FPGA modules. Controllers based on these modules are used in applications ranging from the control of particle accelerators like the CERN Large Hadron Collider, to hardware-in-the-loop testing for engine electronic control units (ECUs), to adaptive control for oil well drilling, to high-speed vibration monitoring for predictive maintenance. This guide provides tips for developing CompactRIO applications that are readable, maintainable, scalable, and optimized for performance and reliability.
CompactRIO is a rugged, reconfigurable embedded system containing three components: a processor running a real-time operating system (RTOS), a reconfigurable field-programmable gate array (FPGA), and interchangeable industrial I/O modules. The real-time processor offers reliable, predictable behavior and excels at floating-point math and analysis, while the FPGA excels at smaller tasks that require high-speed logic and precise timing. Often CompactRIO applications incorporate a human machine interface (HMI), which provides the operator with a graphical user interface
(GUI) for monitoring the system’s state and setting operating parameters.
Figure 1. Reconfigurable Embedded System Architecture
LabVIEW is a graphical programming environment used by millions of engineers and scientists to develop sophisticated control systems using graphical icons and wires that resemble a flowchart. It offers integration with thousands of hardware devices and provides hundreds of built-in libraries for advanced control, analysis, and data visualization—all for creating user-defined systems more quickly. The LabVIEW platform is scalable across multiple targets and OSs, and, in the case of CompactRIO, LabVIEW can be used to access and integrate all of the components of the reconfigurable
I/O (RIO) architecture.
The real-time controller contains a processor that reliably and deterministically executes LabVIEW Real-Time applications and offers multirate control, execution tracing, onboard data logging, and communication with peripherals. Additional options include redundant 9 to 30 VDC supply inputs, a real-time clock, hardware watchdog timers, dual Ethernet ports, up to 2 GB of data storage, and built-in USB and RS232 support.
Figure 2. NI cRIO-9014 Real-Time Controller
Real-Time Operating System (RTOS)
A RTOS is able to reliably execute programs with specific timing requirements, which is important for many science and engineering projects. The key component needed to build a real-time system is a special RTOS; other hardware and software pieces that make up an entire real-time system are discussed in the next section.
For many engineers and scientists, running a measurement or control program on a standard PC with a generalpurpose OS installed (such as Windows) is unacceptable. At any time, the OS might delay execution of a user program for many reasons: running a virus scan, updating graphics, performing system background tasks, and so on.
For programs that need to run at a certain rate without interruption (for example, a cruise control system), this delay can cause system failure.
Note that this behavior is by design—general-purpose OSs are optimized to run many processes and applications at the same time and provide other features like rich user interface graphics. In contrast, real-time OSs are designed to run a single program with precise timing. Specifically, real-time OSs help you implement the following:
Perform tasks within a guaranteed worst-case timeframe
Carefully prioritize different sections of your program
Run loops with nearly the same timing on each iteration (typically within microseconds)
Detect if a loop missed its timing goal
In addition to offering precise timing, RTOSs can be set up to run reliably for days, months, or years without stopping.
This is important not only for engineers building systems that need 24/7 operation but also for any application where downtime is costly. A “watchdog” feature is also typically included in real-time systems to automatically restart an
entire computer if the user program stops running. Furthermore, hardware used in a real-time system is often designed to be rugged to sustain harsh conditions for long periods.
The reconfigurable FPGA chassis is the center of the embedded system architecture. The RIO FPGA is directly connected to the I/O for high-performance access to the I/O circuitry of each module and timing, triggering, and synchronization. Because each module is connected directly to the FPGA rather than through a bus, you experience almost no control latency for system response compared to other controller architectures. By default, this FPGA automatically communicates with I/O modules and provides deterministic I/O to the real-time processor. Out of the box, the FPGA enables programs on the real-time controller to access I/O with less than 500 ns of jitter between loops. You can also directly program this FPGA to further customize the system. Because of the FPGA speed, this chassis is frequently used to create controller systems that incorporate high-speed buffered I/O, fast control loops, or custom signal filtering. For instance, using the FPGA, a single chassis can execute more than 20 analog proportional integral derivative (PID) control loops simultaneously at a rate of 100 kHz. Additionally, because the FPGA runs all code in hardware, it provides the highest reliability and determinism, which is ideal for hardware-based interlocks, custom timing and triggering, or eliminating the custom circuitry normally required with nonstandard sensors and buses. For an overview of FPGA technology, see Chapter 5: Customizing Hardware Through LabVIEW FPGA .
Figure 3. Reconfigurable FPGA Chassis
I/O modules contain isolation, conversion circuitry, signal conditioning, and built-in connectivity for direct connection to industrial sensors/actuators. By offering a variety of wiring options and integrating the connector junction box into the modules, the CompactRIO system significantly reduces space requirements and field-wiring costs. You can choose from more than 50 NI C Series I/O modules for CompactRIO to connect to almost any sensor or actuator.
Module types include thermocouple inputs; ±10 V simultaneous sampling, 24-bit analog I/O; 24 V industrial digital I/O with up to 1 A current drive; differential/TTL digital inputs; 24-bit IEPE accelerometer inputs; strain measurements;
RTD measurements; analog outputs; power measurements; controller area network (CAN) connectivity; and secure digital (SD) cards for logging. Additionally, you can build your own modules or purchase modules from third-party vendors. With the NI cRIO-9951 CompactRIO Module Development Kit, you can develop custom modules to meet application-specific needs. The kit provides access to the low-level electrical CompactRIO embedded system architecture for designing specialized I/O, communication, and control modules. It includes LabVIEW FPGA libraries to interface with your custom module circuitry.
Figure 4. You can choose from more than 50 NI C Series I/O modules for CompactRIO to connect to almost any sensor or actuator.
The simplest embedded system consists of a single controller running in a “headless” configuration. This configuration is used in applications that do not need an HMI except for maintenance or diagnostic purposes.
However, a majority of control and monitoring applications requires an HMI to display data to the operator or to allow the operator to send commands to the embedded system. A common configuration is 1:1, or 1 host to 1 target, as shown in Figure 5. The HMI communicates to the CompactRIO hardware over Ethernet through either a direct connection, hub, or wireless router.
Figure 5. A 1:1 (1 Host to 1 Target) Configuration
The next level of system capability and complexity is either a 1:N (1 host to N targets) or N:1 (N hosts to 1 target configuration). The host is typically either a desktop PC or an industrial touch panel device. The 1:N configuration, shown in Figure 6, is typical for systems controlled by a local operator. The N:1 configuration is common when multiple operators use an HMI to check on the system state from different locations.
Figure 6. A 1:N (1 host to N targets) configuration is common for systems controlled by a local operator.
Complex machine control applications may have an N:N configuration with many controllers and HMIs (Figure 7).
They often involve a high-end server that acts as a data-logging and forwarding engine. This system configuration works for physically large or complex machines. Using it, you can interact with the machine from various locations or distribute specific monitoring and control responsibilities among a group of operators.
Figure 7. A Distributed Machine Control System
This guide walks through recommended implementations for a variety of FPGA, controller, and HMI architecture components. It also offers example code and, in some cases, alternative implementations and the trade-offs between implementations.
DESIGNING A COMPACTRIO
Almost all CompactRIO systems have a minimum of three top-level VIs executing asynchronously across three different targets: the FPGA, the real-time operating system (RTOS), and a host PC. If you begin your software development without having some sort of architecture or flowchart to refer to, you may find keeping track of all of the software components and communication paths to be challenging. Having a diagram that describes all of the system pieces at a high level helps guide development and communication about the design with stakeholders. This section describes several common CompactRIO architectures that you can use as a starting point for many applications. You also can use them as a guide for creating your own architecture.
The example architectures in the following sections were created using a vector-based drawing program called the yEd Graph Editor, which is a free design tool downloadable from yworks.com
CompactRIO Reference Architectures
A CompactRIO system architecture or diagram should provide a basic overview of the system. A basic diagram includes processes and data communication paths. A process, as discussed in this guide, is an independent, asynchronously executing segment of code—basically a loop. The architectures referenced in this guide include processes represented by yellow boxes, the hardware targets that the processes execute on represented by blue boxes, and data communication paths represented by black arrows.
Figure 1.1. Basic Components of a CompactRIO Architecture
The first step in identifying the processes that your application contains is to create a list of tasks that your application needs to accomplish. Common tasks include PID control, data logging, communication to an HMI, communication to I/O, and safety logic or fault handling. The next step is deciding how the tasks are divided into processes. An application with a large number of processes requires more time to be spent on interprocess data communication. At the same time, breaking your tasks into individual processes makes your program more scalable.
For example, you might have a real-time application during the first phase of a project that is communicating across the network to a user interface (UI) built with LabVIEW, but later on the application needs to communicate to a web browser. If you separate the network communication task from other tasks within the application, you can redesign
your network communication process without impacting your control process. More information on designing processes in LabVIEW Real-Time can be found in Chapter 3: Designing a LabVIEW Real-Time Application .
Once you’ve diagrammed your processes, the next step is to identify data communication paths. Data communication is one of the most important factors to consider when designing an embedded system. LabVIEW,
LabVIEW Real-Time, and LabVIEW FPGA include many different mechanisms for transferring data between processes on a single target as well as processes that communicate across targets.
Figure 1.2. Data communication is one of the most important factors when designing an embedded system.
Choosing a data communication mechanism depends on several factors, with the primary factor being the data communication model. Most CompactRIO applications can contain at least two or more of the data communication models listed below:
Current values (tags)
Each model has different data transfer requirements. These models apply to both interprocess communication and intertarget communication. Later chapters refer to these data communication types when recommending LabVIEW mechanisms for data transfer between processes on a Windows target, real-time target, or FPGA target in addition to communication between the CompactRIO device and a host PC.
Command- or message-based communication is something that happens relatively infrequently and is triggered by some specific event. An example is a user pushing a button on an HMI to stop a conveyor belt. In message-based communication, it is important to guarantee delivery of the message in a timely manner or with low latency. In the previous example, when the operator pushes the stop button, the operator expects an immediate response (a human’s perception of “immediate” is on the order of tenths of a second). It is often desirable to synchronize a process to the incoming message or command to conserve processor resources. This involves blocking until a message is received or a timeout occurs.
Current Values (Tags)
Tags are used to communicate current values periodically between processes, or from a controller to an HMI. Tags are commonly used to represent process variables, such as a setpoint for a control system or current temperature data. Often tags are bound to I/O channels within a high-channel-count system such as a machine controller. With current value data or tags, each data transmission does not need to be guaranteed because the controller or HMI is always interested in the latest value, not in historical values. It is often desirable to have features that you can use to look up tags dynamically and manage different groups since tags are usually associated with high-channel counts.
Streaming or buffered communication involves the high-throughput transfer of every data point, where throughput is more important than latency. Typically, one process writes data to another process that reads, displays, or processes that data. An example is an in-vehicle data logger that sends data from the FPGA to the RTOS for data logging.
Streaming often requires multilayer buffering, during which each end (the sender and the receiver) has its own uniquely sized buffer. This is ideal when you have a processor loop that wants to read large chunks of data at a time and a data acquisition loop that writes smaller chunks of data at shorter intervals.
Updates are like a combination of tags and messages. Instead of periodically polling the current value like you would with a tag, you want to wait until the value changes. For example, if you are monitoring the heartbeat of another device on the network, you only are interested in knowing when the value of the heartbeat (dead or alive) changes. It is often desirable to have broadcasting capabilities when dealing with updates.
A summary of the different types of data communication models and their features is shown in Table 1.1. Keep these features in mind when selecting a data communication model.
Current Value Data (tags)
Buffering, blocking (timeout)
Nonhistorical, blocking (timeout)
Buffering, blocking (timeout)
Acknowledgment of data transfer
Dynamic tag lookup, group management
Table 1.1. Summary of Data Communication Models
Low latency, high-channel count
Typical CompactRIO Architecture
Figure 1.3 shows a common architecture that you can use as a starting point for most control and monitoring applications. The host VI provides an event-based user interface so an operator can interact with the embedded system. The RTOS executes high-level control and the FPGA executes low-level control.
There are two network communication paths: one path for sending commands from the user interface to the
CompactRIO hardware and a second path for sending tags (current value data) from the CompactRIO hardware to the user interface for display. To build a scalable application, you should design your system so that it has a single command parser task that you can use to interpret and redistribute the command as needed. This ensures that ongoing critical tasks are not disturbed by the arrival of the command and makes it easy to modify the code to handle additional commands.
Figure 1.3. Common Software Architecture Control and Monitoring Applications
On the RTOS_Main.vi, the communication task and control task are designed as two separate loops. This is generally a good practice since the network communication could impact the determinism of the control algorithm if the tasks are executed within a single loop. Also, the modularity makes it easier to simulate parts of the system. For example, you could easily swap out the actual control loop with a simulated control loop to test the network communication.
Common Variant Architectures
The control and monitoring architecture is a great starting point for most applications, but if you want to design an embedded data logger, an embedded monitoring system, or a supervisory control and data acquisition (SCADA) system, you can leverage the more application-specific architectures in the following sections.
Headless Data Logger
A headless CompactRIO system does not require a user interface running on a remote machine. In the case of a headless data logger, the remote machine might be used for retrieving files that contain logged data from the FTP server. In this architecture, the FPGA is performing low-level control while acquiring data from NI C Series I/O modules at a high speed. This data is streamed from the FPGA to the RTOS, where it can be logged to the onboard memory. The FPGA communication process is separate from the logging engine processes to maximize the rate at which data is read.
Figure 1.4. Headless Data Logger Architecture
Embedded monitoring applications typically require data to be streamed at high rates from the C Series I/O modules up to a host user interface where the data is displayed to an operator. The user interface also allows the operator to configure the hardware, requiring a mechanism for sending commands from the host down to the RTOS.
Figure 1.5. Embedded Monitoring Architecture
Supervisory Control and Data Acquisition (SCADA) Architecture
In a typical SCADA application, the CompactRIO device communicates I/O channels as tags to a supervisor. Some control might be implemented on either the FPGA or RTOS. Often you can use the RIO Scan Interface to handle I/O for these types of applications since they do not require high-speed data acquisition rates or customized hardware.
The NI Scan Engine is discussed in Chapter 2: Choosing a CompactRIO Programming Mode . With the LabVIEW
Datalogging and Supervisory Control (DSC) Module, you can extend the software capabilities of a SCADA system to include the ability to log data to a historical database, set alarms, and manage events. LabVIEW DSC also features support for commonly used industrial protocols including OLE for process control (OPC), so LabVIEW can communicate to third-party programmable logic controllers (PLCs).
Figure 1.6. SCADA Architecture
LabVIEW example code is provided for this section.
An example of a bioreactor control system demonstrates how the control and monitoring architecture in Figure 1.6 could apply to an actual application. A bioreactor is a mechanical vessel in which organisms are cultivated and materials are transformed through chemical reactions. The vessel’s environmental conditions like gas, flow rates, temperature, pH levels, and agitation speed need to be closely monitored and controlled. A diagram of a basic bioreactor is shown in Figure 1.7.
Figure 1.7. Example of a Simplified Bioreactor System
The bioreactor control system has the following software requirements:
Control of the pH level, temperature, and agitator speed
UI that allows the operator to do the following:
Define the setpoint of the temperature, pH level, and agitator speed
Define and run recipes
Abort a running recipe and override recipe setpoints
Monitor current pH level and temperature
Table 1.2 is an example of a recipe:
Temp 35 °C pH 1.5
Time: 5 minutes
Temp 40 °C pH 1.2
Time: 2 minutes
Temp 38 °C pH 1.2
Time: 5 minutes
Table 1.2. Example Recipe for Bioreactor Application
To create an architecture for the bioreactor system, start with the control and monitoring architecture shown in
Figure 1.8. Common Software Architecture Control and Monitoring Applications
Since this application interfaces to single-point I/O and does not require update rates faster than 500 Hz, the I/O was implemented using the RIO Scan Interface. The RIO Scan Interface, included in the LabVIEW Real-Time Engine, helps you access your I/O channels as variables within the LabVIEW Real-Time development environment. Find more information on using the RIO Scan Interface versus LabVIEW FPGA in Chapter 2: Choosing a CompactRIO
Programming Mode .
Figure 1.9 shows an example of a design diagram for the bioreactor application. Data communication mechanisms are labeled on each arrow. The following process components were reused from the example control and monitoring architecture in Figure 1.8:
UI Update—Receives the latest pH and temperature values as network-published I/O variables (IOVs) from the
RIO Scan Interface and displays them to a user interface.
UI Event Handler—Uses an event structure to handle user events, such as Run Recipe or Temperature
Command Sender—Sends any commands received from the UI Event Handler to the CompactRIO controller using network streams.
Command Parser—Receives commands from the Command Sender process and sends them to the Recipe
Engine process using queues (Q). It sends override commands to the control task using single-process shared variables (SP-SV). Queues are not used because they impact control-loop synchronization.
Control Task—Controls the pH and temperature using a PID algorithm; is executed at a higher priority than other processes on the real-time system.
The following processes were added:
Recipe Engine—Manages and executes incoming recipes. It shares recipe data (temperature setpoint = 25, pump ON, and so on) with the control loops using single-process shared variables.
Pump ON/OFF—Controls the state of the pumps and agitation.
Figure 1.9. CompactRIO Architecture of a Bioreactor Application
To view and run the actual bioreactor application, download the Bioreactor Example from Section 1 Downloads.
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project