Overview
OPC UA is one of the most trending industrial M2M communication protocols. Mainly because it can reliably, securely and, most of all, easily model “objects” and make its attributes and properties available both horizontally (shop floor) and vertically (MES, ERP) on the Automation pyramid.
A brief introduction to the OPC UA protocol as follows:
What OPC UA really is?
- Uses standard Ethernet and TCP/IP implementation.
- Uses a Server/Client model.
- Uses Public Key Infrastructure (PKI) for securing communication between the Client and Server.
- Represents data as attributes grouped into objects also known as nodes
What makes OPC UA special?
- OPC UA can be seen more of an Architecture than a protocol? It systemizes how to model data, systems, machines or entire plants. It’s a technology that customize how data is organized and how information about the data is reported.
- OPC UA supports SOAP over HTTP or HTTPS, which means it can be integrated with IT systems and cloud (but not perfectly).
- OPC UA provides a true Information model, providing the ability of an Object Node to have references to other Object Nodes which further references other Object Nodes to an unlimited degree. This provides the capability to form hierarchical relationships that represent systems, processes, and information – an Information model.
- OPC UA offers the ability for Clients to executes small pieces of logic in Servers called methods.
Data model
In this article, the OPC UA server built in this example, will be used to model a very basic MES data model shown below, the aim is to make this information as easy as possible to retrieve and manipulate:
Moving forward, the communication studio is used with the OPC UA configurator extension:
- Create a new project.
- Define a namespace for the data model.
- Define data types and assign properties needed to describe each entity of the process.
- Add objects of the user-defined data types.
- Map the user-defined objects to the defined namespace
Finally we will Deploy and run the OPCUA server on a NXHX 90-JTAG development board.
Configuration
The base nodes supplied by the OPC UA server are objects, types, and views. The objects' node can be used to define new nodes made available by the server and belong to one of two node classes:
- Variable node class: Can only hold a single value.
- Object node class: Contains one or more nodes of class variable.
In the types' node, only object nodes with sub-nodes of the variable node class, i.e., leaf nodes, are defined, then whenever a sub-node of type object is encountered, a reference to another object node is added to that object.
Starting at the top of the data model, the type “Station” is an object within “Resources” which has two leaf nodes “ID” and “status”, and has a reference to “operations” which again has another three leaf nodes.
To achieve this, first go to “types → ObjectTypes → BaseObjectType” and add a new SubType, in the case below figX, called “MyDataTypes”, then add all the objects that contain leaf nodes:
The leaf nodes defined here inherit various properties from their parents nodes, however one very useful property that gets added and not inherited is the Modelling Rule of these nodes.
The Modelling Rule defines whether the leaf node is a mandatory or an optional component or Placeholder of its parent node. Moreover, it uses very useful to define a more specific data type for the leaf node to easily map it to the netPROXY namespace:
Moving on, adding a new "station" object to the objects nodes with the path "Production_control → Resources → Stations" should directly intiate an id and status leaf nodes and a new "Operation" object. Then, add a new object of type "Operation" to the operation node, which should also initiate another three leaf nodes.
Assuming that station2 exists and shares the same operation with station1, instead of defining a new operation inside the station2 object, simply add a reference to operation node in station1. This will result in a new child node which has identical properties and node id to the reference node.
Finally, all the leaf nodes created inside the objects' node are mapped in the netPROXY namespace defined above:
- Define the objects and their variables
- Map every variable to its node path.
Running the server
Note that to map an element to a leaf node, the element type and the variable data type has to match.
Finally, export the OPC UA configuration files and download them to evaluation board:
After running the application (following this example), you can connect to the server using a client application such as uaExpert or implementing an OPCUA client using an SDK from the opcua foundation: