OPCUA integration with B&R Automation Studio

This chapter explains the steps to create PLC tags and enable OPCUA communication between the Simumatik Gateway and Automation Studio 4.8, including the programs and I/O signals.

In this example the data that will be transferred is:

  • ‘inputs’: A PLC input byte (inputs.0…7) addressed to the variables.
  • ‘outputs’: A PLC output byte (outputs.0…7) addressed to the variables.

Automation Studio Project

The first step is to create a new project by opening Automation Studio and then choose ‘New Project’.

alt text

After creating a project, give it a name and select 'next'.

alt text

Hardware configuration

To define the hardware, select 'Define a new hardware configuration manually' and click 'Next'.

alt text

Choose the desired controller, which in this example is 'X20CP1584' and click on ‘Finish’.

Warning

Make sure the choosen PLC is compatible with OPCUA

alt text

IO declaration

After selecting the hardware, in the 'Logical View' window on the left side, click on 'Global.var' and define the variables.

Warning

The BYTE variables has to be named as the PLC variables in Simumatik. The defaults are 'inputs' and 'outputs'.

alt text

Program creation

Once the variables are defined, create the program in the 'Toolbox' window on the right side of the screen, and select 'Program'.

alt text

In this tutorial we are going to create two different programs. One to map the bytes variables into bit variables, and the other one to program the PLC logic.

First select 'Program', and pick 'ST Program All In One'. Secondly select 'Program' again and pick 'LD Program'.

alt text

Note

For clarity, we renamed the ST program to 'IOmapping' and the LD program to 'Program'.

Double click 'IOmapping' and assign the I/O variables to the bytes in the order seen in the image, first inputs and then the outputs.

Tip

In Automation Studio, the way to access a certain bit from a BYTE variable is by typing inputs.0 ... inputs.7

alt text

Next, double click 'Program' and introduce the inputs and outputs like in the following image.

alt text

OPC-UA connection

Once the program is created, the OPC-UA connection will be made between Simumatik and Automation Studio. Inside 'Physical View' window, right click on the X20CP1584 hardware and select 'Configuration'. Within 'OPC-UA System' select 'ON'.

Warning

Change Port number to 4841 in case that another application is using port number 4840, such as Tia Portal or Codesys.

alt text

Once the OPC-UA is connected, in the 'Configuration View' window, within X20CP1584 / Connectivity double click on OpcUA. In the 'Toolbox' window on the right side of the screen, double-click on 'OPC UA Default View File'.

alt text

Double click on the 'OpcUaMap.uad' file that has been created.

alt text

Once inside the 'OpcUaMap.uad' file, first press 'Build' and then 'Refresh Default View' so that the declared global variables appear.

alt text

Note

If the 'Global Variables' doesn't appear, close 'OpcUaMap.uad' window and open it again.

When the 'Global Variables' appear, select all of them and press 'Enable Tag'.

alt text

Simumatik gateway connection

Before transferring the Automation Studio program, the Gateway must be connected in Simumatik so that the connection between the two is possible.

alt text

Warning

In case the port number in Automation Studio is changed to 4841 as in the example, within 'Variables: PLC' change the url to opc.tcp://localhost:4841.

alt text

Transfer program

To transfer the program, first press 'Activate Simulation', and once in 'Run' mode, press 'Build'.

alt text

After building the program, click on 'Transfer' in the 'Project Build' and 'Transfer to target' windows.

alt text alt text

Once the program has been transferred to Simumatik, the status of the PLC will be 'RUNNING'.

alt text