Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

souradipp76/OpenModelica-Arduino

Repository files navigation

OpenModelica-Arduino

Free library for interfacing Arduino using Modelica and Modelica_DeviceDrivers models in Linux. There is support for serial port.

Library description

The OpenModelica-Arduino library is an open source Modelica package for simulating circuit designs involving Arduino platforms based on AVR Atmega328P MCUs.

Main features:

  • Support for Linux.
  • (Soft) real-time synchronization of a simulation.

Please note that the library is known to work with

  • OpenModelica (partial support starting with OpenModelica v1.11.0, e.g.serial port).

Prerequisites

Compile and Install

  • Compile: Navigate to Library directory under Resources and to compile a source file named filename.c execute the following command
$ gcc –c –Wall –fPIC ../src/filename.c

To make a shared object file named libSerialComm.so execute the following

$ gcc –shared –fPIC *.o -o libSerialComm.so
  • Install and Run: Launch OMEdit and load the package Modelica_DeviceDrivers.Also, load the OpenModelica-Arduino package present in Arduino.mo file.Load the Arduino platform with the arduino_firmware.ino code.Create any model using the package and simulate.

Running Test Firmware

Test the package using test firmware provided.

  • Load the Arduino platform with the arduino_firmware.ino code.
  • Load the test model present in testfirmware.mo file along with Arduino.mo file in OpenModelica.
  • Simulate the model.If no error occurs,the package is good to go.

Running MDD Models

See the AVR package documentation under Modelica_DeviceDrivers -> EmbeddedTargets -> AVR in OMEdit before running the MDD examples.

  • To run a Modelica_DeviceDrivers Blink example, navigate to MDD_build/Blink directory and execute the following command
$ ./blink.sh [port_no] [baudrate]
  • Running Manually: Executing Blink example within Modelica_DeviceDrivers EmbeddedTargets Package:- Put the runMDDAvr.mos file in a (build) directory and execute following commands on the command line:
$ omc --simCodeTarget=ExperimentalEmbeddedC runMDDAvr.mos
$ avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections Blink_main.c -o Blink -I /path_to_MDD/Modelica_DeviceDrivers/Resources/Include -I /usr/include/omc/c
$ avr-objcopy -O ihex -R .eeprom Blink Blink.hex
$ avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:Blink.hex

For further information: Visit https://build.openmodelica.org/Documentation/Modelica_DeviceDrivers.html.

Development and contribution

Main developers:

Contributions in shape of [Pull Requests] are always welcome.

The following people have directly contributed to the implementation of the library (many more have contributed by providing feedback and suggestions):

  • Manas Ranjan Das (project mentor), contribution in bug fixes,error removal etc.

About

Interfacing Arduino with Openmodelica

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /