Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
What is Developer Zone?
United States

Document TypeTutorial
NI Supported: Yes
Publish Date: Dec 19, 2011


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

Using NI CompactRIO Scan Mode with NI LabVIEW Software

3 Ratings | 3.67 out of 5
Read in  |  Print |  PDF

Overview

The LabVIEW Real-Time Module 8.6 introduced powerful new features for programming CompactRIO hardware that reduce development time and complexity as well as provide tools for monitoring and maintaining CompactRIO applications. CompactRIO is a high-performance programmable automation controller (PAC) that is differentiated by a field-programmable gate array (FPGA) at the heart of its architecture. At the highest level, an FPGA is a reprogrammable silicon chip. FPGAs offer the performance and reliability of custom hardware while maintaining the flexibility of a software-defined system. Traditionally, FPGA use has been restricted to hardware design engineers who are experts in VHDL and other hardware descriptor languages; however, LabVIEW enables you to benefit from FPGAs without this expertise. LabVIEW is a powerful intuitive graphical programming language with hundreds of built-in control, analysis, communication, and logging functions. CompactRIO is entirely programmable with LabVIEW, including the FPGA, real-time processor, and human machine interface (HMI).

Using CompactRIO Scan Mode, you can choose between accessing each I/O module directly in LabVIEW Real-Time and host applications with no FPGA programming or in LabVIEW FPGA for maximum flexibility and performance. You can also use new test panels and I/O forcing functionality to get up and running quickly, perform advanced debugging, and monitor system performance.

Table of Contents

  1. Reduce Development Time and Complexity
  2. Easy Setup, Debugging, and Monitoring
  3. LabVIEW FPGA and CompactRIO Scan Mode
  4. CompactRIO Scan Mode under the Hood
  5. When Should I Use CompactRIO Scan Mode?
  6. Configure a CompactRIO Scan Mode System
  7. Conclusion
  8. Related Resources

Reduce Development Time and Complexity

Figure 1. CompactRIO Scan Mode provides access to I/O directly in LabVIEW Real-Time and host VIs with no FPGA programming or compiling.

Prior to LabVIEW 8.6, CompactRIO I/O was accessed by programming the FPGA and then, in LabVIEW Real-Time, using the LabVIEW FPGA Interface VIs. CompactRIO Scan Mode automatically detects your I/O modules and adds them to the LabVIEW Project. You can then drag and drop the I/O variables onto your LabVIEW Real-Time and host VI block diagrams and instantly read and write scaled, calibrated I/O data without any FPGA programming or compiling (see Figure 2).

Figure 2. Access I/O directly in LabVIEW Real-Time by dragging and dropping I/O variables to your block diagram.

The NI Scan Engine, a component of LabVIEW Real-Time, updates the I/O variable values at a rate you specify (up to 1 kHz). All channel scans are hardware-timed with module-to-module synchronization. You can configure the scan engine from the LabVIEW Project or programmatically with an included library of VIs. The scan engine also provides a timed-loop timing source, so you can synchronize code with I/O updates for low-jitter control applications. You can create aliases of I/O variables to provide an additional layer of abstraction from the physical I/O channel. Also, linear and square root scaling are available on I/O variables and aliases.

CompactRIO Scan Mode adds counter, quadrature encoder, and pulse-width modulation (PWM) functionality to any existing eight-channel digital NI C Series module without requiring any programming. You configure these specialty digital functions from the LabVIEW Project, but they run on the FPGA for accuracy and speed. Now, without compiling, you can perform up to 1 MHz edge counting, pulse-width and frequency measurements, quadrature decoding, and PWM control.

 

Counter-Specific Features

    • 1 MHz counting on eight channels
    • 32-bit count register, with programmable terminal count
    • Configurable terminal count and terminal count behavior
    • Configurable count edge (rising, falling, or both), source, and gate
    • Period, PWM, and frequency measurements with configurable timebase

