OPC UA in practice
OPC UA is easy to connect and surprisingly easy to misconfigure. Information models, subscriptions, deadbands, certificates and the reconnect tests that matter.
The first time I watched an OPC UA integration go sideways, the connection itself was fine. The green icon was on, the client could browse 400 tags, and values were updating every second. Yet the MES team still kept asking what State = 4 meant, why a temperature jumped to 0.0 during a PLC download, and why every certificate expired on the same Tuesday morning.
OPC UA is often sold as “the modern protocol that replaces proprietary drivers.” That is only half the story. Transporting numbers across vendors is easy enough; Modbus has done it since 1979. What makes OPC UA worth the extra setup is that it lets you carry structure, meaning, status codes and authentication together in one interface.
Transport is easy; meaning is the work
Reading a float from a register gives you a number, not an engineering fact. You still do not know whether 23.4 is Celsius or bar, whether it is a live sensor reading or a setpoint, or whether the timestamp came from the PLC clock or the gateway that polled it five seconds late.
In OPC UA, you can expose a clean information model instead of a flat dump of internal memory. Rather than publishing raw data blocks straight out of a Siemens or Beckhoff project, group an equipment unit into an object with predictable nodes:
Line2/
Filler01/
EquipmentState (Int16, documented enum)
Speed (Float, EU: bottles/min)
ActiveBatchId (String)
ProductTemp (Float, EU: degC)
Heartbeat (UInt32)
Control/
RecipeId (String, read-only for historians)
This takes an extra day during design and saves weeks later. When someone swaps a drive or refactors internal PLC structures, the external OPC UA namespace stays stable. Consumers stop depending on a spreadsheet called TagList_v4_FINAL_use_this.xlsx emailed around during commissioning.
One caution: do not model every diagnostic bit and HMI lamp on the machine. Expose the interface contract that upstream systems actually need, and keep internal PLC clutter behind it.
Subscriptions, sampling, deadband and queues
One of the biggest practical differences between OPC UA and older polling architectures is the subscription model. Instead of asking the server for 2,000 tags every 500 milliseconds regardless of whether anything moved, a client creates a subscription and lets the server report changes.
Four parameters decide whether a subscription behaves cleanly or floods the PLC CPU:
- Sampling interval: how often the server checks the underlying value. A slow tank temperature does not need 100 ms sampling; a cycle counter might.
- Publishing interval: how often the server bundles queued notifications and sends them to the client.
- Deadband: the minimum change (absolute or percentage of engineering range) required before a noisy analogue signal triggers a notification. Without a deadband, a 16-bit analogue input dithering in the last decimal place will report on every single scan.
- Queue size: how many transitions the server holds per monitored item between publishes. For a fast state machine or part counter, a queue size of 1 silently drops intermediate transitions.
On embedded PLC OPC UA servers (such as an S7-1500), server CPU load is real. Too many clients creating aggressive subscriptions will quietly stretch scan times or push OPC communication into backlog. In a multi-consumer plant, put an aggregation server or SCADA gateway in front of the PLC so only one controlled client talks directly to the controller.
Always store value, quality and timestamp together
Every OPC UA data value comes as a triplet: value, StatusCode, and timestamps (both SourceTimestamp and ServerTimestamp). A surprising number of custom scripts discard the status code and write only the numeric value into SQL.
That mistake shows up months later when a historian chart displays a clean flat line at 0.0 for four hours and nobody knows whether the heater was off or the sensor wire was broken. Keeping the status code lets downstream systems distinguish Good, Uncertain and Bad_CommunicationError, and keeping the source timestamp avoids blaming network jitter for process timing.
Clock synchronisation is the unglamorous prerequisite here. If the PLC is running on a drifted internal clock three minutes behind the SCADA server’s NTP clock, every sequence of events across systems looks slightly out of order. Set up local NTP or PTP inside the OT network before trusting source timestamps.
Security that does not fall over in year two
OPC UA includes proper transport security: X.509 application instance certificates, signing and encryption (such as Basic256Sha256 with SignAndEncrypt), plus user authentication and role permissions. What usually goes wrong is not the cryptography, it is the lifecycle.
During commissioning, people are under schedule pressure. Someone enables None security “just to test,” or generates self-signed certificates with a one-year lifetime and forgets to put renewal on a maintenance calendar. Twelve months later, the certificate waits politely until the exact week the original engineer changes jobs, then expires at midnight on a Tuesday.
A practical baseline for most plants:
- Disable
Noneendpoints in production and avoid anonymous login unless a read-only local display truly requires it. - Separate read-only data collection accounts from accounts that are permitted to write setpoints or recipes.
- Document every certificate’s issuer, thumbprint, location and expiry date in the handover package, and test renewal on a spare system once.
- Restrict OPC UA TCP ports (4840 by default) at the firewall so only specific gateways or SCADA servers can reach the controller.
Failure modes worth testing before handover
Do not sign off an OPC UA link just because values appear on screen. Unplug the Ethernet cable for two minutes and watch what happens. Does the client mark tags as bad quality promptly, or does it keep showing stale values? When the cable goes back in, does the client automatically recreate its session and subscriptions without a manual service restart? What happens if the PLC reboots and comes back with an updated namespace index?
Namespace indices are a quiet trap. Node IDs combine a namespace index and an identifier (for example ns=3;s=Line2.Filler01.Speed). Clients should resolve the namespace URI on connect rather than hardcoding ns=3 forever, because a firmware update or server reconfiguration can shift indices.
One last note on analytics and AI teams asking for OPC UA access: treat them like any other read-only IT consumer. Give them a brokered feed from the historian or an OT/DMZ gateway, never direct write-capable sessions to the PLC. OPC UA shines when it acts as a disciplined contract between control systems and everything above them, not a backdoor into the machine.