Вы находитесь на странице: 1из 2

Real-Time Control on CompactRIO Sample Project Documentation

Publish Date: Aug 21, 2012

Overview
The Real-Time Control on CompactRIO (RIO Scan Interface) sample project implements deterministic, software-based control of a plant. This sample project uses the RIO Scan Interface (RSI), which is an alternative to programming with the LabVIEW FPGA Module, to perform I/O on the FPGA. The RSI programming mode is available on most CompactRIO and Single-Board RIO devices and is sufficient for applications that require single-point access to I/O at rates of a few hundred Hertz.

Table of Contents
1. Developer Walkthrough 2. Features 3. Basis 4. System Requirements 5. Overview 6. Running this Sample Project 7. Modifying this Sample Project

1. Developer Walkthrough
See a developer walkthrough of the RIO sample projects.

2. Features
Deterministic, software-based controlThe real-time controller executes parallel control algorithms that run at different rates. RIO Scan InterfaceThe RIO Scan Interface provides single-point updates to I/O variables at rates up to a few hundred Hertz without requiring FPGA programming. User interfaceThe user interface VI interacts with the CompactRIO device and displays data. This VI can disconnect from the device and reconnect at any time without affecting the control loop. Error handlingThe application reports and logs all errors from the CompactRIO device, shutting down on any critical error.

3. Basis
This sample project is based on the Simple State Machine and Queued Message Handler templates. Refer to the Simple State Machine and Queued Message Handler templates and their documentation, available from the Create Project dialog box, for information about how these templates work.

4. System Requirements Development System


LabVIEW Full or Professional Development System LabVIEW Real-Time Module NI-RIO device driver software

NI CompactRIO Device in Scan Interface Mode


This sample project is designed for an NI cRIO-9074 with the following components: Software: LabVIEW Real-Time Network Streams Network Variable Engine NI System Configuration NI-RIO NI-Watchdog NI-RIO IO Scan I/O modules: Analog input module. This sample project is designed for an NI 9205 in slot 1. Analog output module. This sample project is designed for an NI 9263 in slot 2. Thermocouple input module. This sample project is designed for an NI 9213 in slot 3. Sinking/sourcing digital input module. This sample project is designed for an NI 9422 in slot 4. Solid-state relay sinking/sourcing digital output module. This sample project is designed for an NI 9485 in slot 5.

5. Overview
This sample project consists of nine parallel loops across two execution targets. The following loops run in parallel on the desktop computer: Handling events from the user interface (UI Main.vi - Event Handling Loop)Produces messages to the UI Message Loop based on front panel events. Handling messages from the user interface and other loops on the desktop computer (UI Main.vi - UI Message Loop) Displaying messages and data from the CompactRIO device (UI Main.vi - Monitoring Loop)Displays the latest values of information acquired from RT Loop - System Health and Monitoring.vi. The following loops run in parallel on the real-time controller: Controlling the plant (RT Loop - RSI Control.vi)Reads from the NI 9205 inputs, applies a control algorithm to each channel, and writes to the NI 9263 outputs. The control algorithm uses setpoint data and PID gains sent from the user interface. Monitoring temperature and stopping the control loop (RT Loop - RSI Low Speed.vi)Reads temperature data from the NI 9213 and a DI line from the NI 9422 and determines whether to stop the control loop and write to DO lines on the NI 9485. Handling commands from the user interface (RT Loop - UI Commands.vi)Reads commands that are sent from UI Main.vi on the development computer and produces the appropriate messages. Handling messages from all loops on the real-time controller (RT Main.vi - Message Handling Loop)Consumes messages from all loops that run on the real-time controller. Ensuring the RT controller remains responsive (RT Loop - Watchdog.vi)Pets the watchdog, ensuring the RT controller remains responsive. Monitoring diagnostic information from the real-time controller (RT Loop - System Health and Monitoring.vi)Monitors CPU and memory usage of the real-time controller and information about

1/2

www.ni.com

