How can I run my Simulink model containing an FMU on Speedgoat hardware with Simulink Real-Time (SLRT)?

57 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
MathWorks Support Team 2025-10-27,0:00
编辑:MathWorks Support Team about 1 hour 前

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.
Beginning with R2025a, you can tune parameters in FMU blocks. For more information about how to tune FMU parameters, see Tune FMU Parameters Using Simulink Real-Time.
For more information on general FMU limitations in Simulink, as well as SLRT-specific limitations,  see the pages on Import FMUs and Apply FMUs by using Simulink Real-Time.

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 the FMU creator has an SLRT license and installation, they can directly use slrealtime.fmu.compileFMUSources to update the .fmu file 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?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Troubleshooting in Simulink Real-Time 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by