MATLAB Answers

Why do I have issues with an imported/exported FMU in Simulink and how to resolve them?

54 views (last 30 days)
Why do I have issues with an imported/exported FMU in Simulink and how to resolve them? This is a short summary about common issues and how to troubleshoot them.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Jul 2020 at 4:00
Edited: MathWorks Support Team on 13 Jul 2020 at 19:04
How to export a FMU in general?
The information about how to export a FMU in Simulink you can find here:
Please be aware, that the process in R2018b is different than the one you can find above. So if you use this version, please refer to this page in our documentation:
How do I debug a FMU error or how to get the actual error message?
In order to debug a FMU, please enable the "FMU debug logging". You can find this in an FMU block in the "FMU Settings (Co-Simulation)" pane.
There please click on "Enable FMU debug logging" and "Redirect debug logs to:" Display.
Then you can see the error messages in the Diagnostic Viewer.
The errors can look like the following (or similar):
# Debug Logging enabled for block FMU_test_bus/FMU
Component:Simulink | Category:Model
Log from FMU: [category:logStatusError, status:fmi2Error] No available MATLAB session can be found.
Component:Simulink | Category:Model
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2Instantiate: Cannot find or connect to existing MATLAB session.
What to do if I see an error?
Here are some troubleshooting steps:
1. Check if the FMU was exported in the Simulink release, you want to use the FMU with. That means, a Simulink FMU exported in Release R2018b can be used in R2018b. If you upgrade, please export the FMU again, to reuse it in a newer release.
2. Please check if you have started a MATLAB slave session already. Therefor please see the documentation above. Starting in R2019a you have to run the following command:
>> shareMATLABForFMUCoSim
3. Before exporting the FMU using the "Share" option in Simulink, please check if there are slxc-files in the folder with the name of your model. If yes, please also add this slxc-files to your project. They are caching the usage of variables in the model and this speeds up the simulation (but this is not necessarily needed)
4. If you are using data from your workspace or data dictionaries. Please also add them to your project.
5. If these data is not being loaded during runtime of your simulation and has to be there for the model initialization, you have to load the data during project startup. This can be done by a project Startup-function or you can use the "Run at Startup" functionality. Please read through:
6. Check if the "Communication step size" of your FMU is set to a value which is not working with your original Simulink model. You can find this in the "FMU Settings (Co-Simulation)" pane.
7. If the steps above are not resolving it for you, then please create a Technical Support request:
Here you can see how the steps in 5. look like: Right click on the mat-file which has to be loaded and click "Run at Startup"
If you did it correctly, you see a small icon under "Status" and you have to option to "Remove from Startup" (doing the right click).
How to automatize the adding of slxc-files?
There is a way for you to automate this file addition process, with some initial setup work.
1.Create a startup script (.M file) that runs every time the project is opened. Details:
2. In this script, you will want to scan your project folders for the filetypes you want to add to your project. Details:
3. Add either of these functions to your script, using the information from the file search above:
"addFile(proj,fileorfolder)" details:
<http://please%20refer%20to%20these%20links%20for%20details:%20https//www.mathworks.com/help/simulink/slref/addfile.html https://www.mathworks.com/help/simulink/slref/addfile.html>
"addFolderIncludingChildFiles(proj,folder)" details:

  0 Comments

Sign in to comment.

More Answers (0)


Translated by