Table Of Contents

Using the Inline Hardware Interface Custom Device Driver Template

Last Modified: June 10, 2021

Use the inline hardware 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 (HW Interface).vit template VI contains a case structure with five 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 (HW 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 a the Read Data from HW case that executes at the beginning of each iteration of the PCL before other components such as faults, alarms, and procedures.
    Read Hardware Channels—You can replace this flat sequence structure or the code inside it with the code necessary to obtain data from a hardware device. For example, you can use a hardware device's API calls to request an A/D sample.
    Set Channel Value by Data Reference VI—Writes the data to a specified channel, making the data available to the other components of VeriStand for the remainder of the PCL iteration.
  5. Modify the following code to set the Write Data to Hardware case that executes at the end of each iteration of the PCL after other components such as faults, alarms, and procedures.
    Write Input Data to Hardware Channels—You can replace the code in this flat sequence structure with the code necessary to send data to a hardware device.
  6. 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.

Recently Viewed Topics