Table Of Contents

Using the Inline Model Interface Custom Device Driver Template

Last Modified: June 10, 2021

Use the inline model interface custom device driver template to build the RT Driver VI for a custom device.

The block diagram of the Inline Custom Device Driver VI Template (Model Interface).vit template VI contains a case structure with four cases to which you can add code to customize the device.

The following image displays the execution order of those cases with respect to the Primary Control Loop (PCL).

  1. Navigate to the labview\vi.lib\NI VeriStand\Custom Device API directory and open Inline Custom Device Driver VI Template (Model Interface).vit.
  2. Modify the following code to set up the Initialization case that executes before the PCL starts running.
    spd-note-note
    Note  

    Because the Initialize case executes before the PCL starts, you cannot read or write channel values in this case.

    Get Custom Device Channel List VI—Gets a list of all the input and output of channels of the custom device.

    Get Channel Data Reference VI—Compiles a list of channel data references for the channels. In this case, you can also read device configuration information from properties that use a reference to the device.
    spd-note-note
    Note  

    The Get Channel Data Reference VI does not appear on the Functions palette but belongs to the Custom Device API library. To avoid causing system instability or errors, do not call this VI or the Set Channel Data Reference VI outside of an inline RT Driver VI.

  3. Modify the Start case that executes after initialization but before the PCL starts running.
    If necessary, you can use this case to start device tasks, such as DAQ tasks, or to wait for start triggers. Because the Start case executes before the PCL starts, you cannot read or write channel values in this case.
    spd-note-note
    Note  

    If you use a start trigger in the Start case, you should specify a timeout for waiting on the trigger. Failing to specify a timeout can cause your system to wait indefinitely if the start trigger does not occur as expected.

  4. Modify the following code to set up the Execution case that executes in the middle of the PCL iteration.

    This case reads input data, executes the model, and then writes output data to the rest of VeriStand. Model refers to a mathematical function. You may need to average channel data, or you can execute a LabVIEW or other model using the LabVIEW Model Interface Toolkit.

  5. Modify the Close case that executes after the PCL finishes executing.

    Use this case to close references and release resources. Because the close case executes after the PCL terminates, you cannot read or write channel values in this case.

If your custom device needs to read or write channel data for multiple channels at a time, consider using block data references in your code.

Recently Viewed Topics