What is OPC UA?

Catalin NegruPublished 7 min read

Part of the OPC UA guide

OPC UA, short for OPC Unified Architecture, is a platform-independent standard for exchanging industrial data between a server that owns the data and clients that use it. It defines three things together: an information model (a tree of typed nodes), a set of services for working with that model (browse, read, write, subscribe, call a method), and secure transports to carry those services. The OPC Foundation publishes it as the OPC 10000 series, and the IEC has adopted it as IEC 62541.

This page is part of the OPC UA guide. It covers the protocol as a whole; the address space and security pages go into the detail.

Where OPC UA came from: OPC Classic

The first OPC specification, OPC Data Access (OPC DA), was released in 1996 so that HMI and SCADA software could read PLC data through one interface instead of one driver per vendor. It was built on Microsoft’s COM and DCOM, and OPC originally stood for OLE for Process Control. Two more specifications followed for other kinds of data: Alarms and Events (OPC A&E) and Historical Data Access (OPC HDA). Together they are now called OPC Classic.

Classic worked, and it had three lasting problems. It ran only on Windows. Connections between machines depended on DCOM, which needs matching user accounts and a wide range of dynamic ports, so it was difficult to configure and to pass through a firewall. Each specification also had its own server and its own address space, so current values, alarms and history for the same tag lived in three places.

OPC UA was written to replace all three, with its first parts published in 2006. The differences that matter in practice:

OPC Classic (DA, A&E, HDA)OPC UA
PlatformWindows, COM and DCOMAny operating system, including embedded controllers
NetworkDCOM, dynamically assigned portsOne TCP port, 4840 by default
Data modelFlat or folder list of items, per specificationOne address space of typed nodes and references
Values, alarms, historyThree specifications, three serversOne server, one address space
SecurityWindows accounts and DCOM permissionsCertificates, signing and encryption in the protocol
Item addressItem ID stringNodeId (namespace plus identifier)

Classic servers are still running in many plants. The usual migration is a wrapper or gateway that connects to the Classic server locally through COM and offers its items as an OPC UA address space, which removes DCOM from the network without replacing the old server.

How does OPC UA work?

There are two roles. An OPC UA server holds an address space and answers requests. An OPC UA client starts every connection and sends every request. A PLC, a drive controller or a software gateway is normally the server; SCADA, MES, historians and data collectors are clients. One application can be both, which is how an aggregating server reads from several PLCs and serves their data upward.

A client’s session follows the same order every time:

  1. Open a TCP connection and exchange Hello and Acknowledge messages to agree on buffer sizes.
  2. Open a secure channel, which sets up signing and encryption.
  3. Create and activate a session, which identifies the application and the user.
  4. Call services: Browse to find nodes, Read and Write for single operations, CreateSubscription and CreateMonitoredItems to receive changes.

The client and server page walks through each step and its failure modes.

The parts of the specification

OPC UA is published in parts. These are the ones an integrator runs into:

PartTitleWhat it defines
1Overview and ConceptsTerms and the overall model
2Security ModelThreats and the security architecture
3Address Space ModelNodes, node classes, attributes, references
4ServicesRead, Write, Browse, subscriptions and the rest
5Information ModelThe standard nodes every server has
6MappingsEncodings and transports, including the binary TCP protocol
7ProfilesNamed feature sets that a product can claim
8Data AccessAnalog and discrete items, engineering units and ranges
9Alarms and ConditionsAlarm state, acknowledgement, events
11Historical AccessReading and updating stored history
14PubSubPublishing data sets without a session

A server does not have to implement all of it. Part 7 groups features into profiles, from small embedded device profiles up to a full standard server, and a product’s documentation states which it supports. Whether a given PLC offers history, alarms or methods is a question for its manual, not for the standard.

Transports and the OPC UA port

Part 6 defines how services are encoded and carried. Three transports exist:

