-
Open TIA portal and open the project: TIA project.
-
Download the PLC program to PLC (It is also possible to use PLCSIM advance).
-
(Optional) Feel free to simulate and configure provided HMI (HMI_TP700/Screens/Applications/51_LiveTwin) to control the PLC program.
Note: Matlab 2019b is used in this example
If you are interested in exporting your own Simulink model, the documentation can be found here: documentation
The Simulink model for this use case is already in this repository: Shock-sensor-model
Prerequisities:
- LiveTwin and SIMATIC Flow Creator applications are running on the Industrial Edge Device
-
Open LiveTwin UI and go to the "LiveTwin studio" section located in the left main menu.
-
Go to the Libraries are and click on the "plus" button to add a template. New tab pop up in the working area.
- Navigate to the "New Template" area and fill the form:
- Choose a "Name" for your template
- Select the "Model Type" (in this case Simulink)
- Browse in the "Model File" for the exported .zip file of the Simulink project.
You can find Simulink project here: livetwin template
- Click "Save". The new template is generated.
- Go to the "Projects" section in the "LiveTwin studio" menu and click on the "plus" button to add project.
- Navigate to the "Projects" area and fill the following information:
- Select your "Template"
- Select "LiveTwin" as a "Project Type"
- Give the project a name
- Choose "Simulation Step" and "Project Cyclic Time" based on your requirements
- Click "Save&Close". The new LiveTwin project is created.
In order to finish this automation task, we need to read/write data from/to PLC. In this use case, we will use SIMATIC S7 Connector system application to establish connection with PLC using S7 and OPC comunnication protocols. The SIMATIC S7 Connector is also connected to the IE Databus and LiveTwin can then access the data from IE Databus via the MQTT protocol. In order to establish this infrastructure, follow these instructions:
-
Go to the "My Installed Apps" section of the Industrial Edge Management System.
-
Click on the "IE Databus" application icon.
-
Click on the "Update Configuration" button, new configuration file appears.
-
Select you edge device and click on "Launch Configurator", IE Databus Configuration window appears.
-
Configure the following information:
User name: edge
Password: edge
Topic: ie/#
Permission: Publish and Subscribe
For performance purposes, we will use the S7 communication protocol for high frequency data simulating vibrations and OPC UA protocol for low frequency data. In order to establish connection with the PLC, follow these instructions:
- Go to the "My Installed Apps" section of the Industrial Edge Management System.
- Click on the "SIMATIC S7 Connector" application icon.
- Click on the "Update Configuration" button, new configuration file appears.
- Click on "Add Data Source" button, select "Simatic S7 protocol" and provide following information for this data source:
Name : plc
IP Adress: IP of PLC, for example 192.168.80.20
PLC Type: 1200/1500
- Click the "plus" button on the right side of the data source to add a tag and input:
-
Acceleration in direction y:
Name : accy Adress: %DB3.DBD2 Data Type: Real Acquisition Cycle: 100 ms Acquisition Mode: CyclicOnChange Access Mode: Read
-
Acceleration in direction x:
Name : accx Adress: %DB3.DBD6 Data Type: Real Acquisition Cycle: 100 ms Acquisition Mode: CyclicOnChange Access Mode: Read
- Click on "Add Data Source", select OPC-UA and fill the following information:
Name : plcshock
OPC-UA URL: opc.tcp://192.168.80.20
Port Number: 4840
Messaging Mode: None
Authentication Mode: Anonymous
-
Click on the file icon on the right side of the data source to enable the "browse" function for tags.
-
Select "HMIHandleDB_resetShock" tag and configure the tag with these information:
Data Type: Real
Acquisition Cycle: 1 s
Acquisition Mode: CyclicOnChange
Access Mode: Read & Write
- Go to the "Settings" option in the right top corner and fill the databus properties:
UserName: edge
Password: edge
Bulk publish: Disabled!
- Click "Deploy" and then "Start Project" buttons.
-
Go to LiveTwin instance settings. The new configuration window opens.
-
For the input signals configure:
-
Accelx:
Data Source: plc Tag Name: accx
-
Accely:
Data Source: plc Tag Name: accy
- Go to the "Server Settings" (connection to IE Databus) and insert the Databus properties:
Username: edge
Password: edge
Output topic: ie/status
Uncheck the "Bulk publish" option!
Note: The output topic will be used in Flow Creator
- Click "Save&Close".
In order to send the shock status back to the PLC we have to create some logic to evaulate whether the shock has been detected or not. We can use the SIMATIC Flow Creator application to do that.
-
Open user interface of the SIMATIC Flow Creator application.
-
Import the flow.json Flow Creator project.
-
Deploy the application.
To run the simulation follow these instructions:
- Make sure that PLC is connected to the Industrial Edge Device and TIA project is downloaded and running on the PLC
- LiveTwin project settings are configured
- SIMATIC S7 Connector and IE Databus system applications are configured
- SIMATIC Flow Creator project is deployed
- Start the simulation of the LiveTwin project
- Enable vibrations on the PLC ("HMIHandleDB" -> "enableVib" -> "True")
- Access the dashboard in the LiveTwin UI
- The shock status is send back to PLC. If a shock was detected, the value of the tag "HMIHandleDB" -> "resetShock" is set to 1.