WOLFRAM SYSTEM MODELER

ModelPlug

Connecting to the real world with Arduino

Package Contents

GettingStarted

Step-by-step guide to running your first model using ModelPlug

Examples

A collection of examples to help you get started

Boards

Components to connect to the Firmata boards

Pins

Components to access the board I/O

Devices

Devices using I2C protocol

Internal

Internal classes used by the ModelPlug library

Library Units and Quantities

Units All units provided by ModelPlug
Quantities All quantities provided by ModelPlug

Information

What Is ModelPlug?

ModelPlug is a library that allows you to connect your simulations with the real world. It uses an Arduino board (or compatible) to send analog and digital signals to physical devices and receive signals from them.

What Can You Do with It?

  • Interact with your model by using buttons, switches, knobs, etc.
  • Input sensor information, for example, about light, temperature, position, pressure, etc.
  • Use actuators like motors, servos and relays.
  • Quickly prototype your system by using System Modeler blocks.

With ModelPlug, you can combine simulation models and real hardware. For example, you can get data from your hardware, design a control and test it in real time.

You can build a real control panel and use it to control your simulation models.

Overview of the Components

ModelPlug provides the following components:

   Inputs  
Analog input Reads analog values from the pins  
Digital input Reads digital values from the pins  
   Output  
Analog output Writes analog values to the pins  
Digital output Writes digital values to the pins  
Servo control Writes the angle to servo motors  
   Board Handlers  
Arduino Connects to Arduino boards like Arduino Uno, Arduino Mega 2560  
Arduino Leonardo Connects to Arduino Leonardo boards and boards using native USB  
StandardFirmata Connects to Arduino-compatible boards  
CustomFirmata Connects to any board supporting Firmata  

How Does It Work?

ModelPlug connects with the boards using USB serial communication. In order to configure, read and write to the board, ModelPlug uses the Firmata protocol v2.3 (http://www.firmata.org). This protocol allows you to connect not only to Arduinos, but also to many boards compatible with Arduino. Examples of other boards supporting the Firmata protocol are:

  • Teensy Development Board: Using AVR or ARM processors
  • chipKIT: Using PIC32 processors

ModelPlug wraps the functionality of Firmata by providing easy-to-use Modelica models that you can connect in your simulations.

Limitations

  • ModelPlug requires a board with Firmata Version 2.3 or higher.
  • Currently ModelPlug does not support sensors that communicate through SPI with the board.
  • The minimum synchronization interval is 1 ms; therefore, ModelPlug cannot have a sampling interval smaller than that. The standard Firmata allows a minimum sampling interval of 10 ms.
  • ModelPlug uses a serial protocol; therefore, the transfer speed is constrained by the serial port speed. This can be problematic when reading or writing too many inputs/outputs with a small sampling interval.

Links

Ask questions about System Modeler and ModelPlug:
http://community.wolfram.com

Find out how to connect sensors and actuators to the Arduino:
http://playground.arduino.cc

Firmata protocol documentation:
https://github.com/firmata/protocol

The breadboard diagrams were created using Fritzing.
http://fritzing.org

Wolfram Language

In[1]:=
SystemModel["ModelPlug"]
Out[1]:=

Revisions

New in Version 2.0

  • Library compatible with Modelica Standard Library 4.0.0
  • Fix Modelica Language incompatibilities

New in Version 1.4.2

  • Support for Apple Silicon platform

New in Version 1.4.1

  • Fix compatibility issues on macOS
  • Fix Modelica Language incompatibilities

New in Version 1.4

  • Adds support for I2C devices
  • Includes documentation on how to connect to custom I2C devices

New in Version 1.3.1

  • Now compatible with Modelica library Version 3.2.3

New in Version 1.3

  • Added stored plots to examples for easy plotting of relevant variables
  • Now compatible with Modelica library Version 3.2.2

New in Version 1.2

  • Allows defining initial values in AnalogInput and DigitalInput Pins
  • Improved support for Windows 10