Error exporting Simulink model as FMU in function 'fmi2Instantiate'

60 vues (au cours des 30 derniers jours)
Bruno Flores Ramos
Bruno Flores Ramos le 7 Mai 2019
Modifié(e) : Kautuk Raj le 4 Déc 2024
I have a user defined block on Simulink which contains an script. It has two inputs and an output, and works perfectly if I simulate on simulink. When create a project from the model and export it as FMU to use it on a different software, it does not work. I have tried to import that FMU into simulink again as it is shown in the picture bellow and it gives me the following error: Error in supplied FMU: An error occurred in function 'fmi2Instantiate' for block 'discretetest/FMU' during simulation. To view debug logs, open FMU log file. For more information, see the FMU troubleshooting documentation.
When I open the FMU log file, it says:
# Debug Logging enabled for block 'discretetest/FMU'
Log from FMU: [category:logStatusError, status:fmi2Error] Cannot find available MATLAB session open for co-simulation.
Log from FMU: [category:logStatusError, status:fmi2Error] fmi2Instantiate: Cannot find or connect to existing MATLAB session.
How can I solve this problem? I need to be sure it works testing it on simulink back again to use it on another software.
  4 commentaires
na li
na li le 9 Déc 2019
Modifié(e) : na li le 9 Déc 2019
Did you resolve this issue? I have same problem when using FMU file co-simulation which export by matlab simulink. The logger message is "Cannot find available MATLAB session open for co-simulation". I confused what is matlab session for co-simulation?
Tom Bernand
Tom Bernand le 20 Fév 2020
@na li. The solution is very easy.
You have to open a new instance of matlab and type in the command: "shareMATLABForFMUCoSim".
Then go back to the first instance and import the fmu model normaly, now it should work fine.

Connectez-vous pour commenter.

Réponses (1)

Kautuk Raj
Kautuk Raj le 4 Déc 2024
Modifié(e) : Kautuk Raj le 4 Déc 2024
To resolve the issue with your FMU in Simulink, you need to set up a separate MATLAB instance to act as the slave session for co-simulation.
Begin by launching a new MATLAB session and executing the command shareMATLABForFMUCoSim. Make sure this session remains free from any other running scripts or models.
Next, open another MATLAB session of the same release. In this second session, load the Simulink model containing your Tool-Coupling FMU and proceed to simulate it. This approach ensures that the FMU utilizes the first MATLAB session for co-simulation, allowing it to function correctly without errors.
For more details on this, you can refer to the MathWorks documentation from the latest release (as of now, R2024b): https://www.mathworks.com/help/simulink/ug/export-model-as-tool-coupling-fmu.html

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by