IMDHMIControls LibraryShop main store

Explainer

Synchronous PLC reads: what one grouped request guarantees

SCADA and data logging Published 9 min read By IMDHMI controls team

Short answer

A grouped client request to the server does not give you a coherent PLC snapshot: coherence exists only when the driver reads the tags in one device transaction. Put a bit and an integer in one contiguous block of one memory type, or copy them into a PLC snapshot buffer with a before-and-after sequence marker; on a PLC-5, different data files make the buffer mandatory. Faster polling narrows the skew but never removes it.

On this page
  1. What a grouped request actually synchronizes
  2. Coherence lives in the driver transaction
  3. The memory-type rule on file-based PLCs
  4. When no PLC change is acceptable
  5. The snapshot buffer: payload plus a before-and-after marker
  6. Worked example: fast events against a slow poll
  7. Prove it before you trust it
  8. The decision for each controller
  9. Questions asked

A grouped request from your client to the server is not a coherent PLC snapshot. The server answers from its cache, the cache is filled by driver transactions, and a bit and an integer that reach your client together can have been captured whole update cycles apart. Coherence exists at exactly one place: the device transaction. So the rule is short. If the bit and the integer sit in one contiguous region of one memory type, the driver can read them in one transaction and the pair is coherent by construction. If they do not — and on a PLC-5 a binary-file bit and an integer-file word never do — you must build the snapshot in the PLC and validate it with a sequence marker that the client reads before and after the payload. Faster polling narrows the skew. It never removes it.

What a grouped request actually synchronizes #

Four boundaries sit between the machine and your chart. The PLC scan writes its data files. The driver polls the device at the device update rate and fills the server cache. The server answers your client from that cache. Your client assembles the values on screen or into the log. Grouping items into one client call synchronizes only the last boundary. Every cached value carries the timestamp of the moment the driver acquired it, and the UA data-access specification defines the server timestamp as the time the server obtained the value, so differing timestamps on a delivered pair are direct evidence of separate acquisitions. What looks simultaneous on the client is delivery-simultaneous, not capture-simultaneous, and no client setting changes what the driver did downstream.

Coherence lives in the driver transaction #

The driver builds its poll from the tags you define. Addresses it can combine into one contiguous, same-type block are read together; addresses that cross a block boundary or a memory-type change are split into separate transactions. How much a driver may combine is a documented limit of that driver, not a universal rule: the Micro800 Ethernet driver documents a block-size option of 30 to 3840 atomic array elements per transaction with a default of 120, and other drivers publish their own numbers. Splitting can also fail loudly instead of silently: a Modbus device answers a block it cannot serve with exception code 2, illegal address, or exception code 3, illegal data, and drivers carry a setting to stop polling a block when those exceptions arrive.

Settle it for your own pair in one minute. Define only the bit and the integer, make both change, and watch the driver diagnostics that count device requests per update cycle. One request per cycle means the pair already travels in one transaction and is coherent. Two requests per cycle means the pair is split, and no server configuration can merge it, because the separation comes from the controller's memory layout rather than from anything the client or server chose.

The memory-type rule on file-based PLCs #

PLC-5 data lives in typed files. A discrete flag belongs to a binary file such as B3, a number belongs to an integer file such as N7, and those are different memory types. The controller cannot serve one read that spans them, so every update of that pair costs two transactions, and the two values inside them are as far apart as the polling allows. The same file-structured data model runs the SLC 500 and the MicroLogix family, and the PLC-3 keeps the same file-structured data table, so one rule covers all four families: one memory type per read.

ControlLogix and CompactLogix are tag-based instead, and a DINT array is contiguous by construction. That is why reading PLC tag arrays in one block request yields a single transaction there. The array is still not automatically a snapshot: if the logic writes element one in one scan and element two in the next, one transaction delivers two different scans' values. The array makes the single read possible; the program makes it coherent.

An S7-400 refreshes its process image once per scan, so reads of I and Q come back scan-consistent. M memory and DB words carry no such boundary, so they follow the same buffer discipline as the data of any other controller.

