Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

FMU Import & Inputs/Outputs of FMU Block

FMU Import & Inputs/Outputs of FMU Block

Hi,

I'm very new into OpenModelica, so sorry if this is a very basic issue but I'm a bit lost.

I would like to use FMU blocks for co-simulation in my project and connect them to other blocks. In order to learn how to do it, I have installed the FMU SDK to start using example models of FMU, like bouncingBalls.fmu that I first run to compare it to the figure of the User's Guide (p.92). But when I use the FMU Import of the OMEdit, it doesn't appear the same thing as in the figure of the User's Guide. I mean, I don't get all the components in the Libraries Browser (left column) as in the figure of the User's Guide and I can't find out why. Am I missing something or am I doing it wrong?

And another question related to the same example. When I put the FMU block in a new model I don't know how to insert inputs/outputs. Can I do it directly in the Diagram View or do I have to change it in the code?

Thank you for your patience and hope you can help me!

Best regards,

Hugo

PS: I use version 1.9.1 Beta2 (r19512)

Re: FMU Import & Inputs/Outputs of FMU Block

The users guide is showing the old picture. I will update the users guide with the new picture.

You insert inputs/outputs to FMU block before adding it to new model. Normally you don't need to create inputs/outputs by hand, they will be generated automatically based on the inputs/outputs of your FMU.

Adeel.

Re: FMU Import & Inputs/Outputs of FMU Block

Thank you Adeel for your fast response. When will you upload the new version? If it's going to take some time, could you send me that picture please?

Regarding the second question, for example, if I want to connect a resistance to a FMU block as an input and a motor as an output (as in the picture attached), how can I create the ports of input/output in the FMU block in order to connect them? I haven't been able to find how to do it.

https://openmodelica.org/images/agorapro/attachments/4092/mini_I-O-FMU-block.jpg

Sorry for my ignorance and thank you for your time.

Hugo

Attachments:

Re: FMU Import & Inputs/Outputs of FMU Block

Hi,

I finally find out how to put I/O in a FMU block. But now, when trying to save after having modified something in the generated FMU of the 'BouncingBall' model, an error turns up:

Code:


[:0:0-0:0] Error: Failed to insert class fmi1CompletedIntegratorStep within BouncingBall_me_FMU.fmi1Functions;
the available classes were:
  Modelica.SIunits.ComplexPower
  Modelica.SIunits.ComplexAdmittance
  Modelica.SIunits.ComplexImpedance
  Modelica.SIunits.ComplexReluctance
  Modelica.SIunits.ComplexMagneticFlux
  Modelica.SIunits.ComplexMagneticFluxDensity
  Modelica.SIunits.ComplexMagnetomotiveForce
  Modelica.SIunits.ComplexMagneticPotentialDifference
  Modelica.SIunits.ComplexMagneticPotential
  Modeli...

And the same error with all classes: fmi1nextEventTime, fmi1EventUpdate, fmi1setString, fmi1GetString...

So I put everything as it was at the beginning but I got the same error. How can I fix it? Is it because I can't touch the code once the FMU is generated?

Thank you in advance.

Best,

Hugo

Re: FMU Import & Inputs/Outputs of FMU Block

There is a bug saving protected classes. In your code find text "package fmi1Functions" and above this line add "public" keyword then try to save the file.
I will try to fix the bug.

You should not change the generated FMU code. When you are creating the FMU at that time specify the I/Os. If your FMU has the I/Os then the generated code will automatically have the I/Os. Even if you manage to put I/O manually in the FMU block still maybe your model will not work correctly.

Adeel.

Re: FMU Import & Inputs/Outputs of FMU Block

Thank you Adeel! I added "public" but I got the same error, but anyways I have seen that, as you said, I should not change the generated FMU code. So if I need to change something, I will create a new FMU.

Now, I tried to use the FMU block of the bouncingball from the FMU SDK in a new model and I got an error when trying to simulate:

Code:


[:0:0-0:0] Error: Failed to open simulation result C:/OpenModelica1.9.1Beta2/share/doc/omc/testmodels/Test_res.mat: Too few rows in data_2 matrix

Also, in the Simulation Output window it says:

Code:


Process crashed
Simulation process exited with code -1073741819

Why does it happen? Is it because FMU SDK has something different in their FMUs that OM does not support?

I'm trying with this FMU SDK example because in my project I will have C code from Matlab/Simulink and in order to convert it to FMU I will use FMU SDK. Or is there another way to generate an FMU from C code?

Again, thank you so much.

Hugo

Re: FMU Import & Inputs/Outputs of FMU Block

Send me the FMU and I will see what is wrong. The bouncingBall FMU from FMU SDK should work. It is very simple example.

Adeel.

Re: FMU Import & Inputs/Outputs of FMU Block

Thank you Adeel. This is it.

bouncingBall.fmu

(The FMU SDK version is 2.0.3 and the bouncingBall.fmu is from "fmusdk\fmu10\fmu\cs\x64")

Hugo

Attachments:

Re: FMU Import & Inputs/Outputs of FMU Block

Ah you are talking about co-simulation FMU. We don't support import of co-simulation FMU even the users guide mention this "The support for FMI Co-Simulation 1.0 tool coupling is still under development."

Adeel.

Re: FMU Import & Inputs/Outputs of FMU Block

Oh ok. I thought you have it as a beta version.

Do you know any other open tool like OM that supports import/export FMUs for co-simulation, apart from FMU SDK?

Thank you.

Hugo

Re: FMU Import & Inputs/Outputs of FMU Block

Try JModelica http://www.jmodelica.org/

Adeel.

Re: FMU Import & Inputs/Outputs of FMU Block

Thank you Adeel! And thank you for all your fast and useful responses! I'm going to try with JModelica.

Best regards,

Hugo

Re: FMU Import & Inputs/Outputs of FMU Block

In my project also I have a C code and, to convert it to FMU, I would use the SDK FMU but I do not know how to use it, if you can explain how to convert this C code into FMU. Or is there another way to generate a UMF from code C?
Thank you
Mary

Re: FMU Import & Inputs/Outputs of FMU Block

I'm very new into OpenModelica, so sorry if this is a very basic issue but I'm a bit lost.


^Goldenslot^

There are 0 guests and 0 other users also viewing this topic
You are here: