Basic Architecture for Executing Models
- Updated2026-05-07
- 3 minute(s) read
Basic Architecture for Executing Models
The Model Interface API allows for integration and execution of models in LabVIEW control systems, supporting reliable timing and synchronization for applications.
The Model Interface API allows you to integrate and run models in LabVIEW control systems. In many applications, timing is an important factor in application design. Time steps must repeat based on specific timing characteristics or synchronize model execution with a hardware device clock. To ensure LabVIEW runs a model reliably, you can separate your code into at least two components:
Prior to the control loop of your code, you can perform initialization-related tasks, such as loading the model and initializing parameter values. After the control loop and background code stops, you can unload the model and close any references you opened.
Example: Simple Model Control Application
The following block diagram shows a simple VI:
The VI uses the Model Interface API to perform the following steps:
- Loads the model from the disk.
- Creates a model reference you pass to other VIs throughout the application to
run and interact with the model.Note Avoid branching the model reference wire to ensure optimal performance. The Model Interface API is not designed to operate on a model in parallel locations.
- Reads the compiled rate of the model in seconds.
- Sets the period of the Timed Loop.. Each iteration of the Timed Loop must complete execution before the specified period. This example converts seconds to milliseconds. The Period input of the Timed Loop requires values in the same units as the 1 kHz clock timing source configured for the loop.
- Performs the following tasks during each iteration of the high-priority control
loop:
- Writes a value of 0 to the only model inport. 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 model response to a particular stimulus. However, in hardware-in-the-loop applications, dynamic inport values might come from hardware I/O, such as channels on a DAQ device. In other applications, you might allow users to manipulate inport values via front-panel controls.
- Steps the model during each iteration of the Timed Loop. The Timed Loop iterates until an error occurs or the stop control is TRUE.
- Displays the value of the model outport in a waveform chart on the front panel.
- Writes a value of 0 to the only model inport.
- The Model Interface API sets the value of a parameter when the control loop sleeps. This loop is typical of background-priority code.
- The Model Interface API unloads the model and handles any errors that occurred.
In this example, the control loop transfers data between the model and front panel controls and indicators. A real-world application might contain the following features:
- A model with multiple inports, outports, parameters, and signals
- Hardware device driver VIs that read data from or write data to hardware I/O
- Multiple models
Related Information
- Initializing Parameter Values
Set and initialize parameter values in models using the Model Interface API or modeling environment software.
- Updating Parameters While the Model Runs
Use the Model Interface API to update model parameters programmatically during runtime.
- Probing Signal Values
Probe signal values in a model using the Model Interface API, including signal buffering, formatting, and accessing values during execution.