Quad-Specific Features

    • 1 MHz max quad count rate
    • 32-bit count register
    • 32-bit velocity measurement register
    • Configurable velocity measurement timebase (256 µs, 512 µs, ... 16384 µs, or 32768 µs)
    • X4 encoding
    • Two quad channels with A+B+Index inputs per module
    • Selectable encoder polarity

PWM-Specific Features

    • Eight output channels
    • Per-channel duty-cycle and period configuration
    • Configurable frequency period (1 Hz, 50 Hz, 250 Hz, 500 Hz, 1 kHz, 5 kHz, 10 kHz, or 20 kHz)

Easy Setup, Debugging, and Monitoring

The NI Distributed System Manager provides a central location for monitoring systems on the network and managing published data. The new system manager offers test panels for CompactRIO modules using CompactRIO Scan Mode. As soon as your system is available on the network, you have access to real-time and historical-trend I/O values, so you can quickly verify your connections and signal integrity. In addition to test panels, the system manager also gives visibility into memory usage and processor load for CompactRIO controllers.

Figure 3. The new NI Distributed System Manager helps you get up and running quickly by adding test panels to CompactRIO.

 

CompactRIO Scan Mode provides I/O forcing, which is a debugging tool you can use to override the value of an I/O variable without stopping or changing your real-time application. You can force inputs to test the response of your application without a physical stimulus, as well as force outputs to override program output values. You can force channel values using the system manager or with new I/O forcing VIs.

 

LabVIEW FPGA and CompactRIO Scan Mode

With LabVIEW Real-Time 8.6 or later, you can access each module with either CompactRIO Scan Mode or LabVIEW FPGA. Using LabVIEW FPGA, you can implement custom triggering, hardware-based analysis and signal processing, or high-speed analog streaming. To use I/O modules in LabVIEW FPGA Mode, simply drag the module to the FPGA target in the LabVIEW Project, removing it from scan mode. Then use LabVIEW FPGA to program the modules and use I/O variables to read and write I/O on the remaining modules (see Figure 4).

Figure 4. This VI accesses I/O with CompactRIO Scan Mode while computing the fast Fourier transform of an acceleration input with LabVIEW FPGA.

When using LabVIEW FPGA Mode on one or more modules, the CompactRIO Scan Mode logic on the FPGA, known as the RIO Scan Interface , is compiled with the LabVIEW FPGA VI into a single FPGA application. If no modules are configured to use scan mode, the RIO Scan Interface is not included in the compile.

 

Communicating Between LabVIEW FPGA and LabVIEW Real-Time with I/O Variables

With the LabVIEW 2009 Real-Time Module, you can create user-defined I/O variables to provide communication between your real-time and FPGA VIs. This provides a way for data from the FPGA VI to be inserted into the scan engine and read out in LabVIEW Real-Time, using the same I/O variable API used for scan mode I/O. These I/O variables can also pass data from a real-time VI to the FPGA; however, each I/O variable is unidirectional. Methods are also provided to synchronize your LabVIEW FPGA code to the RIO Scan Interface I/O updates.

For example, suppose a CompactRIO system is using LabVIEW FPGA to monitor an accelerometer at 50kHz and calculate the RMS on the fly, The RMS calculation on the FPGA can be synchronized to the FPGA scan mode logic and written to a user-defined I/O variable, which is then accessed in a LabVIEW Real-Time VI.

 

CompactRIO Scan Mode under the Hood

CompactRIO Scan Mode is powered by two technologies, the NI Scan Engine and the RIO Scan Interface. The RIO Scan Interface is a set of FPGA intellectual property (IP) developed by National Instruments that is downloaded to the CompactRIO FPGA and is responsible for I/O module detection, timing, synchronization, and communication. The RIO Scan Interface runs a hardware-timed scan loop, which updates the physical I/O values. Two DMA channels are used to transport I/O data between the FPGA and real-time operating system (RTOS). The prebuilt specialty digital functionality is also a component of the RIO Scan Interface. For more information on the RIO Scan Interface, see the Related Resources section below.

