Problem with operating two FMU blocks in one simulink simulation

4 次查看(过去 30 天)
Hello,
i have a problem with the co-simulation of two fmu blocks. Each of the fmu-block only contains a matlab-system function and some in- and outputs.
When i simulate the converted simulink model (fmu-block 1 and 2) of each function separatly, everything works fine. Also the whole system is working when i connect both mathlabs-system-functions in one simulink model. But when i connect the two fmu blocks in an other model (as seen below in the sketch), simulink throws an error.
This is the error message i recieved:
"Error in supplied FMU: An error occurred in function 'fmi2Instantiate' for block 'Sim_FMU5' during simulation. To debug your FMU file, select the "Enable FMU Debug Logging" check box. For more information, see the FMU troubleshooting documentation."
The solver is in each model the same, also the step time. The Debug Logging didn´t help to find the mistake.
Can somebody help me?
Tank you for your support :)
Kind regards
Tobias

回答(1 个)

Yash
Yash 2025-2-16
I tried creating a simple example model with two Co-Simulation FMUs where output of first FMU is fed as input to the second FMU. Here are the details:
  • gain1.slx: Base model for first FMU. Simple model with inport, gain (x2 multiplier) and outport
  • gain1.fmu: FMU obtained by exporting gain1.slx to Co-Simulation FMI Version 2.0
  • gain2.slx: Base model for second FMU. Simple model with inport, gain (x3 multiplier) and outport
  • gain2.fmu: FMU obtained by exporting gain2.slx to Co-Simulation FMI Version 2.0
  • modelWithTwoFMUs.slx: Model with a constant block followed by the two FMUs connected in series
All three simulink models share the same solver settings (Fixed-step ode3 with 0.1 step size). The top model (modelWithTwoFMUs.slx) is working correctly where the input gets multiplied twice after passing through the two FMUs. I have attached these files. All the files were created using MATLAB R2019a.
Since you are also ensuring the same, I would suggest to debug the logic of the MATLAB function you are trying to implement.
Also try using an external debugger to debug the function fmi2Instantiate as stated in your error message.

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by