Mixed values are not stuck values: a bit that never changes over Modbus TCP is an addressing fault with its own repair, covered in why a Modicon M221 bit stays fixed in Kepware over Modbus TCP, while a pair that both move but disagree is the coherence problem this page is about.

When no PLC change is acceptable #

Zero modification works in exactly one case: the tags already sit in one contiguous, same-type region, so the driver already reads them in one transaction. Confirm that with the request counter described above rather than with hope. Adjacent addresses in different files still split, and two same-type words that straddle a block boundary the driver refuses to cross split as well.

The smallest change that fixes a split pair is to carry the flag inside the value's own word. Move the logic that drives the bit onto a bit of the integer word that holds the number, N7:12/15 in standard addressing, and one read returns both. If the discrete address must stay, keep the coil where it is and add one rung that copies it into the word each scan, which is a two-instruction change. Modbus devices have the client-side equivalent: keep the flag in a bit of the register and let the item reference address that bit directly, the technique in Modbus register bit addressing in a SCADA item reference.

Anything larger, a multi-word record captured at one instant, is the buffer in the next section, and it needs program space in the controller. For a PLC-5 pair split across B3 and N7 there is no server-side workaround: some PLC-side change is unavoidable.

The snapshot buffer: payload plus a before-and-after marker #

The general design runs on every controller in the fleet. The PLC copies the related values into a buffer at one defined point in the scan, after every value that belongs to the event has been updated, and publishes the copy under a sequence counter that moves twice per capture: the first increment makes the counter odd, the payload is written, the second increment makes it even again. The client reads the counter, reads the payload, reads the counter again, and accepts the payload only when both counter reads are equal and even. An odd value means a capture is in progress and the payload may be half-written, so the client drops that cycle and waits for the next poll.

The bracket has to be proved, not assumed. Use the server timestamps to confirm the three values were acquired in marker, payload, marker order; a marker read from an earlier update cycle cannot validate a payload acquired after it. When no event may be lost between polls, a single buffer is not enough either: keep a short ring of retained snapshots under the same counter discipline and read the oldest slot your window still covers.

One caution, once: this handshake protects data coherence, not people, and any protective action keeps its own validated safety function.

Worked example: fast events against a slow poll #

Setup: a cutter raises a run flag and reports a measured length at 20 events per second, so one event every 50 ms, and the device update rate in the server is 250 ms.

Split reads, no PLC change: with the flag in B3 and the length in N7, every update costs two transactions, so the delivered pair can be up to 250 ms apart. That is 250 ms ÷ 50 ms = 5 events of skew.

Retention sizing: a retained snapshot must survive one full poll interval, and 250 ms ÷ 50 ms = 5 event periods, so a ring of 6 slots holds a 300 ms window, 1.2 times the poll. If one missed poll must be survivable, size for a 500 ms gap: 500 ms ÷ 50 ms = 10 slots, and take 12 for margin.

Counter width: a 16-bit marker passes through 65536 values and moves twice per capture, so it wraps after 65536 ÷ 2 ÷ 20 = 1638.4 s, about 27 minutes. The gap between the two marker reads is bounded by the request timeout; the Triconex Ethernet driver, for one, documents a range of 50 to 10000 ms with a 1000 ms default, so a timeout-bounded worst case is 10 s. The 27-minute wrap dwarfs it, and 16 bits is safe while the client's worst pause is one timeout. If the client can pause arbitrarily, as a sleeping laptop or a retrying WAN link can, the wrap can land exactly on the gap and pass a stale payload as valid; then use a 32-bit counter, a DINT on Logix or two integer words on a PLC-5, which at 20 events per second wraps after 2147483648 ÷ 2 ÷ 20 = 53687091.2 s, about 1.7 years.

Prove it before you trust it #

