1. Discovering I/O in a Deployed System
A CompactRIO system may contain I/O modules that are supported in scan mode or in LabVIEW FPGA for advanced functionality. The discovery method discussed here applies to I/O modules supported in scan mode (FPGA I/O modules can be discovered using this library of VIs).
To identify the C Series I/O Modules that are present in a CompactRIO system, call the Refresh local I/O VI on the NI Scan Engine palette (this VI should not be called while performing control as it will induce jitter on the system). Once the I/O is refreshed, you can access references to each I/O module through LabVIEW property nodes and a new hierarchy of objects. For discovery, use the class Variable » Variable Object » Variable Container and select the Children property. This provides an array of references to the I/O modules that are currently present in the system. To identify the I/O modules, traverse the Children array using the To More Specific Class function to convert the references to RSI Module, and select the Model and Slot property, as shown below.
Figure 1. The LabVIEW Real-Time code above will discover the scan mode I/O modules that are currently present in the system.
The Children property of each I/O module is array of I/O variable references that can be used to read and write to each channel. Before reading and writing to each channel, use the To More Specific Class function to cast the references to I/O variables.
Figure 2. Use the Children property of a scan mode module to access the I/O variable channels
Once discovered, the properties of C Series I/O Modules, typically found in the LabVIEW Project, can be configured programmatically as discussed below.
2. Configuring I/O
Using the new programmatic I/O API, properties that were previously only accessible in the LabVIEW Project can now be configured at runtime. Each I/O module supported by scan mode shares the properties and methods of the RSI Module object, such as Slot and Model. Several I/O modules have their own object class with additional properties and methods for setting voltage gains, shunt calibration, etc. For example, the NI 9213 has a property for setting the thermocouple type of each of its input channels. Specialty digital capable DIO modules also have their own object class, SD Module, which provides properties and methods for configuring PWM, quadrature encoder, and high-speed counter functions.
For configuration, obtain references to each I/O module through discovery, as discussed in the previous section, or by simply dragging and dropping an I/O module to the block diagram from the LabVIEW Project.
Figure 3. Drag and drop scan mode I/O modules to the block diagram to get a URL to use for configuration.
3. Read and Writing I/O
LabVIEW 2009 includes a new set of VIs for programmatically reading and writing I/O variables and shared variables. Simply provide the URL of the variable to access through discovery, or by creating a constant from the shared variable refnum in input of the shared variable VIs and selecting browse.
Figure 4. To browse for variables, simply create a constant from the shared variable VI input.
You have the option to browse variables currently deployed in various engines or the variables in your LabVIEW Project.
Figure 5. The browse functionality allows you to select any variable currently deployed or in the LabVIEW Project
The VIs provided on the Shared Variable palette read and write a single channel at a time. For applications requiring the highest performance, use the NI Scan Engine Advanced I/O Access VIs to read and write to an entire module at once, as an array.
4. Create Flexible CompactRIO Scan Mode Applications
The LabVIEW 2009 platform increases the breadth of applications addressable with CompactRIO Scan Mode. You now have the ability to design and develop flexible, self-configuring applications that can adapt to a variety of I/O requirements in the field, without the need for reprogramming the system.
To see an example that uses the programmatic I/O API to discover, configure, and access CompactRIO Scan Mode I/O, click here.
5. Related Resources
White paper: Using CompactRIO Scan Mode with NI LabVIEW Software