Skip to content

OPC UA Super Complete Tutorial

Welcome! You are about to begin a tour to learn how to design and create OPC UA applications using a super complete tutorial. Here, I present several application samples to demonstrate the use of OPC UA specifications and technology. Finally, you’ll be ready to start implementing real-world OPC UA applications.

To sum up, below is a list of posts that complete this series:

  • OPC Foundation Unified Architecture Technology Samples

However, before we dive in our OPC UA super complete tutorial, let’s review some important concepts:

What is OPC UA?

Basically, we can say OPC Unified Architecture (OPC UA) is an industrial automation standard for moving data between the factory floor and the enterprise.

For a longer definition, we can say OPC UA is a platform-independent interoperability standard interface through which various kinds of systems and devices can communicate to each other over various types of networks. OPC UA is applicable to components in all industrial domains, such as industrial sensors and actuators, control systems, Manufacturing Execution Systems and Enterprise Resource Planning Systems, including the Industrial Internet of Things (IIoT), Machine To Machine (M2M) as well as Industrie 4.0 and China 2025.

OPC UA standard

Why an OPC UA super complete tutorial?

Firstly, I want you to build something, which can be a completely practical project. Consequently, you will apply the quote “learn by doing” and a guide like this could help you to achieve this goal. Therefore, the main idea here is to design and implement a real-world OPC UA software application, one step at a time.

What will we need?

We’ll need several software components:

  • Microsoft Visual Studio, an IDE from Microsoft.
  • Git, a free and open source distributed version control system.
  • Git repositories, usually from GitHub.

Designing for OPC UA

Integrated

OPC UA provides a consistent, integrated AddressSpace and service model. This allows a single Server to integrate data, Alarms and Events, and history into its AddressSpace, and to provide access to them using an integrated set of Services. These Services also include an integrated security model.

Openly browsable and dynamic

OPC UA also allows Servers to provide Clients with type definitions for the Objects accessed from the AddressSpace. Additionally, information models describe the contents of the AddressSpace. OPC UA exposes data in many different formats, including binary structures and XML or JSON documents. Moreover, the OPC Foundation, other standard organizations or vendors may define the format of the data. Through the AddressSpace, Clients can query the Server for the metadata that describes the format for the data. In many cases, Clients with no pre-programmed knowledge of the data formats will be able to determine the formats at runtime and properly utilize the data.

Flexible hierarchy for multiple applications

OPC UA adds support for many relationships between Nodes, which could be much more than a single hierarchy. In this way, a Server may present data in a variety of hierarchies tailored to the way a set of Clients would typically like to view the data. This flexibility, combined with support for type definitions, makes OPC UA applicable to a wide array of problem domains. In addition to this, OPC UA aims not just the SCADA, PLC and DCS interface, but to provide greater interoperability between higher level functions.

Now, let’s see the scope of some OPC UA target applications:

Robust communication

OPC UA provides robustness of published data. A major feature of all OPC servers is the ability to publish data and Event Notifications. OPC UA provides mechanisms for Clients to quickly detect and recover from communication failures associated with these data transfers. In doing so, there is no need to wait for long timeouts provided by the underlying protocols.

Scalable

OPC UA supports a wide range of Servers, from plant floor PLCs to enterprise Servers, all of them with a broad scope of size, performance, execution platforms and functional capabilities. Therefore, OPC UA defines a comprehensive set of capabilities, and Servers may implement a subset of these capabilities. To promote interoperability, OPC UA defines subsets, referred to as Profiles, to which Servers may claim conformance. Clients can then discover the Profiles of a Server, and tailor their interactions with that Server based on the Profiles.

Stable core

The OPC UA specifications layers isolate the core design from the underlying computing technology and network transport. This allows future technologies to map OPC UA when necessary, without negating the basic design. According to the standard, we will use three data encodings:

  • XML/text
  • UA Binary
  • JSON

Furthermore, we will use several protocols:

  • OPC UA TCP
  • HTTPS
  • WebSockets

Business-conscious

OPC UA Applications that support multiple transports and encodings will allow the end users to make decisions about trade-offs between performance and compatibility at the time of deployment, rather than determined by the OPC vendor at the time of product definition.

Backward compatibility

OPC UA is the evolution or migration path for OPC clients and servers that are based on Microsoft COM technology. With great care in the design, existing data exposed by OPC COM servers (DA, HDA and A&E) can easily match OPC UA. Evidently, vendors may choose migrating their products natively to OPC UA or use external wrappers to convert from OPC COM to OPC UA and viceversa. Besides, each of the previous OPC specifications defined its own address space model and its own set of Services. Consequently, OPC UA unifies the previous models into a single integrated address space with a single set of Services.

Additional messaging pattern

Unlike OPC UA Client Server, OPC UA PubSub opens new application fields for OPC UA. The following are some example uses for PubSub:

  • Configurable peer to peer communication between controllers and between controllers and HMIs. There is no need for the peers to stay directly connected and do not even need to know about the existence of each other. The data exchange often requires a fixed time-window and it may be point-to-point or a multi-point connection.
  • An order processing application can place an order on a message queue or an enterprise service bus (asynchronous workflow). Thence, one or more workers can process such orders.
  • Sensors or actuators that write logs to a monitoring system, an HMI, an archive application for later querying.
  • Servers representing services or devices that stream data to applications hosted in the cloud such as backend servers, big data analytics for system optimization and predictive maintenance.

Certainly, various different messaging systems can implement PubSub. Let’s see this with two examples:

  • Production environments with frequent transmissions of small amounts of data can easily use PubSub with UDP. It also allows data exchange in one-to-one and one-to-many configurations.
  • The use of established messaging protocols (e.g. the ISO/IEC AMQP 1.0 protocol) with JSON data encoding supports the cloud integration path and readily allows handling of the information in modern stream and batch analytics systems.

Basic exercises

As I wrote in the beginning, you will understand this technology with examples. Then, let’s complete some basic exercises from the OPC Foundation Unified Architecture Technology Samples:

Launching the OPC UA Server & Client

  • Go to the “UA-.NETStandard-Samples” GitHub repository here.
  • Download or clone the repository to your workspace.
  • Open the “UA Quickstart Applications.sln” solution file using Visual Studio.
  • Wait until all projects load.
  • Once in Visual Studio, compile the entire solution (Build -> Build Solution).
  • Notice that compiled applications are within “../bin/Debug” folder.
  • Firstly, go to that folder and launch the DA server by running “Quickstarts.DataAccessServer.exe”.
  • Secondly, launch the DA client by running “Quickstarts.DataAccessClient.exe”.
  • Finally, you should see both applications open on-screen.
OPC DA server
OPC DA client

External resources

To experience the OPC UA super complete tutorial better, make sure to check these external resources:

For other articles like this one in English, click here. To see them in Spanish, click here.

Share this post

2 thoughts on “OPC UA Super Complete Tutorial”

  1. Hi Jose,
    Thanks for the tutorial on OPC -UA.
    I am new to this communication standard. I need to do a POC on OPC-UA (using C++ programming language with Matrikon flex SDK) for the smart railway project I’m working on.
    Can you help me with any sample applications if available in c++.

    Thanks in Advance

    1. José Alberto Maita

      Hello Anusuya. You’re welcome. Please, write to my email so we can evaluate your requirements and other details for your POC. Greetings, José A.

Comments are closed.