LabVIEW Simulation Interface Toolkit API Reference

Creating a Custom Driver VI (Simulation Interface Toolkit)

  • Updated2023-02-21
  • 5 minute(s) read

You can use the LabVIEW Simulation Interface Toolkit to run a simulation on a National Instruments real-time (RT) controller by creating a driver VI. A driver VI contains mappings between a model DLL and a variety of National Instruments FPGA, CAN, and DAQ devices. You can use the SIT Connection Manager dialog box to create a driver VI for many supported hardware configurations.

If you want to run a simulation using a hardware configuration that this dialog box does not support, you can create a custom driver VI to support that configuration. For example, you need a custom driver VI in the following situations:

  • You want to run a simulation that uses RS232 (serial), GPIB, third-party, or custom I/O hardware devices.
  • You want to add extended capabilities to the driver VI.
Note  This topic assumes you are familiar with the architecture and operation of the driver VI. If you are using third-party or custom hardware devices, this topic assumes you already have a compatible RT driver for that hardware and that you know how to write LabVIEW code to interface with that hardware device.

You can customize the driver VI and still use the SIT Connection Manager dialog box to change mappings between LabVIEW controls/indicators and model parameters/signals. You can create and maintain one driver VI per DLL for use with different models and hardware configurations. LabVIEW saves any changes you make to the driver VI when you rebuild the driver VI, with the following exceptions:

  • LabVIEW does not preserve changes to controls with green labels.
  • LabVIEW does not preserve changes to the four I/O VIs.
  • LabVIEW does not preserve changes to the project if you select a new target type.
  • LabVIEW does not preserve changes to IP addresses or target aliases.

Adding Custom I/O to the Driver VI

You can add I/O that is not supported by the SIT Connection Manager dialog box to the driver VI. Adding I/O is useful if you want to use a combination of National Instruments hardware devices with serial, third-party, or custom hardware devices.

Note  To create a custom driver VI, you must correctly index into the pre-sized data array, which is where the Simulation Interface Toolkit places data from I/O channels. Refer to the modelname _portsReadme.txt file, located in the model DLL build directory, for a list of the ordering and widths of all model inputs and outputs. The index number of these arrays is the sum of the width of all previous elements. For example, the index number of element 3 equals the width of element 2 plus the width of element 1.

Adding I/O involves creating four VIs: one each that initializes, reads from, writes to, and closes the custom hardware. You then place these VIs on the block diagram of the generated IO Base Rate Loop VI.

For example, you can use the SIT Connection Manager dialog box to create the part of the driver VI that uses National Instruments FPGA target. If you modify the driver VI to contain four custom VIs that interact with a serial device, you still can change the FPGA mappings by using the SIT Connection Manager dialog box. These changes do not affect the four custom VIs, even if you generate the driver VI again.

Note  You also can edit the template VIs in the labview\vi.lib\addons\Simulation Interface\_Connection Manager\scriptdriver\templates. However, if you edit the template VIs, each time you generate a new driver VI the driver VI contains the modified template VIs. Before you edit the template VIs, browse to the labview\vi.lib\addons\Simulation Interface\_Connection Manager\scriptdriver\templates directory and make a backup copies of SIT Driver.vi and sit Base Rate Loop.vi. These VIs are templates LabVIEW uses when you generate a new driver VI. This file is the IO Base Rate Loop VI template. National Instruments recommends you maintain a copy of the original template.

As you create these VIs, you might want to create a type definition to pass resource names, control parameters the hardware needs, VISA resource names, and/or DAQmx Task Name controls between these four VIs. This setup is similar to how the modelname _IO IO Ref.ctl type definition, which the SIT Connection Manager dialog box uses, works.

After you create these VIs, place each one on the block diagram of the generated IO Base Rate Loop VI. Place each custom VI in the appropriate Sequence structure. Wire the custom VIs to maintain the data flow already present in the generated VI. For example, make sure the custom VIs share the same error cluster as the generated VIs.

The following figure shows the I/O Base Rate Loop VI before placing the custom VIs on the block diagram. The VIs with the SIT I/O icons are the VIs that LabVIEW generates.

The following figure shows the IO Base Rate Loop VI after you place the custom VIs on the block diagram. National Instruments recommends that you place custom VIs in the empty Sequence structures on the block diagram. However, you can place custom VIs anywhere on the block diagram. Three of the four custom VIs are circled.

In the previous figure, notice how each custom VI is in a Sequence structure. This method ensures that the custom driver VI executes.

After you save the I/O Base Rate Loop VI with the custom VIs included, using the SIT Connection Manager dialog box does not overwrite changes you made to the driver VI except for the caveats described in this topic. If you have multiple models and/or hardware configurations, you can generate multiple VIs for each model and/or configuration.

Log in to get a better experience