Troubleshooting
Why a PLC Modbus Master Read Returns Nothing From an HMI
Short answer
When a PLC Modbus RTU master polls an HMI slave and gets nothing back, three faults hide behind the flashing LED: DTR direction control left at 0 instead of 2, the wrong starting address for LB0, and a one-scan enable that kills the transaction before Done. Fix them in that order.
On this page
When the PLC is the Modbus RTU master and the HMI panel is the slave, a flashing comms LED with no usable data almost always comes down to three faults, and none of them is the cable. In the case this article is built from, the panel reported that the PLC was not responding; the fixes, in order, were: set DTRManagement from 0 (DTR_OFF) to 2 (DTR_AUTO_WO_TIMES) so the two-wire RS-485 port can switch direction; enter starting address 1 with FCcode 16#01 to read the panel's LB0, not 40000; and hold the master function block's enable active until it reports completion, because a one-scan pulse every 100 ms starts a transaction and then removes it. Work through them in that order, on one panel, before touching termination resistors or polling intervals.
Separate the three faults before changing the bus #
A flashing comms LED proves activity, not delivery. Terminating the bus differently or polling faster will not repair a port that cannot turn around, a request for the wrong address, or a transaction whose enable disappears. Map the symptom first:
- The panel reports that the PLC does not respond, and the test object does not even appear on screen — serial direction control, port selection, or the panel's device configuration.
- The comms LED flashes at the poll rate but the bit never changes — traffic without a valid completed response: wrong function code or wrong starting address.
- A transaction starts on every timer pulse but never produces data — the enable drops while the asynchronous block is still mid-transaction.
- One panel works, added panels do not — node addressing, overlapping transactions, or multidrop wiring.
Judge every fix the same way: a completed read in which the received bit follows the panel's toggle through both its states. Count the Done and Error edges of the block and store its status word whenever Error is set, so a completion on error is never mistaken for a data refresh.
Give the port automatic direction control #
Set the roles first: the PLC is the only master, the panel answers as a slave. Check the panel's device configuration, not just the screen objects — if the toggle is assigned to an external PLC device, the panel is trying to poll on its own and you have two masters on one bus, the mirror image of an HMI Modbus timeout caused by a master–slave conflict.
Then the physical link:
- Confirm the controller's "fieldbus" terminals belong to the port opened as COM2 with Sysfopen in mode rw, so the port can both transmit requests and receive responses.
- On the panel side the connection uses pins 1 and 2 of COM1; pin numbers alone do not establish polarity, so follow the signal labels at both connectors.
- Match baud rate, parity and framing by reading the actual settings from both devices, and set the panel's slave node address.
Now the setting that stopped this installation: DTRManagement. On a two-wire RS-485 port, DTR is the direction switch. The value is 2, DTR_AUTO_WO_TIMES, not 0, DTR_OFF. In two-wire DTR-controlled operation the receiver is disabled while the transmitter drives the bus, which is what keeps the port from reading back its own request; with automatic management the serial driver asserts transmit around the outgoing frame and releases it for the response. With DTR off the direction never switches, so the request–response exchange cannot complete and the panel correctly reports no response.
The 50 cm bench cable with 100 Ω termination resistors is not the problem at this length; a short cable tolerates that value without validating it. For the permanent bus, take the termination value from the cable and device documentation, fit it at the two physical ends of the segment, and check for built-in termination before adding external resistors.
Decision: if the panel still reports no PLC response, stay in this section — roles, port, polarity, direction control — and do not move to addressing until a request leaves and a response returns.
Enter address 1 for LB0 #
A panel toggle stored in local bit memory is read as a coil, so FCcode stays 16#01. The starting address is where this failed: 40000 points outside the panel's local-bit area in this setup. The block's address field is one-based at the application level, so the address for LB0 is 1 — its LB number plus one.
Keep three layers separate:
- Panel memory label: LB0 is the bit the button toggles.
- Function-block address: 1 in this one-based convention.
- Wire address: the Modbus protocol address carried on the bus is zero-based, so the same bit appears as coil 0 in a different master library or a bus monitor.
Reading 16 bits from address 1 returns LB0 through LB15. Eight toggle buttons placed from LB0 occupy LB0 through LB7 — a screen description saying "LB0 to LB8" covers nine bits, so read the object assignments rather than the count. Toggle the button off and on and watch the received bit: both states must arrive, because a constant 0 does not distinguish a valid off from stale data. Never build an interlock on a bit carried this way — a missed response leaves the last value standing, so local-bit data is operator-interface information, not a safety signal.
Hold the enable until the block completes #
ModbusRTUMaster_v1 is asynchronous: it executes across repeated PLC scans, sending the request, waiting for the response, and collecting it. It is not an instruction that returns the answer inside the scan that called it.
The failing arrangement enabled the block with a positive-edge contact every 100 ms. That pulse starts a command, and the next scan removes the enable — and removing the enable terminates the block's operation. Repeating the pulse does not service the interrupted transaction; it starts another one.
Wire it as a maintained state instead:
- A start variable — StartCom in this setup — enables the block and stays set.
- The block keeps executing while StartCom is active and manages the exchange itself.
- Done clears StartCom, and so does a completion on error, which you count separately from a successful update.
- The next transaction rearms only after the state has cleared.
For a fixed cadence, let a timer set StartCom and let the Done of the last block reset it; the whole communication cycle must finish inside the timer period. Blocks of this kind also cascade: they issue their commands sequentially in the order they are enabled. A chain of four — read 16 coils, write 16 coils, read 8 registers, write 8 registers — each enabled by the previous completion, with Done[3] restarting the cycle and the Delay variable pacing it. The write steps fail the same way when the address convention is wrong, as covered in why a Modbus RTU master write never reaches an HMI holding register.
Worked example: polling LB0 through LB15 every 100 ms #
Inputs, each from the installation:
- One panel as the only slave, toggle object on LB0 (panel program).
- Two-wire RS-485 link, bench cable 50 cm long, 100 Ω termination resistors fitted (bench hardware).
- DTRManagement at 2, DTR_AUTO_WO_TIMES, after the direction-control fix (serial port setup).
- A read of 16 coils with FCcode 16#01 (master function block parameters).
- Poll request every 100 ms, driven by a positive-edge contact on the enable (PLC program).
Rules in words: the address for a local bit is its LB number plus one; the enable must stay active from the start of the transaction until the block reports completion; and a completed cycle must fit inside the retrigger period.
The arithmetic:
- Starting address for LB0: 0 + 1 = 1. The 40000 first tried points outside the local-bit area.
- End of the 16-bit range: 1 + 16 − 1 = 16, which is LB15, so one read returns LB0 through LB15.
- Eight buttons from LB0: last button at 0 + 8 − 1 = 7, so LB0 through LB7; a range written "LB0 to LB8" is 8 − 0 + 1 = 9 bits.
- Edge-pulse enables per second: 1000 ms ÷ 100 ms = 10 starts, each cut short on the scan after it began.
Result: with the edge contact, every transaction is abandoned before it can complete, so no response is ever collected, whatever the address. With the address also at 40000, the two faults stack and the read returns nothing twice over.
Decision: replace the edge contact with a maintained StartCom set by the 100 ms timer and cleared by Done or by an error completion, and enter address 1. Each poll then runs to completion and the next starts from a clean state. The pass threshold is the both-states test on LB0. If you pace the cycle with a 5 s timer instead of 100 ms, the entire cascade must finish inside 5 s; if it does not, lengthen the timer rather than overlapping transactions.
Expanding from one panel to a multidrop network #
The single-panel baseline comes first; add panels one at a time and repeat the both-states test on each:
- Give every panel its own slave node address and add its polls to the sequence — the port services one transaction at a time.
- Keep all requests through the same port serialized, by cascade order or by the start-variable method.
- Terminate only the two physical ends of the segment, with the value the cable and device documentation calls for.
The bus rules are the same ones that govern sharing one RS-485 PLC port between multiple HMIs, only with the master role on the PLC side. When a node stops answering after others are added, suspect a duplicate address or an overlapped transaction before the cable.
Questions asked
The comms LED on the panel flashes at the poll rate. Does that prove the read works?
No. A flashing LED proves frames are crossing the bus at your cadence, not that a transaction completes or that the returned bits are fresh. The only pass test is a completed read in which the received bit follows the panel toggle through both its off and on states. If the LED flashes and the value never moves, the fault is the address or the enable, not the wiring.
Isn't Modbus addressing zero-based? Why does LB0 need address 1?
Both statements are true at different layers. The function block's address field is one-based at the application level, so LB0 is entered as 1 and LB15 as 16. The address encoded on the wire is zero-based, so the same bit shows up as coil 0 in another master library or a bus monitor. Enter 1 in this block, and enter 0 only in a tool that documents zero-based input.
How do I poll at a fixed interval instead of free-running?
Use a timer to set a start variable, StartCom in this setup, that enables the block or the whole cascade, and let Done of the last block reset it. The constraint is that the entire communication cycle must finish inside the timer period: with a 5 s timer, the read of 16 coils, the write of 16 coils, the read of 8 registers and the write of 8 registers must all complete within 5 s.
Are 100 ohm terminators right for my bench cable?
At 50 cm the cable is electrically short, so the bench works regardless of the exact termination value. That tolerates the resistors but does not validate them. Before the bus is permanent, size the terminator from the cable and device documentation, fit it at the two physical ends of the segment only, and check whether the port or the panels already have built-in termination before adding external resistors.
Can I leave DTRManagement at 0 and just poll faster or rewire the bus?
No. On a two-wire RS-485 port the DTR signal is the direction switch: the driver asserts transmit for the request and releases it to receive the response. At 0, DTR_OFF, the direction never switches and the exchange cannot complete. Set it to 2, DTR_AUTO_WO_TIMES, and let the serial driver time the turnaround itself. No polling interval compensates for a port that cannot turn around.