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

Openmodelica model for simulation

Openmodelica model for simulation

Hi,
I m new to modelica. The aim of my project is to build an aircraft math model in modelica and use the generated CPP code to build a project. To this I can add my real time code and run in a flight simulator. I built a sample modelica .mo model and compiled using gcc. I m now unable to directly build it in eclipse ide. Lots of syntax errors. Whether MDT is useful in such cases?
Please suggest any useful links or guides.

Sorry if the post is silly. Did a lot of reading and got more confused.

Re: Openmodelica model for simulation

Hello archanahebbar

The simplest way (and maybe the only) to use your C code is using external functions:
http://book.xogeny.com/behavior/functions/external/
This means that Modelica model calls your functions, but your functions cannot call your Modelica model.
However you can launch your Modelica model .exe and connect to it through sockets (much easier than using CORBA interface).

Best regards
Koldo

Re: Openmodelica model for simulation


Thanks. Will try that.

Any example for adding socket interface would be useful. Also, in this project I am restricted to use C++ & UDP sockets and hence cannot use COBRA interface.

Re: Openmodelica model for simulation

Hello archanahebbar

You have to do a simple communication between two programs using sockets.

The first I would do is to prepare and test two simple C /C++ programs, one as sender and other as receiver.
Then I would include the sender code in a simple Modelica model to try it.

You can find some details here:
http://blog.kempj.co.uk/2013/12/modelic … t-library/

Good luck
Koldo

Edited by: Koldo - Jun-20-17 06:46:37

Re: Openmodelica model for simulation

Thanks Koldo.

But the sample app doesn't work for me because of version mismatch.

In the meantime I have installed eclipse and tried to compile omc generated c++ files. After many corrections made in the individual c++&.h files, I m struck with systemdefaultimplementation.h. None of its class members are identified by my project. I have verified the path to be correct. Have anybody faced similar problem?  I m using release 1.11 32 bit build.

My intention is to generate a standalone executable where modelica generated files get embedded with my udp code, along with openmodelica's gcc compiler. I also plan to use FreeRTOS to add real time patch later.

Please let me know whether anybody have faced similar issue with this .h file.

Thanks.

Re: Openmodelica model for simulation

Sorru archanahebbar

The only way I know to connect an OpenModelica simulation to do a co-simulation or a software/hardware in the loop is using sockets and including them through external functions inside your model.

In the past I tried to compile omc generated files adding personal patches but;
- I could not do it
- Probably I would not comply with license

Best regards
koldo

Edited by: Koldo - Jun-23-17 20:33:00

Re: Openmodelica model for simulation

Ok.

But there should not be any compliance issue because I m not doing anything with openmodelica code. I m just using the files for my model that r generated by openmodelica. I m now unable to understand - what is the purpose of code generation then? In matlad, we take the Matlab generated code and pluginto our projects.

Thanks.

Re: Openmodelica model for simulation

Hi all,

Can some please tell me the configuration process of SocketCAN in OpenModelica. If possible please attach an example program of Modelica(.mo file) for SocketCAN under Modelica_DeviceDrivers.
The inbuilt example of SocketCAN in OpenModelica itself is throwing multiple errors.

Thank you.

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