The NI Scan Engine is a component of LabVIEW Real-Time that runs at a priority above time critical or between time critical and timed structures, which you can configure. Each time the RIO Scan Interface has finished the latest I/O scan, LabVIEW adds the I/O variables to a global scan engine memory map and updates the values of all I/O variables concurrently. However, you can configure each I/O variable node to use either scanned access or direct access. By default, LabVIEW configures I/O variable nodes to use scanned I/O, which uses the scan engine memory map to perform non-blocking I/O reads and writes (see Figure 5). Direct I/O access bypasses the scan engine memory map and communicates directly with the I/O device driver to perform blocking I/O reads and writes (see Figure 5). The NI Scan Engine also publishes the I/O variables to the network, making them available for reading and writing in host applications, test panels, and I/O forcing. The scan engine, not the LabVIEW shared variable engine, handles the network publishing of the I/O variables, which you can disable from the I/O variable properties page.

When you use LabVIEW FPGA with CompactRIO Scan Mode (some modules using CompactRIO Scan Mode and some using LabVIEW FPGA Mode), the RIO Scan Interface and the FPGA VI are compiled into a single bitstream and deployed to the FPGA. If you remove all the modules from scan mode, then the RIO Scan Interface is not compiled into the bitstream. The space consumed by the RIO Scan Interface, on the FPGA, scales with the number of modules using scan mode.

Figure 5. CompactRIO Scan Mode under the Hood

 

When Should I Use CompactRIO Scan Mode?

CompactRIO Scan Mode is designed for applications requiring synchronous I/O updates at rates of up to 1 kHz. You can use the specialty digital functionality provided by scan mode to convert any existing eight-channel digital I/O module into an advanced PWM, counter, or quadrature encoder module. With the I/O forcing and test panel functionality of the system manager, you can also use scan mode for initial setup, system performance monitoring, and advanced troubleshooting. For applications with higher-performance requirements, such as analog streaming at nearly 1 MHz, high-speed PID control loops more than 1 kHz, custom hardware analysis and signal processing, or I/O modules not supported by scan mode, use the LabVIEW FPGA Module with scan mode. You can also offload processing from the real-time controller with the LabVIEW FPGA Module.

Scan mode is supported by controllers running the VxWorks RTOS with at least 2M gate FPGAs because of the RIO Scan Interface FPGA space requirements. 

There are some performance trade-offs when using CompactRIO Scan Mode. For example, the specialty digital functionality supports up to 1 MHz counters versus the 20 MHz counters achievable with LabVIEW FPGA. The scan engine uses system resources, which include FPGA space, two DMA channels, memory, and an amount of CPU time that scales with the scan rate. The space consumed by the RSI, on the FPGA, scales with the number of modules using scan mode.

 

Configure a CompactRIO Scan Mode System

To get started with CompactRIO Scan Mode, configure a system using the CompactRIO Advisor and be sure to include:

-NI LabVIEW 8.6 Development System for Windows or later

-NI LabVIEW Real-Time Module 8.6 or later

 

Conclusion

LabVIEW Real-Time provides a powerful set of features designed to reduce CompactRIO development time and complexity. With CompactRIO Scan Mode, you can access I/O in LabVIEW Real-Time and host applications with no FPGA programming, while having the option to program the FPGA directly for the most advanced requirements. The NI Distributed System Manager and I/O forcing also bring test panels and advanced debugging to CompactRIO, making it easy to monitor and maintain CompactRIO applications.

Try LabVIEW online to check out the new features.

 

Related Resources

Video Tutorial: LabVIEW Real-Time 8.6 for CompactRIO Video Tutorials

C Series Modules Supported by CompactRIO Scan Mode

White Paper: Recommended Practices for Using the LabVIEW I/O Variable and NI Scan Engine

White Paper: The RIO Scan Interface Under the Hood

 

 

3 Ratings | 3.67 out of 5
Read in  |  Print |  PDF

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).