How to communicate two controllers thought OPC UA

This post explains how to configure step by step a communication thought two B&R controllers by OPC UA, being one server and the other client, without implementing any code, just configuration.

Minimum version requirements are:

  • Automation Studio: 4.4
  • Automation Runtime: F4.44

Limitations:

  • Only possible to communicate variable types: BOOL, (U)SINT, (U)INT, (U)DINT and REAL

If you want to use STRING type variables, structures or OPC UA methods, you can use EasyUaClnt library. Which simplifies AsOpcUac library and makes easier its use. See this post to know more about it: EasyUaClnt a simplicity wrapper library based on AsOpcUac

Configuring the server

Activate OPC-UA System

To activate an OPC UA server on the device, the OPC-UA System must be enabled in the Physical View with the right button on CPU > Configuration, and here Activate OPC-UA System > On.

Configure OPC-UA System

First of all, the access port to the OPC UA server must be defined in the “Port Number” field of “Network Settings”. By default, 4840.

image

Define the variables to communicate through OPC UA

To define the variables to be communicated through OPC UA, it is necessary to go to the Configuration View and add the “OPC UA Default View File” file from the Toolbox to Connectivity > OpcUA folder, by double clicking on the file or dragging it. to the mentioned route.

When we open this file, we will find all the program variables that we have in our project. By default, all of them will be disabled. To enable them, you must click on them with the secondary button and press “Enable Tag”, or using the green tick at the top.

When enabled, they will go from gray to black.

image image

Once this step is completed, the OPC UA server will be configured.

Configuring the client

Add hardware

The component is searched in the Toolboox - Hardware Catalog with the name OpcUa_any.

image

The OpcUa_Any component is dragged over the Ethernet (ETH) interface in the Physical View.

Activate OPC-UA System

A requirement for the OpcUa_any component to work is to have the OPC-UA System activated. The OpcUa_Any component is dragged over the Ethernet (ETH) interface in the Physical View. OPC-UA System is enabled in the Physical View with the right button on CPU > Configuration.

Configure OpcUa_Any

The OpcUa_Any configuration is available from the Physical View by right-clicking on the component > Configuration.

Once here, the “Server diagnostics” option is activated to find out more details about the connection to the server (optional). And in the “ServerEndpointUrl” field, enter the IP address and port of the server. If the default port on the OPC UA server has not been modified, it will be 4840. It will be written in the following format:

  • opc.tcp://ip-address:port
  • opc.tcp://hostname:port

Next, to configure a channel you have to define whether it is input or output in the “Direction” field, the data type in “Data type” and the path within the server in “Browse Path”. The “Name” field is the one that will be displayed in the I/O Mapping of the module. Within “Direction” the sampling and publication time (from the server’s point of view) of the variables is configured.

For a B&R OPC-UA server “Browse Path” has the following syntax:

  • Local variables: /0:Root/0:Objects/4:PLC/6:Modules/6:&:&:/6:/6:
  • Global variables: /0:Root/0:Objects/4:PLC/6:Modules/6:&:&:/6:Global PV/6:

In case the OPC-UA server is configured as Information Models PV 2.00 will be replaced 6:Modules by 4:Modules.

In the “Direction” drop-down menu the following are configured:

  • Sampling interval: channel sampling time
  • Publishing interval: transmission interval from the OPC UA server to channel. This value is limited by the range defined in the OPC UA Server configuration.

In the image above, two variables are defined as inputs. The first, the local variable “var1” of type USINT, from the task “Program1”. The second, the global variable “gVar1” of type BOOL.

Communication check

Within the Physical View, by clicking on the OpcUa_Any component > I/O Mapping, we will find information about the component and the created channels.

image

If everything works correctly, I/O Mapping > ModuleOk will be TRUE and the configured channels will be displayed. In I/O Mapping they can be mapped to project variables.

The image below shows an example of communication between two B&R controllers using OPC UA. On the left, the OPC UA server is running on one computer, and on the right, the OPC UA client is running on another. Both configured with the steps explained in this guide. It can be seen how two input variables and one output variable (from the client’s point of view) are communicating with each other. Showing the value of the variables sent by the server in the I/O mapping of the OpcUa_any component, along with server diagnostic variables.

Additional information

If you want to configure the OPC UA client to communicate with a non-B&R server, the route syntax can be checked with programs that act as OPC UA clients such as UaExpert, from Unified Automation.

Here we can see the path to the variable, where we will have to separate each folder by /NamespaceIndex:FolderName/

image image

I hope you find this information usefull. For more information please check the Automation Help chapter of OPC UA Configuration in Automation Studio.

5 Likes

Only use OpcUa any device if you need to communicate a few basic datatype values between PLCs, but from my experience one should avoid using it completely.

More elegant and performant communications can be done using the AsOpcUac library.
Many OpcUa samples can be found in the Automation studio installation path here:
C:\BRAutomation\AS412\Samples

Or just check out this post here:

1 Like

Hi Philipp!

I agree with you. That is why at the beginning of the post I wanted to add its limitations. I summarize the limitations below:

Feature OpcUa_Any component Libraries AsOpcUac / EasyUaClnt
Define variables of type: BOOL, (U)SINT, (U)INT, (U)DINT and REAL type variables :white_check_mark: :white_check_mark:
Define variables of type STRING or structures :x: :white_check_mark:
OPC UA method management :x: :white_check_mark:
1 Like

A post was split to a new topic: Communication Between Robot and B&R PLC