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
- 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
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.
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.
Once this step is completed, the OPC UA server will be configured.
The component is searched in the Toolboox - Hardware Catalog with the name OpcUa_any.
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.
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:
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.
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.
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.
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/
I hope you find this information usefull. For more information please check the Automation Help chapter of OPC UA Configuration in Automation Studio.