Monitoring diagnostic information from the real-time controller (RT Loop - System Health and Monitoring.vi)Monitors CPU and memory usage of the real-time controller and information about the RSI. This information is written to network-published shared variables and appears on the Data Monitoring and System Monitoring tabs of UI Main.vi. No LabVIEW code runs on the FPGA. Instead, the RSI runs on the FPGA, scans the C Series modules for input and output changes, and passes updated values to the NI Scan Engine. The NI Scan Engine, which is running on the real-time controller, updates the I/O variables with data from the RSI. This update provides single-point data from C Series I/O to both the real-time VI and the user interface.

6. Running this Sample Project


1. Adapt the sample project to your hardware. 2. In the Project Explorer window, run RT CompactRIO TargetRT Main.vi. This VI begins acquiring data and executing the control loop. 3. Open and run My ComputerUI Main.vi. 4. Enter the IP address of the CompactRIO chassis in the Controller Address text box and click Connect. 5. After you are connected, click Run Control to start the control loop. 6. Adjust the channel values on the Control Settings page and view the outputs on the Data Monitoring page. Until you define a control algorithm, all Control Output Values will read 0. 7. Click Exit to exit the application.

7. Modifying this Sample Project Adapting this Sample Project to Your Hardware
The following steps refer to NI CompactRIO devices, but you also can adapt this sample project to an NI Single-Board RIO device that supports the RIO Scan Interface. 1. Ensure all devices are configured and connected to the same network as the development computer. 2. In the Project Explorer window, add or discover your RT CompactRIO target to the top-level project item. 3. Add or discover your CompactRIO chassis to the RT Compact RIO target you added in the previous step. Ensure the chassis is set to Scan Interface mode. 4. Add or discover your C Series input module to the CompactRIO chassis you added in the previous step. 5. Drag the following project items from the default RT CompactRIO target to the one you added in step 2: Error Handlers folder Globals folder Support VIs folder RT Loops folder Type Definitions folder Deterministic Loop Variables.lvlib Shared Variables.lvlib RT Main.vi 6. Delete the default RT CompactRIO Target project item that no longer has any VIs associated with it. 7. Open RT Loop - RSI Control.vi and replace the Shared Variable Nodes with ones that represent the I/O channels you want to use. For example, to use Mod5/AI2, drag this input channel from the Project Explorer window to the block diagram. The actual channels you read from and write to depend on your application. 8. Open RT Loop - RSI Low Speed.vi and replace the Shared Variable Nodes with ones that represent the I/O channels you want to use.

Defining a Control Algorithm


Locate the Control (PID) subdiagram of the Case structure in RT Loop - RSI Control.vi and modify this subdiagram to apply a control algorithm. For example, you can use the PID VI that is included with the NI LabVIEW PID & Fuzzy Logic Toolkit. By default, this algorithm returns a constant value of 0 on all output channels. You can perform a different algorithm on each individual channel. Although this sample project is designed to implement a PID algorithm, you can modify the sample project to use any algorithm.

Defining Safe Values for Hardware Connected to the C Series Modules


Modify the Safe State, Default subdiagram of the Case structure in RT Loop - RSI Control.vi to write safe values to output channels. The values you write here should be ones that you know the connected hardware can safely handle. By default, this subdiagram writes a value of 0 to all output channels.

Configuring Sample Project Settings


In the Project Explorer window, open My ComputerGlobalsGlobal - Configuration Options.vi and configure the sample project settings. Copyright 2012 National Instruments. All rights reserved. For copyright notices, conditions, and disclaimers, including information regarding certain third-party components used in LabVIEW, refer to the Copyright topic of the LabVIEW Help. Trademarks LabVIEW, National Instruments, NI, ni.com, LabVIEW, the National Instruments corporate logo, and the Eagle logo are trademarks of National Instruments Corporation. Refer to the Trademark Information at ni.com/trademarks for other National Instruments trademarks. Patents For patents covering the National Instruments products/technology, refer to the appropriate location: HelpPatents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.

2/2

www.ni.com

Вам также может понравиться