IMDHMIControls LibraryShop main store

Troubleshooting

Why Modbus cannot transfer a PLC ladder program over TCP

PLC programming Published 7 min read

Short answer

No Modbus address reaches ladder memory: the application protocol defines four data tables — coils, discrete inputs, input registers, holding registers — and program storage is not in any of them. Swapping RTU for TCP changes transport, not protocol. On DirectLogic PLCs the program moves only over K-Sequence or DirectNET through the vendor's programming tools; Modbus stays for mapped user data.

On this page
  1. What the Modbus standard puts within reach
  2. Why ladder memory sits outside the data map
  3. What each failed attempt is actually doing
  4. Worked example: the request you are imagining
  5. The transfer path that moves a program
  6. The decision for each case
  7. Questions asked

There is no Modbus address for ladder memory — not over the serial port, not over Modbus TCP, not in any register range. The Modbus application protocol gives a client four data tables — coils, discrete inputs, input registers and holding registers — and your PLC's data map puts user V-memory words and bits in them and nothing else. The executable program lives in a store the protocol cannot see, which is why every register guess returns process data or an exception, and why swapping RTU for TCP changes nothing. A ladder program moves only over the controller's programming protocol — K-Sequence or DirectNET on AutomationDirect DirectLogic PLCs — driven by the vendor's programming package or its standalone loader utility. Keep Modbus for mapped process data and give the program its own transfer path. What follows: what the standard allows, what each failed attempt actually does, the arithmetic that closes the question, and the decision for each case.

What the Modbus standard puts within reach #

The MODBUS Application Protocol Specification V1.1b3, published at modbus.org, defines that data model precisely: coils on 0x references, discrete inputs on 1x, input registers on 3x, holding registers on 4x. Function codes 01–04 read the tables, and 05, 06, 15 and 16 write them. The same specification caps a read at 2,000 bits (0x7D0) for codes 01 and 02, at 125 registers (0x7D) for codes 03 and 04, and caps code 16 at 123 registers (0x7B) per request. Everything a compliant device exposes sits in those tables, and the vendor's data map decides which physical memory each address reaches — on these DirectLogic PLCs, that is user V-memory. Program storage has no table, no function code and no offset. Function codes outside the standard set are vendor-defined, and where a vendor puts program transfer behind one, that code speaks the vendor's programming protocol — not something a generic Modbus master can use.

Why ladder memory sits outside the data map #

The split is deliberate. The CPU's operating system executes the ladder from a store it manages as code; the communications firmware maps user data into the Modbus tables according to the data map printed in the PLC manual. A fieldbus that could address executable memory would let any node on the network rewrite the logic driving a running machine, so every vendor keeps program storage off the data map. Upload and download are engineering operations — mode changes, target checks, revision checks — and the vendor keeps them behind a programming protocol whose other end is a known tool. That design decision, not a missing driver or a wrong switch setting, is what the search for program registers keeps colliding with.

What each failed attempt is actually doing #

  • Reading guessed program registers. The address either falls inside the data map, and you get a live V-memory value, or outside it, and the CPU answers exception code 02, ILLEGAL DATA ADDRESS. Either way the buffer holds data, not instructions.
  • Writing the ladder with a Modbus master. Function codes 05, 06 and 16 write coils and registers; there is no function code that assembles or downloads logic. A write that returns a normal response has changed a process value — stop treating writes as a transfer method.
  • Switching RTU for TCP. Modbus TCP wraps the same function codes and the same four tables in a TCP envelope on port 502. The transport changed; the addressable memory did not.
  • Asking the HMI or SCADA client for the program. A display that polls over Modbus can show only what the data map holds. If its values show question marks, that is a comms-timeout problem — the one covered by why HMI values show question marks — not a blocked program read.
  • Blaming the loader utility for TCP. Whether the standalone loader speaks TCP depends on its release, so settle that from the tool's own release documentation before you design the procedure around the limitation.

Worked example: the request you are imagining #

The limits below come from the specification; the program size is an illustrative input — read the real figure from your programming package's project report.

Say the project compiles to 24 KB of program memory, 24,576 bytes. A Modbus register is 2 bytes, so a hypothetical program range would need 24,576 ÷ 2 = 12,288 registers. A single code-03 read carries at most 125 registers — 125 × 2 = 250 bytes — so even a fictional range would take 12,288 ÷ 125 = 98.3, that is 99 read transactions. Writes fare no better: code 16 tops out at 123 registers per request, 123 × 2 = 246 bytes, so 24,576 ÷ 246 = 99.9, which rounds up to 100 write transactions.

None of those transactions can be formed, because no address range holds the ladder. A guessed start offset either lands inside the data map and returns process values, or lands outside it and returns the ILLEGAL DATA ADDRESS exception. For contrast, a legitimate read of 2 mapped registers returns a byte count of 4 — 2 × 2 — and those bytes are user data. The transfer is impossible over Modbus; that is the specification working, not a configuration problem.

