Archived: NI Scan Engine Advanced I/O Access in LabVIEW 2009 and Earlier Versions

NI does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.

Overview



The NI Scan Engine is a software component that you can install on supported targets, such as Real-Time PXI and CompactRIO targets. The NI Scan Engine enables efficient access to coherent sets of I/O channels, using a scan that stores data in a global memory map and updates all values at a single rate, known as the scan period. Refer to the target I/O driver documentation for information about NI Scan Engine support.

The LabVIEW Real-Time Module supports I/O variables for accessing I/O channels through the NI Scan Engine. LabVIEW 2010 introduced the ability to access multiple I/O channels using a single I/O variable. However, if you are using LabVIEW 2009 or earlier versions, you must access the channels separately using an I/O variable node for each channel.

To address this, NI created the NI Scan Engine Advanced I/O Access API for LabVIEW 2009 and earlier versions. This API allows users to read and write entire I/O modules using a single call to the NI Scan Engine from a cRIO or EtherCAT device. You can use the API attached to this document to achieve high performance and clean block diagrams when working with entire modules of I/O data at a time.

Download the NI Scan Engine Advanced I/O Access API here.

Contents

Native Functionality in LabVIEW 2010

The ability to read and write I/O values to an entire C Series module as an array was added as native functionality in LabVIEW 2010.  
For example, the following block diagram will return an array of doubles by using the Scanned Variable Read vi to read all the I/O channels by wiring in an array to the Data Type.  For the Shared Variable Refnum input, drag and drop the module from the project explorer.

The LabVIEW Help contains additional information.

 

NI Scan Engine Advanced I/O Access for LabVIEW Versions Prior to 2010

If you need to work with VIs or C-based functions that process multiple channels of data, it is more convenient and efficient to use an array-based API than to use the single-channel I/O variable API. For example, the PID VI is optimized for high channel counts if you pass an array of channels to the VI. To achieve this with the I/O variable API, you must read each channel separately and write them into a pre-allocated array during every iteration of the control loop, which adds unnecessary performance and memory overhead since the NI Scan Engine already stores contiguous channel values internally as an array. As the following block diagram demonstrates, this method also requires tedious LabVIEW code.

With the NI Scan Engine Advanced I/O Access API you can achieve the same outcome as the block diagram above with better performance and a simpler block diagram, as shown below.

The NI Scan Engine Advanced I/O Access API sacrifices some of the features of I/O variables in the interest of maximizing performance and convenience when working with arrays of data from multiple channels. The Advanced I/O Access API offers greater performance than I/O variables, especially in systems with high channel counts and fast loop rates, as shown in the following figures.

The Advanced I/O Access API does not return I/O channel errors or timestamps. Advanced I/O Access interfaces directly with the NI Scan Engine memory map and therefore does not support Direct I/O access mode. Also, Advanced I/O Access does not support aliasing, custom scaling, or I/O forcing.

Note: Because the Advanced I/O Access API is not integrated into the Project Explorer window, the API cannot automatically update module names to match the project configuration nor automatically deploy variable or hardware configuration settings.

 

NI Scan Engine Advanced I/O Access API Reference

The NI Scan Engine Advanced I/O Access API attached to this document includes functionality to obtain references to deployed I/O modules, obtain information about deployed modules and I/O channels, and read and write I/O values either by channel or by module. The Advanced I/O Access API preallocates memory buffers to store I/O values that you can then transfer a module at a time to and from the NI Scan Engine memory map.

Support for the Advance I/O Access API must be installed on the target from Measurement & Automation Explorer (MAX). Expand the target under Remote Devices, right-click on Software and select Add/Remove Software. Select Custom software installation and install the component called NI Scan Engine Advanced I/O Access 1.0.

Note: The API includes several “Set” VIs, which write output channel values to the memory buffers used by the API. However, you must use the Write I/O Module Data VI to transfer output values from the memory buffers to the NI Scan Engine, which then updates the physical I/O channels.

The following VIs will be added to the LabVIEW palette set under Measurement I/O » NI Scan Engine » Advanced I/O Access.

Get I/O Module List        

Returns an array of I/O module information for each deployed I/O module. The information returned for each module includes the module name, number of channels, and an array of channel names. This VI allocates memory and uses a shared resource that blocks all the other VIs in this API. Therefore, you should not use this VI inside a time-critical loop. If your application requires multiple calls to this VI, use dataflow to ensure that all instances of this VI complete before any I/O loops run.

Open Module Reference

Returns a reference to an I/O module. You can use this reference to access I/O module data through the NI Scan Engine Advanced I/O Access API. This VI also returns an array containing information about each I/O channel in the module. This VI allocates memory and uses a shared resource that blocks all the other VIs in this API. Therefore, you should not use this VI inside a time-critical loop. If your application requires multiple calls to this VI, use dataflow to ensure that all instances of this VI complete before any I/O loops run.

Note: The Refnum out output of this VI is not a standard LabVIEW refnum but rather an unsigned 32-bit integer value. This refnum value is invalidated when you change the deployed I/O module or I/O variable configuration on the target.

Allocate Array for Input Module

Allocates an array of the appropriate size and data type to store I/O module data. Use this VI to preallocate an array for deterministic, in-place access within a LabVIEW loop. You must manually select the polymorphic instance of this VI to match the data type of the I/O module.

Set All Output Channel Values

Sets the values of all channels of an I/O module within a local memory buffer. You must call the Write I/O Module Data VI after this VI to transfer the data from the local memory buffer to the NI Scan Engine memory map.

Read Input Module Data

Transfers the current I/O channel data for an I/O module from the NI Scan Engine memory map to a preallocated array you create using the Allocate Array for I/O Module VI.

Write Output Module Data

Transfers all I/O channel data for an I/O module written using the Set Output Channel VI's to the NI Scan Engine memory map. The NI Scan Engine then updates the physical I/O channels on the next scan iteration.

Set Output Channel Value by Index

Sets the value of an I/O channel specified by the index of the channel.  This VI sets the value within a local memory buffer. After setting the desired output channel values, you must call the Write I/O Module Data VI to transfer the data from the local memory buffer to the NI Scan Engine memory map.

Note: This VI replaces the specified index of the array of I/O module values and implements additional error handling to generate an error when the deployed I/O configuration changes at runtime. If you do not need to check for this type of error, you can simply use the Replace Array Subset function to set the output channel value in the preallocated I/O module data array.

Set Output Channel Value by Name

Sets the value of an I/O channel specified by the name of the deployed I/O variable corresponding to the channel.  This VI sets the value within a local memory buffer. After setting the desired output channel  values, you must call the Write I/O Module Data VI to transfer the data from the local memory buffer to the NI Scan Engine memory map.

Note: Accessing I/O channels by name can require slightly more overhead than accessing by index.

Get Input Channel Value by Index

Returns the value of an I/O channel specified by the index of the channel. You must call the Read I/O Module Data VI before this VI to get the latest channel value.

Note: This VI indexes the array of I/O module values and implements additional error handling to generate an error when the deployed I/O configuration changes at runtime. If you do not need to check for this type of error, you can simply use an Index Array function to get the input channel value from the preallocated I/O module data array.

Get Input Channel Value by Name

Returns the value of an I/O channel specified by the name of the deployed I/O variable corresponding to the channel. You must call the Read I/O Module Data VI before this VI to get the latest channel value.

Note: Accessing I/O channels by name can require slightly more overhead than accessing by index.

Close Module Reference

Closes the I/O module reference and frees up the memory associated with the reference.

 

Was this information helpful?

Yes

No