URL schemeTransportEncodingDefault port
opc.tcp://OPC UA TCPUA Binary4840
https://HTTPSUA Binary, XML or JSON443
opc.wss://WebSockets over TLSUA Binary or JSON443

Nearly every PLC and plant-floor server uses opc.tcp with the binary encoding. Port 4840 is the port registered with IANA for it, but it is only a default: a server can listen anywhere, and software servers that host several endpoints on one machine often use other ports. The port in the endpoint URL is the one that counts.

UA Binary is little-endian, so the low byte of every integer is sent first. This is the opposite of Modbus. Each message starts with an eight-byte header: three ASCII characters for the message type, one for the chunk type (F for a final chunk) and a four-byte total size. The first message on a new connection is Hello, sent by the client:

Hello: 48 45 4C 46 3C 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 01 00 00 00 00 1C 00 00 00 6F 70 63 2E 74 63 70 3A 2F 2F 31 39 32 2E 31 36 38 2E 31 2E 31 30 30 3A 34 38 34 30 48 45 4C message type "HEL" 46 chunk type "F", final 3C 00 00 00 message size: 60 bytes 00 00 00 00 protocol version 0 00 00 01 00 receive buffer size: 65,536 bytes 00 00 01 00 send buffer size: 65,536 bytes 00 00 00 01 maximum message size: 16,777,216 bytes 00 00 00 00 maximum chunk count: 0, no limit 1C 00 00 00 endpoint URL length: 28 bytes 6F 70 63 ... "opc.tcp://192.168.1.100:4840"

The server answers with Acknowledge (41 43 4B 46, “ACK” and “F”), which carries its own buffer sizes and limits, or with an Error message (45 52 52 46) and closes the connection. After that come the secure channel messages, typed OPN, MSG and CLO.

What a value looks like

A Modbus read returns 16-bit words and nothing else. An OPC UA read returns a DataValue, which has four main fields:

FieldContent
ValueThe data, in a Variant that states its own type (Boolean, Int16, Float, Double, String and so on)
StatusCodeA 32-bit code; the top two bits give the severity: Good, Uncertain or Bad
SourceTimestampWhen the value was measured or last changed at its source
ServerTimestampWhen the server received or processed it

The status code is what distinguishes a real zero from a failed read. A sensor with a broken wire can report a Bad status with the last value attached, and a client that checks only the value will trend a flat line as if it were a measurement. 0x00000000 is Good; any code that starts with 0x8 is Bad.

Subscriptions in place of polling

A client can call Read on a timer, and for a handful of slow values that is fine. The mechanism OPC UA is designed around is the subscription.

The client creates a subscription with a publishing interval, then adds monitored items to it, one per node. Each monitored item has a sampling interval (how often the server checks the value), a queue size, and an optional filter with a deadband, so that noise below a threshold is not reported. The server samples the values itself and, once per publishing interval, sends the client only the items that changed. When nothing changed, it sends a keep-alive at a negotiated count of intervals so the client can tell a quiet process from a dead connection.

The effect is that a thousand mostly stable values cost almost no traffic, and a fast change is reported at the sampling rate without the client polling at that rate.

Reading OPC UA with ControlCom

ControlCom Connect is hosted, so the OPC UA connection is made on site by the ControlCom Edge Server. Its OPC UA client takes the server’s OPC Endpoint URL, written either as 192.168.1.100:4840 or as opc.tcp://192.168.1.100:4840, and a list of items. Each item names a Node ID, an Attribute ID and the platform variable that receives the value. Two settings on each item control how often a value is published: Send if Stale After (ms), which defaults to 10000, forces a publish when the value has not changed in that time, and Deadband Percentage, which defaults to 5 for number items, suppresses changes smaller than that share of the previous value.

The OPC UA client documentation  has the full field list, and the platform overview shows what happens to the values afterwards.

Point the Edge Server at an OPC UA endpoint, map each node to a variable, and the values are stored, trended and alarmed on in ControlCom Connect.