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: Mar 25, 2011


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

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

0 Ratings | 0.00 out of 5
 Print |  PDF

Overview

LabVIEW Real-Time 8.6 introduced a new programming model for CompactRIO that reduces development time and complexity. There are several technologies in LabVIEW that make this new programming experience possible, two of which are the NI Scan Engine and I/O variable. To learn more about these features refer to Using NI CompactRIO Scan Mode with NI LabVIEW Software.

This paper discusses advanced features that can help you write code that is more portable, has better fault handling, and is easily accessible for HMI and OPC clients.

Table of Contents

  1. Background
  2. I/O Alias
  3. Remote Monitoring and Communication
  4. Fault Handling
  5. Related Resource

Background

The I/O variable provides direct access in LabVIEW Real-Time to scaled calibrated I/O data without FPGA programming or compiling. The I/O variable values are read from a global memory table that is updated by the NI Scan Engine at a rate you specify. You can use I/O variables throughout your LabVIEW Real-Time VIs to provide jitter-free access to coherent sets of I/O data.

I/O Alias

An I/O Alias is reference to an I/O variable that allows you to provide additional scaling and maintain code portability.

Code Portability with I/O Alias

Each I/O variable that is placed on the block diagram is statically linked to an I/O channel. For example, an I/O variable may be linked to …/Mod1/AI0. If the I/O channel moves (Mod1 is moved to Mod2) or the application is ported to a new CompactRIO controller with different I/O modules, you need to update each instance of the I/O variable to point to the new I/O channel. To prevent this scenario and maintain code portability, use I/O aliases. From the LabVIEW Project, you can change which I/O variable an I/O alias references, which then updates all instances of the I/O alias to point to the new I/O variable. Also, because I/O aliases are saved in project libraries, a VI using I/O aliases and the project library can be easily copied and imported into a new LabVIEW Project, where the I/O aliases are bound to I/O variables in the new project.

Additional Custom Scaling with I/O Alias

Multiple I/O aliases can be created for a single I/O variable. Since I/O aliases support linear and square root scaling, each I/O alias can apply a unique scale to the I/O value. For example, if you have an I/O variable called Temp_C, that is reporting temperature in degrees Celsius, you can create two I/O aliases bound to Temp_C. Each I/O alias can then provide additional scaling to convert the Celsius value to Fahrenheit and Kelvin. The I/O variable and I/O aliases can then be used, interchangeably, throughout the application, depending on which engineering units are needed.

For additional information, including batch creation of I/O aliases, see the following LabVIEW Real-Time help topic:  

LabVIEW 8.6 Help » Real-Time Module » Real-Time Module Concepts » Accessing I/O with the NI Scan Engine » Using I/O Variables

Remote Monitoring and Communication

By default, I/O variable values are published to the network for remote I/O monitoring. The I/O variables do not use or require the Shared Variable Engine, but are published by a normal priority thread associated with the NI Scan Engine at a rate you specify. Use the NI Distributed System Manager to remotely monitor your network-published I/O values.

Key Differences between Network Variables and I/O Variables

Since I/O variables are network-published, you can also use them in host applications across the network for remotely monitoring I/O values. However, unlike shared variables, network published I/O variables do not support buffering,  blocking reads, logging and alarming with the LabVIEW Datalogging and Supervisory Control Module, publishing data as OPC items, etc.   Note: remote monitoring of I/O variables is not available on the Touch Panel.

Using I/O Variables in HMI Applications (OPC, DSC, Touch Panel)

For applications requiring more than simple single-point monitoring of I/O(such as OPC access, alarming, logging), you can create a network-published shared variable on your host machine (or any Windows machine) that is bound to the I/O variable. You can then access the newly created network published shared variable to get OPC support, alarming and logging support for the LabVIEW Datalogging and Supervisory Control Module, and I/O access for the LabVIEW Touch Panel Module.

Fault Handling

LabVIEW Real-Time Targets with the NI Scan Engine installed use faults to address asynchronous error conditions. Each fault has an associated code and description. You can view and clear faults with the NI Distributed System Manager or manage them programmatically with the Faults VIs in the NI Scan Engine palette. You can also use the Set Fault VI to report user defined faults.

By default, the scan engine is configured to run at a priority higher than time critical, which means that the I/O scan thread responsible for reading and writing I/O has a higher priority than all user VIs and structures. It is recommended that you use this default configuration; however, you can configure the scan engine to run at a priority between time critical and timed structures, as an advanced option. If you configure the scan engine to run at less than time critical priority it is important to monitor and manage faults. If your application contains a time critical VI that does not allow the I/O scan thread to complete an iteration on time, a fault is reported. If the I/O scan is late for ten consecutive iterations the I/O scan thread is stopped and a fault is reported. In the event that the I/O scan stops, use I/O variables configured to use direct I/O access, which bypasses the I/O scan, to set your outputs to safe values. This complexity can be avoided by configuring the scan engine to run above time critical.

To protect against an application hang or lock-up, use the LabVIEW Real-Time Watchdog VIs.

Refer to the following help topics for additional information:

LabVIEW 8.6 Help » Real-Time Module » Real-Time Module Concepts » Accessing I/O with the NI Scan Engine » Using the NI Scan Engine

LabVIEW 8.6 Help » Real-Time Module » Real-Time Module Concepts » Accessing I/O with the NI Scan Engine » NI Scan Engine Faults

Related Resource

White Paper: NI Scan Engine Performance Benchmarks

0 Ratings | 0.00 out of 5
 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/).