OPCUA integration with SIEMENS TIA Portal + PLCSIM Advanced

This chapter explains the steps to create PLC tags and enable OPCUA communication between the Simumatik Gateway and PLCSIM Advanced. This will allow you to run the code programed in TIA Portal against a Simumatik system.

Versions of the programs are: - TIA Portal V16.0 - PLCSIM Advanced V3.0

Warning

Make sure the choosen PLC is compatible with OPCUA

In this example the data that will be transfered is:

  • 'inputs': A PLC input byte addressed to %IB10.
  • 'outputs': A PLC output byte addressed to %QB6.

The PLC chosen for this example is:

  • Short designation: CPU 1512C-1 PN
  • Article number: 6ES7 512-1CK00-0AB0
  • Firmware version: V2.8

TIA Portal Project

Create a project in TIA Portal and configure the hardware.

Hardware configuration

Some configuration needs to be done in TIA Portal in order to enable OPCUA features. In the project tree, right click on the title of the project, and select “properties”.

alt text

In the “Protection” tab of the pop-up window, enable the option “Support simulation during block compilation”

alt text

PLC Properties

In the project tree, right click on the PLC, and select “Properties”

alt text

In the structure on the left, you can find the I/O modules added previously, click on I/O addresses for each module and set the process image of inputs and outputs to none in both modules. Thus, you have to set “none” in 4 different squares. Remember to do this in every I/O module you have in the PLC.

alt text

In the “General” tab of the pop-up window, choose “OPC UA” in the structure on the left and enable the option “Activate OPC UA server”.

alt text

In the structure on the left, scroll down until the end where you will find the “Runtime licenses” tab, click on “OPC UA” and select the type of purchased license as “Medium”.

alt text

IO communication (optional)

In order to achieve a better response from the changes in the inputs and outputs you can change the following parameters:

PLC / Properties / OPC UA / Server / Options / Subscriptions

  • Minimum sampling interval: 100 ms.
  • Minimum publishing interval: 500 ms.

alt text

PLC / Properties / Profinet interface / Advanced options / Real time settings / IO communication

  • Send clock: 0.5 ms

alt text

PLC Hardware

The PLC built in Simumatik OEP has an I/O module of 1 byte (0-7) for the inputs called “inputs” and an I/O module of 1 byte (0-7) for the outputs called “outputs”. In the “port” tab is shown the addresses of the inputs and outputs. For example in this system, the sensor 2 is in the bit 1 of the inputs module.

alt text

Thus, in the “device configuration” tab, 2 I/O modules should be added to the PLC, one for the inputs and the other for the outputs as it is shown in the pictures below.

alt text

alt text

Open the tag table and declare the variables 'inputs' and 'outputs' in the corresponding addresses. Then, individual signals can be declared to be used in the program, each one properly mapped according to the connections in the model:

  • The addresses of I/O list must be equal in the hardware (I/O modules)

alt text

PLC SIM ADVANCED CONFIGURATION

This section details the steps to be performed in the PLCSIM Advanced simulator.

Create an instance

First, you have to know the IP of your PLC in TIA Portal, go to the PLC properties panel and click on “Ethernet addresses” and there you have all the data needed. In our case the IP address is 192.168.0.1 and the subnet mask 255.255.255.0

Note

The IP Address can be different from this, the important thing is that this IP Address is the same in the PLC in TIA Portal and the IP Address in PLCSIM Advanced.

alt text

Open PLCSIM Advanced and configure it as:

  • PLCSIM Virtual Eth. Adapter. If you can´t do it, NPF may have to be started on the command line. Open Command Prompt as administrator and write “net start npf”.
  • TPC/IP communication with: <local>
  • Instance name: random name
  • IP Address: the same IP you have in the PLC in TIA Portal, in our case is 192.168.0.1
  • Subnet mask: 255.255.255.0
  • PLC type: The type of your PLC, in our case is CPU 1500
  • CLICK START

After this, a yellow light will be activated.

alt text

IP Address Setting

An appropriate IP address must be assigned to that virtual Ethernet adapter. To do som, click on the Windows symbol and go to “settings” and click on “Network & Internet”

Next, click on “Network and Sharing Center”

alt text

Click on “Change adapter settings”

alt text

alt text

Search for “Siemens PLCSIM Virtual Adapter”. In the “Properties” of this network, access the “Internet Protocol version 4 (TCP/IPv4)” and assign an IP address of the same range as the IP address of the PLC in TIA Portal and PLCSIM Advanced (it means that the IP Address differs in the last digit, for example 192.168.0.2) and set the subnet mask to 255.255.255.0.

alt text

Download to device

Select the PLC and compile its program, as shown below in the icon “1”.

alt text

Now, the project will be transferred (not simulated) to the PLC (using the “2” icon, next to the previous). In the pop-up window shown below, select “Siemens PLCSIM Virtual Ethernet Adapter” and start search. Select the PLC and load the program.

alt text

After this, a green light will be activated in PLCSIM Advanced.

alt text

Once the simulation is finished, PLCSIM Advanced will be closed by following these steps:

  1. “Turn off” the instance, acting on the button “1” shown below, then the light will switch to grey.

  2. “Remove” the instance, acting on the button “2”.

Otherwise, the IP address of the instance will remain registered and can give problems in future simulations with other addresses.

alt text

SIMUMATIK OEP CONFIGURATION

This section details the steps to be performed in the Simumatik OEP, based on a model already made.

First, create either an online or a local server (download link) in Simumatik.

alt text

Once the server is created and started, enter to the workspace by clicking on the right button.

alt text

Click on the button “1” shown below to show the panels, and now you can add either a public system created by other users or create your own systems by clicking in button “2”. For this guide, the “turning conveyor” will be used.

alt text

Wait until the system is loaded, a pop-up window will be displayed in the right corner.

alt text

In order to see the different assemblies and group of the system you have to click over the system name in the workspace, see the arrow “1”.

Now you have access to the PLC by clicking over the name. Next step is to write the IP address of the PLC in TIA Portal and PLCSIM Advanced instead of “localhost” in the PLC of Simumatik.

alt text

In our case, the IP address is “192.168.0.1” instead of “localhost”

alt text

Finally, the gateway must be activated before the simulation starts. Click on the “more” button with 3 vertical dots.

alt text

A window on the right will appear and click on the gateway button and the slide at the right to activate the gateway.

alt text

Now everything is properly connected, and you just have to click on the “play” button and enjoy Simumatik OEP.