IMDHMIControls LibraryShop main store

Explainer

Why OPC UA subscription updates beat polling PLC input changes

Industrial networks Published 7 min read

Short answer

An OPC UA subscription replaces repeated reads with server-side monitoring: the PLC's OPC UA server samples the exported variable at the sampling interval and delivers queued data-change notifications at the publishing interval. Set the sampling interval below the shortest input change you must catch, keep the queue deep enough for one publishing cycle, and confirm the change reaches the exported variable — no subscription can report a transition the PLC never saw.

On this page
  1. How an OPC UA subscription replaces the poll
  2. The intervals and queues that decide whether a transition arrives
  3. Why a poll misses pulses a subscription catches
  4. A subscription cannot report a change the PLC never saw
  5. Report by exception in other ecosystems
  6. The decision, case by case
  7. Questions asked

You can act on a PLC input change without polling: create an OPC UA subscription and let the controller's server do the watching. The client attaches a monitored item to the exported variable, the server samples that variable at a configured sampling interval, and each qualifying change arrives as a queued data-change notification at the publishing interval. Set the numbers to match the input and the computer hears every transition once, in order, with no request per change. Set them carelessly and the subscription misses pulses a poll would have caught, hides analog drift inside the deadband, or faithfully reports a variable your program never updated. This article gives the mechanism, the arithmetic that decides whether a transition actually arrives, and the decision for each case: subscribe, poll with a tighter period, or move to the other report-by-exception ecosystems.

How an OPC UA subscription replaces the poll #

OPC UA is standardized as IEC 62541, and Part 4 defines the subscription service. The client creates a subscription with a requested publishing interval, then creates monitored items inside it, each with its own sampling interval, queue and data-change filter. From then on the direction of work reverses: the server samples the variable, applies the filter, and every publishing cycle it delivers whatever has queued — or a keep-alive when nothing has. The client issues no read per change; the connection stays up and the server pushes.

Which device actually samples matters, because the server may live in the controller firmware, in a gateway, or on a separate host; the placement is laid out in Where an OPC UA server sits when Python reads PLC data. One filter deserves a number: for analog values the percent deadband is a percentage of the signal range, so on a 0 to 100 °C range a 1% deadband reports only movements beyond 1 °C. A data-change notification is not an event record — events come from alarm and condition sources — so a subscription delivers new values, not a retained history.

The intervals and queues that decide whether a transition arrives #

Setting What it decides Example used below
Sampling interval, per item when the server notices the value changed 100 ms
Publishing interval, per subscription when queued notifications leave 1000 ms
Queue size, per item which pending changes survive until the next publish deep enough for one publishing cycle
Deadband, per analog item smallest change worth reporting 1% of range
Revised intervals the values the server actually uses read back after connecting

Part 4 gives the queue rule you need: size a monitored item's queue to hold every notification generated between two consecutive publishing cycles. Servers may also revise a requested interval, and the value they settled on is reported back in the subscription status — commonly an attribute whose name says it is the actual publishing interval. Whatever your client calls it, read the revised numbers back and run every comparison on those, not on the values you requested.

Worked example #

These numbers are illustrative; keep the method. The program copies a digital input into a Boolean the server exposes. Sampling interval 100 ms, publishing interval 1000 ms, queue sized by the rule above. The sensor produces one pulse, high for 150 ms.

  • Samples fall every 100 ms, and a 150 ms window must contain at least one sample because consecutive samples are 100 ms apart — the server sees the high level whenever the pulse lands.
  • The rising edge is observed within at most 100 ms of the transition, and the falling edge likewise.
  • Two notifications queue and leave at the next publish, so the worst delay from pulse to delivery is 100 ms plus 1000 ms, which is 1100 ms; the mean is about 50 ms plus 500 ms, or 550 ms.

If the server revises the sampling to something slower than the pulse, the guarantee evaporates — that is why the revised value, not the requested one, goes into the comparison. The decision rule: the actual sampling interval must be shorter than the shortest pulse you must catch, and halving this example's sampling to 50 ms buys back margin.

Why a poll misses pulses a subscription catches #

Poll the same variable every 1000 ms and that pulse behaves differently. It opens and closes entirely between two reads unless a read lands inside the 150 ms window, so the chance of seeing it is 150 over 1000, or 15% per pulse; across 100 pulses expect roughly 85 missed. Two pulses between reads look like nothing at all, because the value returns to where it started. A poll reports levels at moments; a sampled, queued subscription reports transitions and cannot lose one whose window exceeds the sampling interval.

Polling stays legitimate when the interface offers no push and the period sits safely below the fastest change you must see — the same comparison as the example — but a short period costs requests, and one sequential poller serializes them; run clients in parallel as described in Why parallel Modbus TCP clients beat one sequential poller. Wire traffic at equal periods is comparable either way, because the server still sends a keep-alive each cycle. The subscription's advantage is capture and ordered deltas, not less steady-state bandwidth.

