Apply Functional Mockup Units with Simulink Real-Time

After you create a model that contains an FMU block, you can build and download the model to a target computer by using Simulink® Real-Time™. The following limitations apply:

  • Simulink Real-Time supports FMU blocks for Co-Simulation mode. Simulink Real-Time does not support FMU blocks for Model Exchange mode.

  • Simulink Real-Time does not support FMU blocks within a referenced model. FMU blocks must be at the top level of the model.

  • Simulink Real-Time generates a mask dialog box that contains both numerical-valued and string-valued parameters. However, Simulink Real-Time generates code for only numerical- valued parameters.

To convert a Simulink model that contains FMU blocks to a Simulink Real-Time model, set the model Configuration Parameters to values compatible with real-time execution:

  • In the Code Generation pane, set System target file to slrt.tlc.

  • In the Solver pane:

    • Set Type to Fixed-step.

    • Set Fixed-step size to a step size compatible with the real-time requirements of your model.

You can then build and download the model to a target computer and run the real-time application. The build and download process downloads the required FMU binary files.

To open an example model that contains FMU blocks running in Simulink Real-Time, type dslrt_bouncing_cs in the MATLAB® Command Window.

Build Considerations

When you build an FMU, dependencies on external DLLs are an important consideration. For example, if the compiler command line does not provide the MT flag, the linker links the .obj file with MSVCRT.lib. This library depends on many DLLs that are unavailable on a Simulink Real-Timetarget computer.

The MT flag on the compiler command line makes the real-time application use the multithread, static version of the run-time library. With MT, the compiler places LIBCMT.lib into the .obj file, so the linker uses LIBCMT.lib to resolve external symbols.

To build a FMU for a Simulink Real-Time real-time application, in the makefile to build a FMU, change from:

cl /wd4090 /nologo %DEF% ..\%1\%1.c /I ..\. /I ..\..\%FMI_DIR%\include

Change to:

cl /MT /wd4090 /nologo %DEF% ..\%1\%1.c /I ..\. /I ..\..\%FMI_DIR%\include

Note

Note: Simulink Real-Time supports FMU blocks that comply with FMU v1.0. Blocks complying with FMU v2.0 are not supported.

See Also

Related Topics

External Websites