Free library for interfacing Arduino using Modelica and Modelica_DeviceDrivers models in Linux. There is support for serial port.
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).
OpenModelica
(>= v1.11.0) (https://www.openmodelica.org/download/download-linux)Modelica_DeviceDrivers
(v1.5.1) (https://github.com/modelica/Modelica_DeviceDrivers/releases/tag/v1.5.1)
- 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 theOpenModelica-Arduino
package present inArduino.mo
file.Load the Arduino platform with thearduino_firmware.ino
code.Create any model using the package and simulate.
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 withArduino.mo
file in OpenModelica. - Simulate the model.If no error occurs,the package is good to go.
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.
Main developers:
- Souradip Pal, contribution to the Linux specific code
- Vanessa Singh, bug fixes.
- Disha Agarwal, various documentation.
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.