This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Implement an FMU Block

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.

  1. Create a model and add the FMU block.

  2. 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 slprj/_fmu/fmu_name folder and unpacks the contents of the FMU file into this folder, which optionally include:

    • 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.

Explore the FMU Block

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 slexCoSimMassSpringFMU file.

Parameters Tab

Lists the FMU block parameters. Edit the values as necessary. You can edit the elements of a structure parameter by expanding the tree view.

Simulation Tab

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 slprj\_fmu\_logs_modelname\modelname_blockname.txt

    • 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.

Input and Output Tabs

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:


Change Block Input, Output, and Parameter Structures

You can change the layout of FMU block input ports, output ports, and parameters with these parameters:

FMUInputMappingChange hierarchy of input ports.

'Flat' — Separates input into individual signals.

'Structured' — Combines input into a structure of signals (bus).

FMUOutputMappingChange hierarchy of output ports.

'Flat' — Separates output into individual signals.

'Structured' — Combines output into a structure of signals (bus).

FMUParamMappingChange hierarchy of parameters.

'Flat' — Separates parameters into individual parameters, listed by the parameter name and value.

'Structured' — Combines parameters into a structure of parameter values (struct).

Use the get_param and set_param functions to set these values. For example, assume a block parameter tab with a structure construct:

The parameters are contained in a struct. To list the parameters individually, set the FMUParamMapping property to 'Flat':

set_param(gcb,'FMUParamMapping', 'Flat')

Timing Considerations

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.

Troubleshooting FMUs

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.

See Also

Related Topics

External Websites