Implement a block and assign a functional mockup unit (FMU) to it. You can then explore the block to see the FMU. This example uses the FMU block with the vehicle FMU.
Create a model and add the FMU block.
In the block dialog box, enter the path name for an
FMU file in the FMU name parameter and click OK or Apply.
The file extension
.fmu is optional.
The first time you click OK or Apply, the block identifies which FMU mode to set your FMU to, co-simulation or model exchange.
The block also creates a
folder and unpacks the contents of the FMU file into this folder, which optionally
binaries — FMU binary files
documentation — FMU documentation HTML files
resources — FMU source files
sources — FMU source files
Other supporting files, such as block mask and description files
The FMU block icon and port labels update to the labels of the corresponding FMU. After you associate the block with an FMU, if you want to change the FMU, right-click the FMU block, and select Block Parameters, and enter a new FMU name in FMU name.
Double-click the block. Suppose that you entered an FMU named
slexCoSimMassSpringFMU from your current folder. The FMU
block dialog box reflects the FMU parameters defined in the
Lists the FMU block parameters. Edit the values as necessary. You can edit the elements of a structure parameter by expanding the tree view.
Enables logging and associated customizations.
To enter a relative tolerance, select Enable FMU tolerance and set it.
To determine the sample time of the block in the model, set
Communication step size. To inherit the step size from the
Simulink® solver, set to
-1. This option is available only if
the FMU is a co-simulation FMU.
To enable logging, select the Enable FMU Debug Logging.
In Redirect debug logs to, select the destination for the logs.
File, saved to
Display, displayed in the MATLAB® Command Window.
If the Enable FMU Debug Logging check box is selected and
the Redirect debug logs to parameter is set to
Display, you cannot use the FMU block for co-simulation. For more
information on co-simulation and multiple cores, see Run Co-Simulation Components on Multiple Cores
In the Filter logs by return status, select the check box for the return status you want.
These two tabs list the input and output bus objects that the block defines.
In the Bus Object Name parameter, you can change the bus object names to match the bus objects defined in the workspace.
To create a bus object in the workspace:
You can change the layout of FMU block input ports, output ports, and parameters with these parameters:
|Change hierarchy of input ports.||
|Change hierarchy of output ports.||
|Change hierarchy of parameters.|
set_param functions to
set these values. For example, assume a block parameter tab with a structure
The parameters are contained in a
struct. To list the parameters
individually, set the
FMUParamMapping property to
You can set the sample time for the FMU block with the Communication step size parameter. This block sample time setting, tC, like all Simulink blocks, must be an integer multiple of the model sample time, tM. Simulink generates an error if the communication step size tC is not a multiple of the model step size tM.
The local step size of the FMU tL, on the other hand, is part of the FMU specification and is known to the FMU only internally. For proper operation, the communication step size, tC must also be an integer multiple of tL. If the model sample time tM or the block sample time tC is incompatible with the FMU local step size tL, the FMU may or may not produce an error at run time, depending on its implementation.
If there are problems with using the FMU:
Check the compliance of the FMU with the FMI standard. Use the FMU compliance checker.
Select the Enable FMU Debug Logging check box on the FMU block Simulation tab.
Contact the FMU supplier.