Reject and count every capture that fails the marker check instead of logging it as good data; silent substitution is how a split read becomes a wrong record. Test with the process running, because a stationary flag and a fixed number hide both the split and the tear. Compare accepted captures against a controller-side count of events to measure what the polls actually miss. The host that polls, validates and logs the snapshots, the data logger or small historian beside the controller in the cabinet, must finish its marker-payload-marker read inside the retention window you sized, and the usual host for that station is an industrial mini PC.

The decision for each controller #

  • PLC-5: a binary-file bit and an integer-file word always split. Pack the flag into a bit of the value word when latest-value coherence is enough; otherwise run the snapshot ring with an even/odd marker in integer words, sized from the poll interval in the example.
  • SLC 500 and MicroLogix: the same file model gives the same decision, with the bit-in-word move as the smallest fix and the marker buffer as the complete one.
  • PLC-3: same file-structured data table, so decide it as the PLC-5 case.
  • ControlLogix and CompactLogix: build the record as one DINT array, write all of it inside one scan, publish it with a DINT marker, and read the array as one block request.
  • S7-400: pairs read from the process image are scan-consistent already; anything kept in M memory or a DB needs the buffer, captured in one place at one point of the scan.
  • Modbus devices: coils and holding registers are different memory, so a coil-plus-register pair splits; carry the flag inside the register and address the bit through the item reference.

Questions asked

Do tags delivered together share a server timestamp?

Values the driver acquired in the same transaction carry the same server timestamp, so equal timestamps are strong evidence of a single transaction. They prove the server read the pair together, not that the PLC produced them in the same scan, because capture still happened at the driver poll. Use the timestamps to confirm the marker-payload-marker ordering of a snapshot read, and read differing timestamps as the signature of a split pair.

Does one client call, such as a single OPC UA read, force one device transaction?

No. A client that asks for many items in one service call still receives cached values, and the driver still acquires them in as many transactions as the address layout forces. Grouping at the client or at the server interface never merges device transactions; only a contiguous same-type block that the driver can read in one pass does.

How wide should the sequence marker be?

A 16-bit marker wraps after 32768 captures, roughly 27 minutes at 20 events per second, which dwarfs any stall a request timeout can produce, so 16 bits is adequate while the worst client pause stays inside the timeout. Move to a 32-bit counter, a DINT on Logix or two integer words on the older families, whenever the client can pause for an unbounded period.

Would pushing from the PLC remove the whole problem?

For capture fidelity, yes: controller-initiated messaging hands the record to the network at the moment it was captured, with no poll race at all. The same discipline still applies, because the receiver must be able to tell a complete record from a half-written one, so the payload-then-marker handshake travels with the design. This page's buffer is the pull-side equivalent of that push handshake.

Keep reading

  • How-to

    Control PLC connect and disconnect from a button

    Run the whole connect and disconnect cycle from one button with DisableSubscriptions: True while the operator edits settings, False only after the address is bound as a new Drivers.PLCAddressItem. EthernetIPforCLXCom drops its connection about 5 s after requests stop; OpcDaCom exposes no disconnect method, only paused subscriptions.

    SCADA and data logging

  • Troubleshooting

    Fixing CODESYS OPC DA memory growth stopping SCADA reads

    The reads stop because WinCoDeSysOPC.exe, a 32-bit OPC DA server process, climbs to its 2 GB memory ceiling over weeks and then stops serving tags; killing it only resets the clock. The resolution that held was installing the current, licensed CODESYS OPC DA server — 3.5.22.40 in place of the CODESYSV35SP10Patch2 install — and proving it through the old failure window.

    SCADA and data logging

  • How-to

    Getting CompactLogix PLC data into Excel over EtherNet/IP

    Excel has no EtherNet/IP client, so a CompactLogix reaches a workbook only through a driver layer: an RSLinx edition that documents OPC or DDE support, or a driver library used within its license — RSLinx Classic Lite does neither. Put the PC and controller on one subnet, prove a single controller-scoped tag read, map that one cell, and add writes only against a dedicated test tag the logic validates.

    SCADA and data logging