Table Of Contents

Implementing Channel Block Reading and Writing in Inline Custom Devices

Last Modified: June 10, 2021

Modify an inline model interface custom device to use block data references to read and write channel data.

Before you begin, create an inline model interface custom device.

In an inline custom device, you can read or write channel data for multiple channels at a time using block data references. Block reading and writing is useful for custom devices with a large number of channels, as this technique runs faster than channel-by-channel access. Block reading and writing also simplifies your code, as referencing, reading and writing to a large number of channels individually can become large and complex.

Use the following VIs from the Custom Device API library to work with block references:
  • Get Channel Block Data References VI
  • Get Channel Values by Block Data Reference VI
  • Set Channel Values by Block Data Reference VI
  1. Modify the Initialize case to obtain block data references.

    Get Custom Device Channel List VI and Get Channel Block Data References VI—Replaces the For Loop and Get Channel Data Reference VI that attains Read Access channel data references in the inline model interface custom device template.

    Get Custom Device Channel List VI and Get Channel Block Data References VI work together as follows:
    1. Get Custom Device Channel List VI returns an array of all the input channel references of the custom device.
    2. Get Channel Block Data References VI uses this array to generate Block Data Refs for the input channels, or an array of 32-bit data references, and sets the Access to Read, allowing you to use the references to get channel data.
    3. Get Channel Block Data References VI also returns the initial channel values as Values Array, which is used later in the Execute Model case.

    Get Custom Device Channel List VI and Get Channel Block Data References VI—Replaces the For Loop and Get Channel Data Reference VI that attains Write Access channel data references in the inline model interface custom device template. Works similarly for output channels.

    Get Custom Device Channel List VI and Get Channel Block Data References VI work together as follows:

    1. Get Custom Device Channel List VI returns an array of all the output channel references of the custom device.
    2. Get Channel Block Data References VI uses this array to generate Out Block Refs for the input channels, or an array of 32-bit data references, and sets the Access to Write, allowing you to use the references to write data to the channels.
    3. Get Channel Block Data References VI also returns the initial channel values as Values Array, which is used later in the Execute Model case.
    Block Data Refs and Values Array—Stored in a cluster for use in the Execute Model case. The refs and array are of both the input and output channels.
  2. Modify the Execute Model case to read and write channel data with block references.

    Get Channel Values by Block Data Reference VI—Uses the stored In Block Refs of the input channels to simultaneously get the value for each input channel.

    Do Model Calculation Flat Sequence Structure—Sums all values in the Input Values array and saves them to the Output Values array.

    Input Values and Output Values—Bundles arrays.

    Set Channel Values by Block Data Reference VI—Uses the Block Data Refs of the output channels to simultaneously write the updated values, which are contained in Output Values array to the output channels.


Recently Viewed Topics