This is the fourth episode of the B&R Automation Studio Tutorial. This time, we will start up OPC UA Server in B&R Automation Studio and briefly explain the concepts related to OPC UA.
Let’s get started!
Reference Link
OPC UA?
OPC UA is a manufacturer-independent communication protocol for automation applications in industry. It enables end-to-end communication from individual sensors and actuators to ERP systems and the cloud.
B&R has been a member of various working groups of the OPC Foundation for many years and makes a variety of products that allow for simple configuration of OPC UA device settings and access rights in B&R’s Automation Studio engineering environment with a few clicks.
In addition, B&R’s Automation Studio provides a PLCopen Function Block, which is used to implement OPC UA functionality in automation projects.
Advantages
OPC UA enables integrated communication from the ERP system to individual sensors and actuators and provides for interoperability between various fields. Using OPC UA has many advantages.
- Conforms to International standard (IEC 62541)
- Safe and secure data exchange
- Increased reliability
- Vendor-independent
- Platform independent
- Vertical and horizontal communication
International standard (IEC 62541)
The OPC UA specification is defined by the OPC Foundation and standardized in IEC 62541. the OPC UA specification consists of 14 parts and is continuously supplemented by specifications from other organizations such as PLCopen and other consortia.
- IEC/TR 62541-1 Part 1: Overview and concepts
- IEC/TR 62541-2 Part 2: Security model
- IEC 62541-3 Part 3: Address space model
- IEC 62541-4 Part 4: Services
- IEC 62541-5 Part 5: Information model
- IEC 62541-6 Part 6: Mappings
- IEC 62541-7 Part 7: Profiles
- IEC 62541-8 Part 8: Data access
- IEC 62541-9 Part 9: Alarms and conditions
- IEC 62541-10 Part 10: Programs
- IEC 62541-11 Part 11: Historical access
- Part 12: Discovery
- IEC 62541-13 Part 13: Aggregates
- Standard OPC UA specifications
- Part 14: PubSub
- IEC 62541-100 PLCopen IEC 61131-3
Where to use?
OPC UA is used in various parts of the B&R system:
- Connection between HMI application and controller (e.g. mapp View)
- Data exchange with B&RController
- Data exchange with third party CPUs
- Connection of Fieldbus devices (e.g. B&R Bus Controller or OPC UA compatible sensors or actuators)
HMI Applications
This is a utilization case that becomes an exchange of process variables between an OPC UA HMI application and a PLC system. Briefly, an HMI application connects the OPC UA Client to a Controller such as a PLC to the OPC UA Server, and the OPC UA Node in the Server receives process variable data to and from the PLC.
OPC UA bus controller
The Bus Controller provides OPC UA Server functionality, allowing various OPC UA Clients to connect to its Bus Controller and read/write data from/to the IO modules installed in the Bus Controller.
For example, the Bus Controller X20BC008U shown below connects the OPC UA system to the X20 I/O system and can request or send data from both the Bus Controller and X20 I/O modules using OPC UA services.
The B&R Bus Controller, which follows the OPC UA standard, can be accessed not only by B&R products but also by OPC UA Clients from other manufacturers.
Controller to controller
With OPC UA, communication between PLC systems can be easily implemented by using the FBs specified in PLCopen. 20+ FBs are provided in Automation Studio to transfer data and call methods on the connected OPC UA device The FBs can be used to transfer data and call methods on the OPC UA device to which they are connected.
Information model
In the B&R OPC UA Server based on the OPC UA specification, PLC systems are mapped to the OPC UA address space. Its Infomration model is based on the following parts
- Part 3 (Address Space Model)
- Part 5 (Information model)
- Companion Specification PLCopen OPC UA Information Model 1.00 Specification
Nodes
The B&R OPC UA Server contains the OPC UA Nodes required according to the specification (e.g. Server Object). In addition, variables that indicate the state of the B&R OPC UA server during startup or operation are also mapped to the Server as Nodes.
NodeID
A Node in OPC UA Server is uniquely identified in AddressSapce by its NodeID. The NodeID consists of NamespaceIndex, Identifier, and IdentifierType.
NamespaceIndex
Nodes in the OPC UA Server may be defined by the OPC Foundation, the PLCopen organization, or by B&R itself, and the address space of the OPC UA is managed in Namespace.
So, from NameSpace, you can sort out where the corresponding Node is defined from in the following format.
Automation Studio
OPC UA bus controller
Since URIs are very long, instead of specifying them by NodeID, the URIs are managed in a “NamespaceArray” in the Server Object. For example, for Automation Rutnime,
- NamespaceIndex 0: http://opcfoundation.org/UA/
- NamespaceIndex 3: http://opcfoundation.org/UA/DI/
- NamespaceIndex 6: urn:B&R/pv/
Implementation
Automation Studio Side
Enable the OPC UA system
To use the OPC UA Server with B&R’s Controller, it must be enabled in the Automation Runtime Configuration and can be configured from a separate screen.
For basic configuration, it is enough to enable the OPC UA system. In the Server configuration, you can also set server properties such as port, encryption access, transmission cycle time, and number of linkable variables.
Switch Physical View to Project>Select CPU>Right click>Configuration.
There is an item OPC-UA System>Activate OPC-UA System, which is Off in Default.
When the setting item of “Activate OPC-UA System” is set to On, detailed settings of OPC UA Server such as security settings and Port used are displayed.
Configure the Access/Security
Next, open B&R’s Configuration View.
The Configuration View is switched to >AccessAndSecurity and there is a UserRoleSystem. In this UserRoleSystem, you can configure the security relationship and Login information when OPC UA Client accesses to OPC UA Server of B&R.
Now we can open UserRoleSystem>Role.role.
Add User
Right click on User.user>Open>Open As Table to change the User of the project.
The User Configuration screen is now displayed.
User.user now has only Anoymous, so the User screen reflects the same.
Right click on the User build screen>Add “User” Element to add a new User.
Done!A User named Anonymous_1 has been added.
User name
Click on Anonymous_1 and change the User name.
In this Tutorial, it is set to Admin.
Password
Set the Password to Login to User Admin.
Done!
Roles
Next is Roles, which allows you to set which Group the corresponding User belongs to.
User Admin is set to belong to Roles Adminstrators.
Add Roles
If you want to add new Roles, right click on Role.role>Open>Open As Table.
The Roles definition screen appears.
Right click on the Role Configuration screen > Add “Role Element” to add a new Role.
A Roles named Adminstrators_1 was added.
Change the Roles name to Enginner.
Go back to the User Configuration screen we just went through, add a new User Chris, and set Roles to belong to Engineer.
Roles and User?
Before we move on to the next Step, let me explain a little about the relationship between Roles and User. For example, you are in charge of a certain production line, and you are in charge of the areas of Maintenance, Modification, and Development. Naturally, your Roles are also in Maintenance, Modification, and Development, and you have authority over those Roles.
You have a new member, Tom, who is only responsible for LINE maintenance and naturally does not have access to modifications or development.
It is the concept of Roles and Users: a User has multiple roles for only one.
Mapping
Next, set the Node to Publish to OPC UA.
Adding OPC UA mapping
By adding the OPC UA Default View to the Configuration View from the Toolbox, you can easily do variable mapping between OPC UA and Runtime.
This means that you can use the Automation Runtime OPC UA server and have many configuration options such as ranges for each Node value, read/write access, units, etc.
Add Default view
To add the OPC UA Default View, add the OPC UA Default view File in the Toolbox to the Configuration View.
OPCUaMap.uad has been added.
OpcUaMap.uad is also the OPC UA Default View, which allows you to set the attributes of Runtime variables.
Configure
Click on Default View to configure basic settings for OPC UA Server.
Properties- Default View on the right side of Automation Studio shows the security setting items of OPC UA, etc.
Add Role
We will add the Login information to access B&R’s Automation Runtime OPC UA Server from 3rd-Party. First, add Roles that can access OPC UA Server.
Rights/Roles>Add Role.
The Drop-List will appear. First, select Administrators.
Done!The operation that User who corresponds to the Value column permits to OPC UA Server can be set by Check/UnCheck.
Let’s add and specify Roles for Everyone and Engineer using the same operation.
Enable tag
Select the Tag you want to publish to OPC UA Server>Right click>Enable Tag.
Done!The Tag to be published will be black text.
Finally, download the project to Runtime
UaExpert Side
Now we will use UaExpert to validate B&R’s OPC UA Server.
Add Server
Add a Server that connects to UaExpert.
The Add Server screen appears.
From Custom Discovery, <+Double Click to Add Server… >Add a new Server.
Enter the URL of the B&R OPC UA Server and press >Ok to proceed.
Done!If B&R’s OPC UA Server is found, Security Options that can connect to B&R’s OPC UA Server will be displayed.
In this article, we will use Basic256Sha256 to connect.
Done!B&R’s OPC UA Server has been added.
Connect Server
Click the Connect Server button to connect to B&R’s OPC UA Server.
The certificate approval screen appears.
Please check “Trust Server certificate” and click “Continue” to proceed.
Done!UaExpert and B&R’s OPC UA Server successfully connected.
Add Nodes
CPU>GlobalVars also displayed the Tag that was just Enabled in Automation Studio.
Let’s add Node to UaExpert.
BadUserAccessDenied…?
But I got a BadUserAccessDenied error.
Properties
Open >Server>B&R’s OPC UA Server>Properties to change the way UaExpert logs into B&R’s OPC UA Server.
Change Authorization Settings to Username and enter Admin in the Username field.
Now you need to enter the password.
BadResourceUnavailable..?
Login succeeded, but this time I got a BadResourceUnavailable error.
When I open the Attributes of Nodes, I see that the TimeStamp of Value is out of date, and I probably need to update the TimeStamp using the corresponding variable in the B&R project.
Use it in program
Let’s try to use variables published by OPC UA Server in Automation Studio.
Result
Done!