Troubleshooting
Why a Modbus coil read fails when the request block is too long
Short answer
Exception 02 on a Read Coils exchange means the server checked every address from the start through start + quantity - 1 and found one outside its coil map, so it rejected the whole read. When a client that reads full bytes asks for 8 coils from a device that maps only 4, the first four coils in an easyE4 base unit, the valid start address still fails. Cut the quantity to fit the map; in HMI Droid that is the "Always read full bytes" setting.
On this page
- Why do marker and input reads work while the coil read fails?
- What does Modbus exception 02 actually reject?
- How do you calculate the coils a request really covers?
- Why does the client ask for eight coils when the screen shows four?
- How do you fix the block length without changing the controller program?
- What should the packet capture show after the fix?
- When is the block length not the problem at all?
- Questions asked
When a controller serves marker and discrete-input reads but answers a Read Coils request with exception 02, suspect the quantity field, not the start address. The server checks every address in the covered interval, start through start + quantity - 1, and one unmapped coil anywhere in that interval fails the whole read. A client that rounds bit requests up to full bytes asks for 8 coils, and a controller that maps only 4, like the first four Modbus coils in an easyE4 base unit, refuses it. Cut the requested quantity to fit the mapped range, in HMI Droid the setting is called "Always read full bytes", and the read goes through.
Why do marker and input reads work while the coil read fails? #
Because each data area is checked against its own map, and only the coil request leaves its map: marker reads sit inside the exposed marker-word range, input reads inside the discrete-input area, and the coil read runs off the end of a four-coil area.
The reported installation is a useful template: three easyE4 controllers on Modbus/TCP behind a wireless router on a separate controls network, polled by a tablet app. Marker words could be read and set, discrete inputs could be read by selecting the input area and using the input number, and only the output-state read failed; a packet capture showed a Read Coils request answered by an exception. An exception is an answer, not a dropped connection: the server received the request, parsed it and said no.
Modbus keeps separate maps for the bit areas and the word areas. The easyE4 Modbus configuration exposes marker words from MW1 up to a configured end; read that endpoint from the configuration instead of assuming every marker word is available. Reads inside the exposed range succeed, and reads past it fail on the same principle as the coil read. The discrete inputs worked through the same full-byte request logic, which tells you that area is at least 8 points wide. The coil area in the base unit is 4 points wide, and that difference is the entire fault.
What does Modbus exception 02 actually reject? #
The combination of starting address and transfer length: exception 02, illegal data address, is the server's answer when the interval covered by the request contains at least one address it has not defined, and the whole read is refused.
The protocol defines the code to cover an invalid combination of starting reference and transfer length, not only a bad start. In plain terms the server walks the entire requested interval against its map and rejects the read if any single address in it is undefined; a documented example of Modbus exception responses shows exactly that for one coil missing from a slave's map. Client software words the condition differently, and one SCADA driver logs it as 0x02 IllegalDataAddress on a ReadCoils request, but the meaning is fixed by the protocol.
An exception response also tells you three things worked: the server is reachable, the function is supported, and the frame was parsed. That is why a marker read that succeeds and a coil read that returns 02 point at the coil map rather than the network. The same code appears on the register side when a read spans a hole between mapped blocks, which is what Modbus exception 02 when a read crosses a register map gap works through.
How do you calculate the coils a request really covers? #
List the interval from A through A + N - 1, with A the starting address in the frame and N the requested quantity, then check every address in that interval against the device's coil map: a single unmapped coil fails the read.
Read A and N from the captured request frame, not from the number of lamps on your page. The page shows what you wanted; the frame shows what was asked.
Worked example, easyE4 base unit with full-byte reads enabled. The base unit maps the first four Modbus coils, at offsets 0 through 3. Your lamp sits on the first coil, so the frame carries start A = 0. The client rounds up to a full byte and sends quantity N = 8. The covered interval is 0 through 0 + 8 - 1 = 7. Offsets 4, 5, 6 and 7 are not in the map, so the server returns exception 02 against a start address that is perfectly valid. With full-byte reads disabled the quantity becomes N = 4, the interval is 0 through 0 + 4 - 1 = 3, every address is mapped, and the read succeeds.
Two consequences follow from that arithmetic. No start address rescues an 8-wide request in a 4-wide map, because the map's widest valid interval is 4, so an 8-wide request misses somewhere no matter where it starts. And both quantities fit one response byte, since 8 coils pack into 1 byte and 4 coils pack into 1 byte, so response size was never the constraint; the requested interval was.
One address caution before you trust A: check whether your client displays 1-based reference numbers while the frame carries the zero-based offset the protocol transmits. That off-by-one territory, and the byte offsets that come with it on the register side, is what fixing Modbus TCP addressing errors between an HMI and a PLC works through.
Why does the client ask for eight coils when the screen shows four? #
Because the client rounds bit requests up to whole bytes: HMI Droid and Odrid HMI read full bytes of coils and discrete inputs, a choice that works with most PLCs and fails on small controllers and I/O modules that map fewer than 8 points in the requested area.
Byte packing belongs to the response format, not to the request. Coil states travel packed 8 to a byte, and that places no requirement on the request quantity: a request for 4 coils is legal and is answered with one data byte whose upper four bits are not part of your request. Asking for 8 is the client's implementation decision. The app vendor documented the full-byte behavior for both apps, noted that it fails on small controllers and I/O modules with fewer than 8 points in an area, and shipped an option to stop doing it; the version history entry for 1.7.8.116 names reading the first four coils of an Eaton easyE4 base unit as the case the option addresses.
How do you fix the block length without changing the controller program? #
Reduce the requested quantity until the entire interval sits inside the mapped coil range: in HMI Droid, uncheck the setting called "Always read full bytes" in the app settings from version 1.7.8.116, and the request shrinks to the points your objects use.
Work through the options in this order:
- Uncheck "Always read full bytes" in the HMI Droid app settings, version 1.7.8.116 or later, so the request carries the quantity your objects actually use.
- If the client offers no quantity control, split the page so each read block both starts and ends inside a mapped range, and check each block with the interval arithmetic above.
- If neither is possible, copy the states you need into exposed marker words in the controller program and read them as registers; the easyE4 exposes marker words from MW1 up to the configured end, and a word read sidesteps the small coil map entirely.
Then confirm the change on the wire before you call it fixed.
What should the packet capture show after the fix? #
A Read Coils request with quantity 4 answered by a normal one-byte response, replacing the failing pair of quantity 8 followed by the exception response: that frame pair is the proof that block length was the fault.
Read these fields from the two exchanges:
- Destination address and unit identifier: the controller you intended to poll, unchanged by the fix.
- Function field: Read Coils in both the failing and the working exchange.
- Start address field: the same value before and after, because the fix never touches it.
- Quantity field: 8 in the failing request, 4 in the working one.
- Response: the exception response before, one normal data byte after.
One caution when you put the result to work: a coil read reports the controller's commanded state, not the physical output, so it does not prove a valve moved, and final elements must be verified electrically before the machine is treated as safe.
When is the block length not the problem at all? #
When the controller sends no reply at all, or a plausible value changes on the wrong controller: those are path, addressing and duplication faults, and no quantity change fixes them, so diagnose them first.
Silence is not an exception. A request that draws no reply points at the transport path, the wireless-to-wired hop, the fixed IP addresses, the station numbers and the server enablement, and that is a different walk, the serial version of which is fixing an HMI Modbus device that sends no response over RS-485. With several controllers on one network, record each fixed IP address and station number, check for duplicates, and test one controller at a time so a value that changes proves which one answered.
Finally, read the exception code itself. The block-length mechanism explains code 02; a different code means the server rejected something else about the request, and the captured frames, not the coil map, are where that answer lives.
Questions asked
Does exception 02 mean the starting address itself is wrong?
Not necessarily, and in this failure it usually does not. The server rejects the combination of start and quantity, so a start address that reads fine on its own still fails when the quantity pushes the covered interval past the last mapped coil. Read both fields from the captured request before you move the start.
Why did discrete input reads work on the same device?
Because the same full-byte logic stayed inside the map. HMI Droid and Odrid HMI round bit requests up to whole bytes for coils and discrete inputs alike, so working input reads tell you that area is at least 8 points wide. The coil area in an easyE4 base unit is 4 points wide, and that difference is the whole fault.
Where is the setting that stops the client reading full bytes?
In HMI Droid it is called "Always read full bytes" and it appears in the app settings from version 1.7.8.116, which the vendor released to open beta with the easyE4 four-coil case named as its purpose. Uncheck it and the request carries the quantity your objects actually use.
Can I fix it by copying output states into marker words instead?
Yes, that is a legitimate workaround when you cannot change the requested quantity. Copy each output state to an exposed marker word in the controller program and read those words as registers; the easyE4 Modbus configuration exposes marker words from MW1 upward to a configured end. You trade a coil read for a word read and keep the display working.
Does a successful coil read prove the physical output switched?
No. The coil reflects the controller's commanded state only. It does not prove the output circuit energized, the contact closed or the hydraulic valve moved, so verify final elements electrically or with field feedback before you treat the machine as safe.