IMDHMIControls LibraryShop main store

How-to

Safe Modbus writes to PLC output registers from SCADA

Industrial networks Published 8 min read

Short answer

A Modbus write can command physical outputs whenever PLC logic copies the written word to output commands, so never map one word as both status and command. Keep a PLC-written status word that clients only read, route remote control through a separate request register validated against permissives each scan, and verify the map before go-live.

On this page
  1. Can a Modbus write to 40001 change physical outputs?
  2. How do I split status and command into separate registers?
  3. How should the PLC validate a SCADA command request?
  4. Does register 40001 mean offset 0 or offset 1 in the client?
  5. What happens to Modbus writes between PLC scans?
  6. Which clients should be allowed to write to the PLC?
  7. How do I verify the new register interface before go-live?
  8. Questions asked

Yes — and the fix is a register-map change, not a faster client or a slower poll rate. Holding registers across 40001 to 49999 are readable and writable by design, so a word at 40001 that both reports the 16 digital outputs of an M580 to Citect and feeds a MOVE onto those same outputs' commands is a control path any client can drive. Scan timing is not the hazard; the shared status-and-command word is. The narrower question of whether a plain write can reach outputs at all is answered in whether a Modbus write can change PLC outputs; this article is the interface design that stops a write commanding anything on its own.

Can a Modbus write to 40001 change physical outputs? #

Yes. The Modbus write function for a single holding register covers references 40001 to 49999; holding registers are the protocol's read/write block by design, so if your logic moves that word into output commands, any client write can change outputs regardless of scan speed. The protocol has no concept of status versus command: to the server, 40001 holds a 16-bit number, and the PLC project decides what that number does.

Trace the word from the Modbus server mapping to its PLC variable, then through every BITAND, MOVE and rung that touches it. If the variable is client-writable and any path from it reaches an output command tag, you have remote control, whatever the tag is called.

Worked example on a 16-channel DO card, with bit n of the word reporting output n + 1 and outputs 1, 4 and 6 energized, all others off:

status word = 2^0 + 2^3 + 2^5 = 1 + 8 + 32 = 41 (binary 0000 0000 0010 1001)

Reading it in Citect, BITAND(41, 8) = 8, nonzero, so output 4 shows ON; BITAND(41, 2) = 0, so output 2 shows OFF. That is the read direction earning its tag savings. The write direction on the same word is the failure: a client writing 41 commands outputs 1, 4 and 6 in one frame, writing 32768 (2^15) commands output 16 alone, and writing 65535 (2^16 − 1) commands all sixteen outputs at once. One frame, sixteen devices.

Decision: any client-writable word with a path to an output command tag is remote control — rebuild it as the split interface below before it ships as "telemetry".

How do I split status and command into separate registers? #

Keep one word the PLC writes and clients only read, and a different word clients write and the PLC consumes: in the example map below, 40001 is the status word and 40011 is the request register. The PLC becomes the sole writer of status, so a client can read what the outputs are doing but cannot state what they should do.

Logic assembles the status word from the 16 output status bits every scan; SCADA reads the word and keeps its BITAND tests, so the tag saving that justified the packing survives the redesign. Remote control moves to a request register at a separate address whose only job is to carry what a client wants, with the meaning of every value written down.

Register Who writes it Role Example value
40001 PLC only DO status word, bit n reports output n + 1 41 = outputs 1, 4, 6 on
40002 PLC only Command state: 0 none, 1 run accepted, 2 stop accepted, 255 rejected 1
40011 The SCADA server, only Request code: 0 no request, 1 request run, 2 request stop 0

The who-writes-it column is the design rule; nothing in the protocol enforces it.

Remap in five steps:

  1. Trace the current register from the server mapping to its PLC variable and list every reader and writer of it.
  2. Point the SCADA status item at the PLC-written status word as a read, keeping the bit tests.
  3. Delete every write to that word — check what the driver's read/write register object actually does, not what the tag name implies.
  4. Map the request and command-state registers at new addresses and document every value.
  5. Add the logic that consumes requests and produces both the status word and the command state.

Decision: status at 40001, requests at 40011 — two registers, two directions, no shared word.

How should the PLC validate a SCADA command request? #

Only three values ever cross: write 0 for no request, 1 to request run and 2 to request stop, and the PLC accepts a request only when the permissives pass — every other value is ignored and flagged. A request is information, not authority; each scan, logic checks it against the machine state before touching an output command tag.

  • Range: only 0, 1 and 2 are valid. Anything else is ignored and reported as 255 in the command state.
  • Permissives: a run request (1) is accepted only when the process conditions hold — a pump run request is rejected while the outlet valve is closed when the design requires it open.
  • Loss of permissive: if a condition drops after acceptance, logic removes the run command itself; the request register cannot hold an output on by itself.
  • Acknowledgement: the command-state word shows accepted, stopped or rejected, so a refusal is never silent.

One boundary: permissives over Modbus are operational interlocking, not a safety function — personnel protection stays in the safety controller or hardwired circuits.

Decision: no written value reaches an output command tag without a range check and a permissive check in the same scan that sets it.

Does register 40001 mean offset 0 or offset 1 in the client? #

40001 is the human 4xxxx notation for offset 0: most drivers take a zero-based offset, so "40001" entered as offset 1 in the client actually targets 40002, one register to the side of your status word. The 4xxxx numbers are references for people; on the wire the addressing is zero-based, so offset n points at register 40001 + n.

