Considerations for Integrating Models from MathWorks Simulink

The Model Interface API identifies and categorizes elements in MathWorks Simulink models.

The Model Interface API identifies the following elements in models you created and compiled in MathWorks Simulink according to their configuration in the Simulink:

  • Inports
  • Outports
  • Parameters
  • Signals

Case Study: Simple Models

Consider the following model from the Simulink environment:
Figure 1. Stmulink Model
A Simulink model showing a sine wave generator, gain block, summation block, and output.

When you load this model in an application, the Model Interface API categorizes its components as described in the following table:

Component in Model Type of Component in LabVIEW
Raw_Sine Signal
Sine_Gain Parameter
In1 Inport
Out1 Outport

Inports and Outports

Simulink inports and outports located on the top-level of the simulation hierarchy in Simulink are available as inports and outports. However, inports and outports in submodels are available only if you place VeriStand inport and outport blocks in the submodel.
Note The LabVIEW Model Interface Toolkit shares several components with VeriStand, such as its inport and outport blocks.

Parameters

Compiled models contain one of two types of parameters:

  • Global parameter—Similar to a workspace variable in MathWorks MATLAB. Global parameter applies to any model in the application that contains a parameter with the same name. Even if you open a parameter interface to update parameters for a specific model, the Model Interface API updates all models that contain the same global parameter. If you specify to inline parameters in the Simulink, MathWorks Real-Time Workshop converts MATLAB workspace variables to global parameters in the compiled model. Global parameters have the Model Name/Parameter Name path format.
  • Block parameters—Block parameters apply only to the specific model to which they belong. If you do not specify inline parameters in the MathWorks Real-Time Workshop, block parameters remain block parameters in the compiled model. Block parameters have the Model Name/Block Name/Parameter Name path format.
  • Tip To determine whether a parameter is global or block based on its path, use the Get Paths VI to return the paths of model parameters in a model.

    A Simulink model can contain only one type of parameter. However, an application can contain a model with global parameters and a model with block parameters.

    Conditions Where Parameters Are Unavailable

    The Model Interface API supports model references to submodels, but you cannot access parameters or signals in submodels. Submodels run in an application built with the Model Interface API, but their parameters and signals are not available for writing or reading.

    In the Simulink, you can use inline parameters, but the Model Interface API cannot access inline parameters to get or set their values. If you use an inline parameter, you can still allow the Model Interface API to influence the parameter by configuring a variable that affects the parameter to be tuneable. For example, consider a model with the following characteristics:

    • Contains a constant configured with the expression x + 3.
    • Contains a sine wave block whose amplitude and frequency parameters are inlined, and therefore unavailable in the Model Interface API.
    • Adds the result of the x + 3 constant to the output from the sine wave block.

    Although the parameters of the sine wave block are unavailable, you can influence the operation by specifying that the x variable is tunable in the Simulink. When x is tunable, it will appear in the list of parameters of the model, so you can change the value of x like a parameter as the model runs.

    Signals

    Model signals are usually excluded when you convert a model into a compiled model. To include model signals you must define the signals as test points in the software you use to compile the model.

    Conditions Where Signals Are Unavailable

    Certain optimizations you enable in the Simulink can make a signal unavailable to the Model Interface API. You can disable these options for the entire model to make all signals available for probing, but the memory footprint of the model increases as a result. Alternatively, you can mark individual signals as test points in the Simulink to maintain a reduced memory footprint while keeping the test-point signals available for probing.

    Note If you previously converted your model to a compiled model, you must convert the model again after marking signals as test points.

    Bus Objects

    In models compiled in Simulink R2010b or a later supported version, named components of bus objects, such as signals, are represented in the same hierarchy as in the uncompiled model. For models compiled in versions of the Simulink earlier than R2010b, bus objects are represented as a single vector of components.