WOLFRAM

OPC UA Tank System

This example demonstrates how to use OPC UA communication in a System Modeler model of a simple tank system. With OPC UA, you can build a digital twin that securely exchanges live data between simulations and real hardware. OPC UA is a secure, robust and scalable communication protocol used in many industries worldwide.

To run this example, you'll need

The latest versions of System Modeler and Mathematica.

Please make a selection:

Get a
free trial
Continue
with download

Why Is OPC UA Useful Together with System Modeler?

Integrating System Modeler’s modeling capabilities with real-world objects in real time enables the creation of digital twins. Using OPC UA, safe communication between hardware—such as a Raspberry Pi or a PLC—and simulation models becomes possible.

Communication Using the OPC UA Library

The example model consists of a simple tank system that can communicate through the OPC UA protocol. The measurement of the liquid level of the first tank is written to a real-valued node on the OPC UA server. This value is then read by another component, to be used as a reference for the liquid level of the second tank. This setup forms a basic digital twin of the tank process.

The diagram view of the tank system using OPC UA communication.

Integrating OPC UA communication in System Modeler models lets industries using OPC UA connect signals directly into a model with live data. That opens up many possibilities when it comes to control theory, signal processing and much more.

How Does It Work?

The System Modeler components defined in the OPC UA Modelica library are using external C code to call functions to an implementation of the OPC UA Library in C code. Through the OPC UA components in System Modeler, values can be both written and read to nodes on an OPC UA server. Since OPC UA is multiplatform, compared to OPC Classic, the OPC UA server can also run on small chips or on a Raspberry Pi, for example.

External C Code

By calling external C code, System Modeler can communicate live to any compatible external hardware, using OPC UA.

Plot over both tank levels over time. The first tank starts full (1 m) and then gets drained. The measurement of the liquid level in the first tank is being written to the server at a sample rate of 0.2 s. The bottom tank uses the measurement of the first tank as the reference value for its liquid level, which can be seen in the bottom plot.

Digital Twin with OPC UA

Use the industrial communication protocol OPC UA in System Modeler to create live, data-driven digital twins of real systems.