Initializing Inport Values
- Updated2025-10-15
- 3 minute(s) read
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, which can cause 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.
|
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.
|
Refer to the MIT Inport and Output VI in the labview\examples\Control and Simulation\Model Interface directory for example code that demonstrates these concepts.


Related Links
Basic Architecture for Executing Models