Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, shared memory, AD/DA converters, serial port and other devices.
The Modelica_DeviceDrivers
(MDD) library is an open source Modelica package under Modelica License 2 that interfaces hardware drivers to Modelica models. An overview of the library is provided in
Bernhard Thiele, Thomas Beutlich, Volker Waurich, Martin Sjölund, and Tobias Bellmann, Towards a Standard-Conform, Platform-Generic and Feature-Rich Modelica Device Drivers Library. In Jiří Kofránek and Francesco Casella, editors, 12th Int. Modelica Conference, Prague, Czech Republic, May 2017. Download
The library unifies previous developments concerning device driver support in Modelica, see Interactive Simulations and advanced Visualization with Modelica and Modelica for Embedded Systems (Modelica'2009 conference). The functionality covered by this library has been used internally at DLR for several years, such as for Driver-in-the-Loop simulation and for the DLR Robot Motion Simulator. The previously fragmented functionality was streamlined, improved, and extended to a coherent cross-platform library.
Main features:
- Cross-platform (Windows and Linux).
- (Soft) real-time synchronization of a simulation.
- Support for keyboard, joystick/gamepad, and 3Dconnexion Spacemouse.
- Support for a universal packaging concept to pack Modelica variables in a graphical and convenient way into a bit vector and transport such a bit vector via UDP, TCP/IP, LCM, serial I/O or shared memory (CAN support is prototypical available).
- Support of the Linux control and measurement device interface for digital and analog I/O (Comedi interface).
All device drivers are made available via external Modelica functions. Furthermore, high level interfaces on these functions are provided via Modelica blocks. The first interface uses Modelica 3.2 functionality only (when-clauses and sample-operator).
The second interface uses the synchronous language elements introduced in Modelica 3.3 and is based on clocks (works together with the Modelica_Synchronous
library).
- Internationalized
- Unit tests
- End-user documentation
- Internal documentation (documentation, interfaces, etc.)
- Existed and maintained for at least 6 months
Download Modelica_DeviceDrivers latest release
Please note that the library is known to work with
- Dymola,
- SimulationX (with
userBufferSize
all non-clocked communication blocks are working in SimulationX, butautoBufferSize
only works for external solvers CVode and Fixed Step solver and fails for BDF and MEBDF solvers, see #54 (comment)), - OpenModelica (partial support starting with OpenModelica v1.11.0 Beta 1, e.g., UDP, serial port, shared memory, LCM, keyboard).
If you tested the library successfully with another Modelica tool, please contact Bernhard Thiele or send a pull request that updates this README.md.
Bugfix releases usually won't have release notes, so please use the download link from above to get the latest release including bugfixes.
- Version v1.5.0 (2017-05-12)
- Important: A bug fix in the shared memory implementation for Windows potentially affects applications that adapted the (wrong) buffer layout (see #138)!
- Presentation of the library at the Modelica'2017 conference.
- OpenModelica (v1.11.0 Beta 1 and later) is now the third tool known to (partially) support the library (e.g., UDP, TCP/IP, serial port, shared memory, and LCM communication).
- Added support for sending and receiving of Lightweight Communications and Marshalling LCM datagrams (only the communication aspect of LCM is considered).
- Added support for TCP/IP communication for Linux (was already available for Windows).
- New top-level package
EmbeddedTargets
with a first prototypical support for the Atmel AVR family of microcontrollers (ATmega16 and ATmega328P (=Arduino Uno) are supported; currently only known to work with OpenModelica's ExperimentalEmbeddedC code generation, see documentation). - Bug fixes for the serial port support (#117, #118, #119, #127, #128).
- Bug fix for the byte order swapping logic (endianness, #203).
- Other (minor) fixes and improvements.
- Version v1.4.4 (2016-04-12)
- Bugfix release, no new features, but many improvements since version v1.4.0 (more than 70 commits since v1.4.0), so let's list some of the improvements...
- Uses latest version of Modelica Standard Library (v3.2.2).
- Changed the license of the external C code and header files to Simplified BSD License (the Modelica package parts remain under Modelica License 2).
- Impoved Modelica compatibility: Fixed the use of conditionally enabled variable
procPrio
outside of connect inBlocks.OperatingSystem.SynchronizeRealtime
andClockedBlocks.OperatingSystem.SynchronizeRealtime
. - Impoved Modelica compatibility: Fixed the invalid integer to enumeration type conversion in
HardwareIO
. - Fully specified the initial conditions for example models.
- Simplified the linking with system libraries (MSVC only).
- Added continuous integration for the external C code (thanks to Travis CI).
- Improved and updated documentation.
- Improved compatibility with the DLR Visualization Library.
- Improved support of automatic Code-Export from SimulationX 3.7.
- Fixes for the clocked communication blocks (added missing
byteOrder
support). - Other (minor) fixes.
- Version v1.4.0 (2015-09-01)
- Switched to semantic versioning.
- Migrated to new release process motivated by impact-on-library-developers.
- Added support for external trigger signals to trigger communication blocks.
- Added support to configure byte ordering in communication blocks.
- Added support for TCP/IP communication for Windows.
- Added serial port support for Windows (was already available for Linux).
- Added compiler support for MinGW and Cygwin.
- Added support for all 32 joystick buttons.
- Fixed Modelica compatibility of output buffers in communication blocks.
- Fixed multi-threaded access of UDP and shared memory communication for Windows.
- Fixed many small issues, particularly for improved compatibility with SimulationX.
- Version v1.3 (2014-05-19)
- Fixed many issues in order to support SimulationX (with the indispensable help of tbeu).
- Particularly, a SimulationX compatible wrapper DLL to give access to the external C functions was added.
- Added serial port support for Linux.
- Version v1.2 (2013-10-01)
- Adapted to the conventions of the Modelica Standard Library 3.2.1 and Modelica_Synchronous 0.92.
- Added utility functions to load parameters from a file.
- Version v1.1 (2013-04-24)
- Latest build (2013-09-20) uses latest Modelica Standard Library version 3.2.1 and Modelica_Synchronous version 0.92, but will also work with previous versions 3.2 and 0.91.
- Improved Modelica 3.3 standard conformance (hopefully completely standard conform by now)
- Included support for the Linux Controller Area Network Protocol Family (aka Socket CAN). This is considered an alpha feature. Therefore the API is not stable and testing has been very limited
- The CMake based build system for the external C sources of this library has been improved to be more robust and better documented.
- Bugs in the SerialPackager's AddString and GetString blocks have been resolved and new blocks AddFloat and GetFloat are now available.
- Some smaller additional bugfixes and improvements.
- Version v1.0 (2012-10-17)
- Initial release
v1.0_build5
with improved documentation
- Initial release
This Modelica package is free software and the use is completely at your own risk; it can be redistributed and/or modified under the terms of the Modelica License 2.
Main developers:
- Bernhard Thiele, release management and the Linux specific code
- Tobias Bellmann, most of the initial MS Windows specific code
- tbeu, various fixes and improvements, particularly SimulationX support
You may report any issues with using the Issues button.
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):
- Miguel Neves, human readable error codes for the Softing CAN interface.
- Dominik Sommer, code for Linux serial port support.
- Rangarajan Varadan, code for Windows serial port support.
- Dietmar Winkler, GitHub project setup, development services integration etc.