The transfer path that moves a program #

  1. Develop and edit the ladder only in the vendor's programming package. Ladder development is a programming-tool function; no Modbus master can write logic.
  2. Move the program with the programming package or the vendor's standalone loader utility, over K-Sequence or DirectNET — the protocols identified for ladder memory on these AutomationDirect DirectLogic PLCs.
  3. Match the port settings to the protocol before connecting: the K-Sequence connection guide has you set the CPU port to the K Sequence Protocol and the mode switch to TERM, and has you set a station number on a D4-440 CPU.
  4. Over Ethernet, use the connection the tool documents: the programming package's Ethernet link carries its programming packets inside TCP or UDP. TCP is the envelope, not a conversion into Modbus. If you want the standalone loader over TCP, confirm the installed release supports it in that release's documentation before building the procedure around it.
  5. Put the machine in a safe state and confirm the target CPU and the approved program revision before any download: a transfer replaces the logic that is driving outputs.
  6. Verify at the CPU afterward with the programming tool's compare or read-back, never with a Modbus read — mapped data moving correctly proves nothing about which program is in the CPU. If the download stalls after a clean compile while the tool still reports a live connection, a project that compiles but will not upload to a PLC works through that specific failure.

The decision for each case #

What you need Use Do not use
Live process data in a PC application Modbus reads and writes against the documented data map Any address treated as program memory
Develop or edit ladder logic The vendor's programming package A generic Modbus master
Upload or download the program The programming package or the vendor's loader over K-Sequence or DirectNET Modbus function codes of any kind
Program transfer across the plant network The tool's documented TCP connection — the programming Ethernet path, or the loader release whose documentation lists TCP support Modbus TCP

Three decisions follow from the table. If the PC application only needs data, keep Modbus and map its addresses deliberately — the original design was sound. If it needs the program, the request as posed cannot be met: schedule the transfer through the programming path and leave the Modbus client on data duty. If backups keep waiting for a laptop to show up, put a maintenance station at the cabinet door — an industrial panel PC that lives there runs both the programming software and your Modbus data logging.

The decision in one line: Modbus never touches the ladder on any compliant PLC, the ladder path on these DirectLogic CPUs is K-Sequence or DirectNET through the vendor's tools, and TCP matters only where that tool chain documents it.

Questions asked

Can a Modbus write download part of a PLC program?

No. Function codes 05, 06 and 16 write coils and registers, and the PLC's data map decides which physical memory each address reaches — user data words and bits only. Executable ladder lives in a store no Modbus address maps. A write that returns a normal response has updated a data word the running logic reads, not written a single instruction. That updated word can move an output on a running machine, so keep Modbus write access limited to addresses you mapped deliberately.

Does function code 04 reach the program where 03 cannot?

No. Function code 04 reads the input-register table instead of the holding-register table, with the same 125-register ceiling per request, and the data map decides what lives in each. Swapping function codes changes which table you touch, not how many tables exist. None of the four holds instructions, so the request returns mapped process values, or exception code 02 when the offset falls outside the data map — exactly as a holding-register read would.

How do I keep ladder backups if the plant software is Modbus-only?

Treat backup as a maintenance task, not a fieldbus feature. After commissioning and after every approved change, run the vendor's programming package or loader utility from a maintenance station, upload the program, and store the project file with the revision that produced it. Keep the Modbus-only client out of the program path entirely: it reads and writes mapped process data and never touches the program store. A station that stays at the machine is what makes the routine stick.

What does Modbus exception code 08 mean during a large read?

Exception code 08 is Memory Parity Error: the server device checked its own memory while servicing the request and the check failed. It is a device-side fault report, not proof that you found hidden program memory. Oversized requests beyond the documented ceilings of 125 registers on a read and 123 on a write have also been reported to trigger firmware faults on some devices, so keep block sizes inside the specification's limits and the device manual's.

Do other PLC brands expose program memory over Modbus?

No. The four-table data model is part of the Modbus application protocol itself, so no compliant device exposes program storage as coils or registers regardless of brand. What differs per vendor is the programming protocol and the tool that speaks it — one vendor uses K-Sequence or DirectNET for its DirectLogic PLCs, another defines its own loader protocol. If a device answers a request that reads or writes its program, that request is speaking the vendor's protocol, not Modbus.

Keep reading

  • How-to

    How to build ladder logic practice projects in STEP 7

    Get STEP 7 ladder practice projects from the vendor's own support portal and from the samples the installer already placed on your PC, not from a copy of a book's bundled disk. Then rebuild three circuits yourself: a start/stop latch with overload interlock, an on-delay timer sequence, and an up/down counter.

    PLC programming

  • Troubleshooting

    Why HMI values show question marks: PLC comms timeouts

    Yes — a running PLC program can cause intermittent HMI timeouts by consuming nearly all controller execution time, and clean Ethernet counters do not clear it: utilization measures bytes, not the cost of servicing requests. Work controller load first: Task Monitor above 90% on the dropping units against 7–15% on healthy ones, then message pacing, packet-rebuild address forms, read grouping, and power last.

    PLC programming

  • How-to

    Remote I/O commissioning checklist for a modular station

    Commission a modular remote I/O station in this order: match the coupler's protocol and addressing to the controller interface, budget and verify station power, seat modules and connectors against the drawing, then prove cyclic data exchange and every field signal before enabling outputs. A loading web page and lit status LEDs prove the coupler is alive; only a value that changes at the controller proves valid I/O data.

    Controllers and I/O