Using FMUs with SLRT: Support and limitations
SLRT supports FMUs only in Co-Simulation mode. Compatibility also depends on the FMI version and the MATLAB release you're using:
- FMI version 1.0: SLRT code generation supported from R2018a.
- FMI version 2.0: SLRT code generation supported from R2022a.
- FMI version 3.0: SLRT code generation supported from R2024b.
For more information on general FMU limitations in Simulink, as well as SLRT-specific limitations, please see the pages below:
Cross-Compiling the FMU for SLRT:
To deploy an FMU on SLRT, it must contain a binary that is compatible with the Real-Time Operating System (RTOS) used by SLRT:
- In R2020b and later, SLRT uses the QNX® Neutrino® RTOS. This requires compiling the FMU source code with the QNX Neutrino compiler (qcc/q++).
- In R2020a and earlier, SLRT uses the Windows-based On-Time RTOS.
Since R2022a, the cross-compilation process is greatly simplified with the slrealtime.fmu.compileFMUSources function, which compiles the FMU sources into an SLRT RTOS-compatible shared library file (.so) and packages it into the .fmu file. For a complete example and further details, refer to the documentation page: Compile Source Code for FMUs If the FMU creator cannot share the source code, they can compile the FMU binaries for the SLRT RTOS on their end and include the compiled .so file in the /binaries/slrt_x64 directory of the FMU. Note that the required compiler may be proprietary.
Keep also in mind that FMUs that rely on other external shared libraries (.so or .dll) must ensure those libraries are compatible with the SLRT RTOS. Moreover, these dependencies must not require runtime libraries that are unavailable for the SLRT RTOS.
Exporting an FMU from Simulink for use with Speedgoat hardware:
NOTE: The model creator needs Simulink Compiler to export standalone FMUs from Simulink, as well as Simulink Coder to include the source code.
To export a Simulink model as a standalone FMU for deployment with SLRT, make sure that the "Access source code from FMU" option is checked in the FMU Export dialog. By default, the FMU will be exported targeting grt.tlc and will not include a binary compiled for SLRT, so having the source code included is essential.
If you have an SLRT license and installation, you can directly use slrealtime.fmu.compileFMUSources to update the FMU with the SLRT-compatible binary. If SLRT is not available, this step can be performed by the FMU end user.
ALTERNATIVE WORKFLOW: If Simulink Compiler is not available, but the model creator has access to Simulink Real-Time, an alternative approach is to export the model as a protected model instead of an FMU. See: Can I use protected models with Simulink Real-Time?