Skip to content

Latest commit

 

History

History
173 lines (93 loc) · 7.54 KB

Documentation.md

File metadata and controls

173 lines (93 loc) · 7.54 KB

Installation

Environment Setup

Edge Device

The following apps must be installed on your IED in order to complete this guide:

ied01

PLC Program

Download the provided TIA Portal V17 project into your PLC. It was originally compiled for a CPU 1212C FW V4.4, so you may need to adjust the device settings if you're using a different device. In case no PLC or simulation is available, you can use Flow Creator. Once running, the Data Block GlobalDB_LiveTwin [DB62] contains two variables of data type Real: pump_speed is the value that will be used as input for the simulation, and flow_rate_l_min is the calculated flow rate in l/min that will be written back to the PLC from LiveTwin.

Databus Configuration

Configure a user in the Databus configurator and give this user permission to publish and subscribe to the topic ie/#. This is where the data will be exchanged between the S7 Connector and LiveTwin.

databus01

S7 Connector Configuration

Next, we need to configure the two data points in the S7 Connector. Start by configuring the Databus credentials (created in the previous step) in the upper left corner.

s701 s702

Add a new data source. With the provided TIA Portal program, an S7+ connection should be configured as follows (substitute the PLC IP address for your own):

s703

The following two data points are used in this example. Note the Name, Address, Data Type, Acquisition Cycle, and Access Mode (Read or Read & Write).

s704

Model Import in LiveTwin

This guide shows two different ways to import the Simulink model into LiveTwin. The first option is to use SIMATIC Target and export the model directly from a running Simulink instance to a running LiveTwin instance. The other way is to export the model as a .zip file and later upload it in the LiveTwin WebUI (the procedure used to generate the provided file is described in this guide).

SIMATIC Target and Simulink

If you want to try out the model in Simulink, you'll need to initialize the parameters by running the provided .m file in Matlab.

simulink00

Open the Simulink model and go to the Settings page.

simulink01

In the Code Generation tab, select the SIMATIC Target based on Simulink Coder as your target.

simulink02

In the SIMATIC Target options, choose LiveTwin for Industrial Edge and enter your Edge Device IP (with /livetwin), username, and password. Then, connect to the LiveTwin application.

simulink03

In the Engineering Integration tab, configure your LiveTwin Template and Project accordingly. Cyclic time can be adjusted later in the app as well.

simulink04

In the Accessibility tab, activate the checkbox.

simulink05

To upload your model to LiveTwin, go to the Simulink Coder App in Simulink and click Generate Code. In LiveTwin, the model will be uploaded as a template and a project based on this template will be created.

simulink06

Exported .zip File

In case you don't have access to or don't want to use Matlab Simulink and SIMATIC Target, you can simply upload the provided .zip file in the LiveTwin WebUI. Start by creating a new template like in the screenshot:

zip01

zip01

The model will be uploaded to LiveTwin.

zip02

Create a new project based on your template according to the screenshot:

zip03

Model Configuration in LiveTwin

Once a LiveTwin project has been created, you will have to configure the connections. Start by going to the Instance Settings.

livetwin00

In the Server Settings tab, configure your Databus credentials. The output topic is not strictly necessary.

livetwin01

In the Inputs/Outputs window, configure first the pump_speed input with the data source and variable name you used in the S7 Connector:

livetwin02

And then go to the next page and configure the flowrate_lmin (lowercase "L" for "liters") output:

livetwin03

Make sure that the Tag Names given here match the names of the variables that were configured in the S7 Connector.

To obtain sensible results, you can adjust the model parameters pressure_pipe_length and pressure_pipe_outlet_height, for example as follows:

livetwin04

Apply the changes. The model is now configured and ready to run.

Usage

Running the Model in LiveTwin

Start your model instance:

livetwin05

in the Monitoring window (left menu), open the chart for your running instance:

livetwin06

Select the relevant variables to monitor:

livetwin07

Start Update in the upper right of the monitoring window. You should now see the input and output variables with changing values.

livetwin08

In TIA Portal, you can go online on the PLC and observe that the result flow_rate_l_min has been written back to the PLC from LiveTwin.

livetwin09

The flow rate has thus been indirectly measured based on a Simulink model and the measured pump speed, removing the need for a hardware sensor.

Input Generation in Flow Creator

In case you have no PLC available, you can also run the LiveTwin model in Flow Creator mode and provide inputs within Flow Creator directly. You can use the provided flow to simulate input values.

In order to use Flow Creator, you have to select Flow Creator as the model type during project creation:

fc01

Import the provided flow and edit the LiveTwin node:

fc01

Select the model project you have created in LiveTwin:

fc01

Use the button to start or stop the instance:

fc01

You can then view the running model in the Monitoring tab of LiveTwin as usual, or observe the outputs in the "Output" debug node in Flow Creator.