Skip to content
Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, MQTT, shared memory, AD/DA converters, serial port and other devices.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, MQTT, shared memory, AD/DA converters, serial port and other devices.

Library description

The Modelica_DeviceDrivers (MDD) library is an open source Modelica package 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, MQTT, 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

Build status

Build Status

Current release

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, but autoBufferSize 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

Release notes

Bug fix releases usually won't have release notes, so please use the download link from above to get the latest release including bug fixes.

  • Version v1.6.0 (2018-10-06)
    • Support for MQTT (Message Queuing Telemetry Transport protocol) client communication (see #130, #256).
    • Utility function to retrieve MAC address (Utilities.Functions.getMACAddress, see #255).
    • Utility function to generate a UUID (Utilities.Functions.generateUUID(), see #244).
    • Number of received bytes in UDPReceive block is provided as output (see #236).
    • Scalable real-time synchronization (see #215).
    • Adaption of the new Modelica Association license for libraries: The 3-Clause BSD License (see #238, #264). The C-code parts of the library were already BSD 3-Clause licensed, but the Modelica code was licensed under the Modelica License 2. Since Modelica Association projects, most notably the Modelica Standard Library (MSL), changed from Modelica License 2 to the BSD 3-Clause license, the Modelica_DeviceDrivers library follows this development.
    • Other (minor) fixes and improvements.
  • Version v1.5.1 (2017-09-19)
    • Bug fix for variable name spelling error in Blocks.InputDevices.JoystickInput (#224)
  • 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)
    • Bug fix 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).
    • Improved Modelica compatibility: Fixed the use of conditionally enabled variable procPrio outside of connect in Blocks.OperatingSystem.SynchronizeRealtime and ClockedBlocks.OperatingSystem.SynchronizeRealtime.
    • Improved 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 Thomas Beutlich).
    • 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 bug fixes and improvements.
  • Version v1.0 (2012-10-17)
    • Initial release v1.0_build5 with improved documentation


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 3-Clause BSD License.

Development and contribution

Main developers:

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):

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.