Initializing Inport Values
- Updated2026-05-07
- 2 minute(s) read
Create and modify an array of inport values outside the control loop to optimize memory usage and prevent invalid model operations.
The Take Model Time Step VI requires you to pass an array of inport values to the VI. By creating this array outside the control loop that contains the Take Model Time Step VI, you preallocate the memory and avoid incurring data copies in the control loop. This eliminates jitter while the model executes.
After you create an array of initial inport values, you can manipulate the array so it includes the values you want to apply to the model inports. Updating the initial inport values can allow you to prevent your models from ever using invalid values. For example, if the model divides by an inport value, you can change the default value from 0 to avoid an invalid operation.
The following block diagram shows how to use the Model Interface API to create and modify the inports array outside the control loop:
The Model Interface API performs the following steps:
- Creates an array of the appropriate size for the model inport values. The value of each element is 0.
- Replaces the first element in the array of initialized values with the value from
the Offset front panel control.Note This example applies the same inport value during every time step. This might be typical of applications in which you want to observe the response to a particular stimulus. However, in hardware-in-the-loop applications, you might want to apply dynamic values from hardware I/O, such as channels on a DAQ device. In this scenario, you can manipulate the inport array inside the control loop.
- Passes the inport array into the model and steps the model.Note Wires that connect terminals of the Take Model Time Step VI within a loop to terminals of objects outside of the loop must pass through a shift register rather than a tunnel for VeriStand to process the model correctly. Unlike shift registers, tunnels do not allow data from one iteration to carry over to the next causing the output value of the model to remain at zero.
For an example code that demonstrates how to use the MIT Inport and Output VI, see the labview\examples\Control and Simulation\Model Interface directory.