A subscription cannot report a change the PLC never saw #

The subscription monitors the exported variable, not the terminal. Between the sensor and that variable sit the input module's filter, the I/O update, the program scan and whatever the program writes: if the program debounces longer than the pulse, latches something else, or overwrites the exported variable later in the scan, the server samples a value that never changed and sends nothing. Verify before tuning: force the input, watch the module LED, read the exported variable directly, and compare the three. If the LED moves and the variable does not, fix the program mapping first, because no interval setting will help.

When every occurrence must be counted — pulses, faults, trips — capture them in the controller with a latch, a counter or an event list and export the capture; the subscription then reports an accumulated fact instead of a transient level. Keep this path out of any safety function: a stop or guard signal belongs on its hardwired or safety-rated channel, with OPC UA values as monitoring only.

Expecting change callbacks from a polled read of one controller family is a separate failure with its own diagnosis; see Why Snap7 reads of S7-1200 inputs give no change callback.

Report by exception in other ecosystems #

The push pattern is not unique to OPC UA; the generic terms are report by exception and unsolicited reporting. DNP3, established in electrical utility SCADA, lets an outstation send unsolicited responses that report event data without waiting for a poll; use it where both ends already speak DNP3, not as a reason to introduce a second stack. MQTT inverts the roles: the controller or a gateway publishes to a broker when a value changes, and the computer subscribes to topics, with industrial payload conventions such as Sparkplug B defining the topic and payload structure. The capture rule applies to both: no publisher can push a change its own logic never detected, so a DNP3 point or an MQTT payload is only as good as the controller-side mapping behind it.

The decision, case by case #

  • The controller exposes an OPC UA server and you act on input changes: subscribe. Set sampling below the shortest change you must catch, confirm the revised value after connecting, set publishing from the reaction budget, size the queue for one publishing cycle, and set the deadband above noise but below the smallest movement that matters.
  • Every occurrence must be counted: capture in the controller first, then subscribe to the capture. Never count on a level subscription.
  • The controller has no OPC UA server: check the manufacturer's options first; otherwise put a gateway in the cabinet — a host computer such as an industrial mini PC runs the converter that exposes the controller's data as an OPC UA server, and your client code stays the same.
  • Both ends already speak DNP3 or MQTT: use their push. Adding a stack for push alone is not worth it.
  • No push anywhere and changes are slow against your detection budget: poll, with the period below the fastest change and parallel clients once the count grows.

Questions asked

Can an OPC UA subscription write outputs back to the PLC?

No. A subscription reports monitored values only; outputs go through the write service as separate calls. Send the write, check the completion status, then confirm the new state on the monitored item. Treat notifications as the read path and writes as commands.

Does a faster publishing interval make input changes arrive sooner?

Only the delivery leg. The sampling interval decides when the server notices a change; the publishing interval decides when the queued notification leaves for the client. Halving publishing halves delivery delay but changes nothing about detection, so set sampling from the fastest input you must catch and publishing from how fast the application must react. Read back the revised values the server reports and size against those, not against what you requested.

Do subscriptions cut network traffic compared with polling?

Not necessarily on the wire. The server still sends something every publishing cycle, a keep-alive when nothing changed, so steady-state traffic at equal periods is similar. What you gain is capture and payload: notifications carry only values that passed the deadband or filter, delivered in order, and a sampled item cannot miss a pulse that opens and closes between two polls, which a poll can.

Can several computers subscribe to the same PLC variable?

Yes. An OPC UA server handles multiple sessions at once, and each client creates its own subscriptions, monitored items and intervals, so two computers can watch the same variable independently. How many sessions and items a given server accepts is a product limit, so check the controller's documentation rather than assuming one client's numbers apply everywhere.

Keep reading

  • How-to

    How to build a virtual PLC test bench for protocol practice

    One laptop runs the whole bench: a Modbus TCP server simulator, a master test client, a Node-RED OPC UA server and a SCADA trial connect over loopback, so you can practice addressing, sessions, scaling, alarms and fault diagnosis without a PLC. Work through three bounded projects and finish with seven pass criteria you can defend.

    Industrial networks

  • Troubleshooting

    Connecting Factory I/O to a local CODESYS soft PLC over OPC UA

    Yes: OPC UA only carries tag values, so the ladder or structured text must run in the CODESYS runtime. Fix the connection in order: prove the engineering path through the Gateway to the runtime first, then the OPC UA endpoint at port 4840, then map each scene point to one variable. Keep Control I/O out of it, because Factory I/O runs one driver at a time.

    Industrial networks

  • Explainer

    Why parallel Modbus TCP clients beat one sequential poller

    Give each Modbus TCP slave its own client on the PLC and start every next request from the previous completion. A reported bench test held about 85 updates per second per client at a 10-register read, and raising the payload from 1 to 100 registers only dropped the rate to about 80 per second, because transaction count and scan scheduling — not register count — set the polling speed.

    Industrial networks