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.

Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


The master and the latest release has been updated to the Modelica Standard Library 4 (MSL 4, released 2020-06-04). Please use the Modelica_DeviceDrivers release v1.8.2 (last MSL 3 release) until your tool is updated for MSL 4.

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.



  • 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, 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 may not have release notes, so please use the download link from above to get the latest release including bug fixes.

  • Version v2.0.0 (2020-06-08)
    • Migrated from Modelica Standard Library 3 (MSL 3) to MSL 4 -> Non-backwards compatible release!
    • However, apart from the MSL 4 dependency this release is compatible to previous releases and no update of user libraries is necessary apart from migrating to MSL 4.
    • Enhancements:
      • Added all license files to better assist tool vendors in distribution of source or binary files (#313).
      • Updated 3rd-party library paho.mqtt.c to v1.3.4 (#320).
    • Bug fixes:
      • Fixed small issues in the SBHS Board example (#318).
  • Version v1.8.2 (2020-03-26)
    • Updated Linux MQTT binary dependencies. The updated libraries are compiled with the -fPIC flag, which fixes a related FMU generation problem (#306).
  • Version v1.8.1 (2020-02-26)
    • Fix declaration of MDD_spaceMouseGetData in external C code (#305).
  • Version v1.8.0 (2020-01-11)
    • TCP/IP server communication (#296). In addition to the existing TCP/IP client blocks (see #78) there are now also blocks for setting up a TCP/IP server. See examples Blocks.Examples.TestSerialPackager_TCPIPServer and Blocks.Examples.TestSerialPackager_TCPIPServerMultipleClients.
    • Enhanced real-time synchronization block (#290). Added an enhanced real-time synchronization block (Blocks.OperatingSystem.RealtimeSynchronize) and deprecated the existing block (Blocks.OperatingSystem.SynchronizeRealtime). The deprecated block is known to not working well with recent Dymola versions (e.g., Dymola 2020). The new RealtimeSynchronize block supports a sample-based real-time synchronization mode which is recommended for more deterministic, less solver sensitive behavior. See example Blocks.Examples.TestRealtimeSynchronize.
    • An utility block for debugging purposes which prints a message when triggered by an event (#289).
    • Updated 3rd-party library paho.mqtt.c to v1.3.1 (#293)
    • Bug fixes:
      • Fixed Spacemouse not working under Windows 10 bug (#289).
      • More similar behavior for getMACAddress() in Windows and Linux (#263).
    • Other (minor) fixes and improvements.

For information about previous releases, see Release Notes of Previous Versions.


Use the following BibTeX lines to cite the Modelica_DeviceDrivers library

  Title = {Towards a Standard-Conform, Platform-Generic and Feature-Rich Modelica Device Drivers Library},
  Author = {Thiele, Bernhard and Beutlich, Thomas and Waurich, Volker and Sjölund, Martin and Bellmann, Tobias},
  Booktitle = {Proceedings of the 12th International Modelica Conference},
  Year = {2017},
  Address = {Prague, Czech Republic},
  Editor = {Kofránek, Jiří and Casella, Francesco},
  Month = may,
  Pages = {713--723},
  Doi = {10.3384/ecp17132713},


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

Development and contribution

The master branch of the Modelica_DeviceDrivers library should work out-of-the-box when loading the library into a supporting Modelica tool. The branch contains the necessary external C libraries as pre-build binaries below folder Modelica_DeviceDrivers/Resources/Library.

If you need to build the external C libraries from the sources, clone the repository with

git clone --recursive
git submodule update --init --recursive

and see Modelica_DeviceDrivers/Resources/

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


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.