Many drivers and gateways take zero-based offsets while register maps are written in 4xxxx style, which is the classic off-by-one. Set the convention from the driver's documentation before the first write; never find the address by trial-writing live values. Check the type in the same pass: the status word is a 16-bit unsigned integer end to end, and a type mismatch fails without an error, for the same reason a SCADA write to a PLC real address fails silently.

Decision: before any write test, read a forced pattern back through the client and compare the raw value with the PLC word — one read catches the off-by-one.

What happens to Modbus writes between PLC scans? #

On most platforms a received write is applied at a scan boundary, not mid-rung, so two writes inside one scan collapse to the last value: never build sequencing on catching every write. Where communication is scan-synchronized — the common design — the order per scan is: incoming client writes are applied to the application data, the logic executes once against whatever landed, then outbound reads are sampled. Your logic never sees the first of two writes; last write wins, so design for it.

If every transition must be caught, add an application-level handshake rather than tuning poll rates: a request/acknowledge pair with a toggling bit or sequence number that the PLC clears before accepting the next request.

Assume writes also land when nothing is watching: on CODESYS-based controllers the Modbus server keeps answering with the CPU in stop, so a client can write the request register while no logic runs at all. Stop mode is not an interlock.

Decision: treat the request register as last-write-wins data and put sequencing in a handshake in logic — never in timing.

Which clients should be allowed to write to the PLC? #

Exactly one client — the SCADA server — gets write access to 40011: status polling clients get reads of 40001 and 40002, and the commissioning laptop gets nothing on the production network. Inventory every client with a route to the controller's Modbus service — SCADA server, historian, gateways, laptops — and enforce the split with segmentation and firewall rules between them and the PLC.

Audit the SCADA project in the same pass, because server-side scripts write too: how Citect SCADA copies %MW between M580 PLCs with a Cicode write is a writer path like any other client write, and it belongs in the inventory with the same question attached — should it be writing at all?

Decision: one writer for the request register, readers for status, nothing else on the path.

How do I verify the new register interface before go-live? #

Force a known output pattern and check the raw word against all 16 tags, then test one accepted and one rejected request with the machine in a safe state — those three checks cover mapping, direction and logic. Run them in this order:

  1. Status map: with the machine in a safe state, energize outputs 1, 4 and 6 and read the word from the client — it must be 41, and all 16 bit tests must match their tags.
  2. Direction: in the same safe state, write a test value to the status word itself and confirm no output command moves — proof the word is status, not control.
  3. Accepted request: with permissives satisfied, write 1 to 40011 and confirm the run command starts and 40002 reads 1.
  4. Rejected request: with one permissive deliberately unmet, write 1 again and confirm the command stays off and 40002 reads 255.
  5. Sequence: trend the request register, the internal accepted-command tag and the physical output through both requests — the order you record is the order you designed.

Decision: go live when all five pass, in a machine state where an unexpected output change can neither damage the process nor hurt anyone.

Questions asked

Does Modbus TCP check who is writing?

No. The protocol carries no client authentication and no per-register permissions: any TCP connection that reaches the PLC's Modbus service can issue writes to every register the server has mapped. The access decision therefore lives in the network — segmentation and firewall rules that let only the SCADA server connect — and in logic that treats every written value as a request needing permissives.

Can I mark a holding register read-only in the Modbus protocol?

No. The specification defines holding registers as a read/write block and has no per-register access attribute. Read-only status is an engineering convention you enforce three ways: map only the PLC-written word to that register, configure the SCADA item as a read, and keep unauthorized clients off the network path to the controller.

What happens to an accepted request if SCADA drops offline?

The last written value simply stays in the request register; nothing in the protocol clears it. Add a watchdog in logic: if the request register is not refreshed within a timeout you choose — 5 s is a workable choice for a slow process — remove the run command, drop to a defined state, and report it in the command-state word so the operator sees why the output stopped.

How do I control several outputs remotely without a packed command word?

Give each remotely controlled output its own request register with coded values — one register per output — and keep the packed 16-bit word for status only. Sixteen request registers cost sixteen addresses and zero ambiguity, whereas one writable command word lets a single frame carrying 65535 command all sixteen outputs at once.

Keep reading

  • Explainer

    Can a Modbus write change PLC outputs?

    Yes, but not by outrunning the scan. On a Modicon CPU the communication interface reaches data memory only between scans, so a write is applied whole and the next scan either consumes it or overwrites it. The real exposure is that Modbus TCP authenticates nothing: any host that can reach the CPU can write an unprotected holding register your logic unpacks into outputs, so pack status into read-only words, keep commands in a separate writable range, and enforce write protection with an IP access control list.

    Industrial networks

  • Troubleshooting

    Modbus exception 02 when a read crosses a register map gap

    The exception is correct: a Modbus block read requests consecutive registers, so a span from 754 through 788 includes the undefined 764-767 gap and the meter rejects it with exception 02, illegal data address. Read the 754-763 setup block at startup and after configuration changes, keep continuous reads inside the 768+ measurement area, and publish the last fully accepted set to your calculation logic.

    Industrial networks

  • Troubleshooting

    Reading Modbus TCP from a ControlLogix PLC without a gateway

    Yes — ControlLogix reads Modbus TCP without a gateway card through Rockwell's sample Modbus TCP driver, but only on controller firmware version 20 or later with socket-capable Ethernet hardware such as a 1756-EN2xx module at firmware 5.007 or later. If either side misses the gate, use a standalone EtherNet/IP to Modbus TCP converter. When the driver runs, prove one request against a known-good PC client and match unit ID, start address and count field by field.

    Industrial networks