Troubleshooting
Why arrReadData stays at 16#0000 during Modbus RTU polling
Short answer
arrReadData fills from element 0 up to iDataCount minus 1, so a 13-register poll never writes elements 41 and 125 even when it succeeds - the data was there all along. Watch elements 0 upward while xDone is TRUE, and work the wire, master, start-address and count checks only when xError appears or the values look wrong.

On this page
- Why does arrReadData stay at 16#0000 while the poll runs?
- Do I need both the master block and the function-code block?
- What do I check on the RS485 wire before touching the logic?
- How do I read the diagnostics the function blocks already produce?
- Why does my function-code block never go active?
- Does the start address want 40127 or 126?
- What value belongs in iDataCount?
- What is the fastest order to work through the checks?
- Questions asked
If xDone sits TRUE while arrReadData stays at 16#0000 in the Watch window, the poll has almost certainly succeeded and the watch list is pointed at elements the block never writes. The Modbus RTU function blocks fill arrReadData from element 0 up to iDataCount minus 1, so anything above that index keeps its initialization value no matter how healthy the bus is. The checks below run in data-path order - wire, master block, function-code block, start address, register count, watch list - so each step eliminates one hop between the CPU and the slave.
Why does arrReadData stay at 16#0000 while the poll runs? #
Your registers were read the whole time: arrReadData fills from element 0 up to iDataCount minus 1, so with iDataCount at 13 a watch list showing elements 41 and 125 displays two untouched elements that stay at 16#0000 while xDone sits TRUE.
In the reported case, a single slave with ID 10 answered cleanly - it had already been read through a USB-to-RS485 converter - yet the Watch window showed nothing but zeros through every poll cycle. A request with a count of 13 writes elements 0 through 12 and never touches element 41 or element 125, so those two watched elements sat at their reset values while the block reported a valid reply. Moving the watch onto elements 0, 1, 2 and upward fixed the display on the spot; nothing on the wire changed.
Read the symptoms as a set:
- Every watched element at 16#0000 with
xDoneTRUE - the watched indexes lie beyond the count; watch elements 0 upward. - Elements 0 upward update, but the values contradict what the converter showed - the start address points at the wrong registers; re-check the address convention.
arrOutputDatachurning in the Watch window - that array carries the CPU-to-module process data, not the slave's reply; it proves the module link is alive and says nothing about register values, so take it off the watch list.
Decision: xDone TRUE means the conversation on the bus finished successfully; fix the watch list before touching anything else.
Do I need both the master block and the function-code block? #
Yes: one MB_AXL_SE_RS485_Master_32 instance owns the RS485 port on the SE module, and every MB_RTU_FC3_71 or MB_RTU_FC4_7 instance builds one request type and hands it to that master, so both blocks belong in the program.
The master instance opens and holds the channel: xActivate TRUE with xActive TRUE means the CPU-to-module link is up, while xError TRUE with a value in udtDiag means it refused its configuration or lost the module. Each function-code instance builds exactly one request type - MB_RTU_FC3_71 reads holding registers, MB_RTU_FC4_7 reads input registers - and submits it through the master instance it is wired to. Count instances as one master per SE module plus one function-code instance per function code the program executes.
The sequence on each function-code instance is fixed: set xActivate, then set xSendRequest, then read the pair xDone and xError. Without xActivate the block ignores xSendRequest entirely.
Decision: keep the two roles separate - a master instance cannot build requests and a function-code instance cannot own the port.
What do I check on the RS485 wire before touching the logic? #
Check the wire first, because a request the slave never receives and one it cannot decode both surface as xError with a timeout code, never as a full array under xDone: termination at both physical ends, A and B not swapped, identical serial settings, one unique address per slave.
On the common twisted pair of 24 AWG wires, fit 100 to 120 ohm termination at both ends of the segment; where the SE module sits at one end, use the module's documented termination setting instead of an added resistor, and put a resistor at the far slave end as well. The reported case wired A to input 1 and B to input 3 - but A and B labelling is not consistent between vendors. Converter-side success with module-side silence is the swap signature: if the slave answered through a USB-to-RS485 converter and stays silent on the module, swap the two conductors at the module terminals and retest. The same swap silences slaves on other RS485 ports, as described in Why CM1241 RS485 A/B polarity stops Modbus RTU slave replies.
Keep baud rate, parity, data bits and stop bits identical on the module and on every slave; a slave silently discards frames with framing or parity errors and never answers. Give each slave a unique address and match the function-code instance's address input to it.
Isolate the segment before moving conductors: RS485 terminals can share a cabinet rail with 230 V wiring.
Decision: a wiring fault appears as xError with a timeout code; if xDone is TRUE, the wire is not the fault.
How do I read the diagnostics the function blocks already produce? #
The blocks already tell you where the fault sits, but only if you bind variables to every output whose name contains Diag, bring the controller online, and add those variables to the Watch window, because an unbound diagnostic output hides the one value that names the cause.
Do it in three steps:
- Bind a variable to every FB output with Diag in the name -
udtDiagon the master instance,DiagCodeon the function-code instances. - Bring the controller online and add every one of those variables to the Watch window.
- Decode each value against the Modbus RTU FB library documentation - the codes are library-specific.
Then read the pattern. xError with a timeout code points back to the wire. xError with an exception code means the slave rejected the request: suspect the start address and the count. xDone TRUE with an apparently empty array points to the watch list and the address. In the reported case the diagnostics existed all along; the second thing missing was simply a bound variable.
Decision: put the diagnostics on the watch list before changing any parameter - one decoded code beats a round of setting changes.
Why does my function-code block never go active? #
Run the master check first, because a function-code block sits behind the master and cannot go active while xActive on the master is FALSE, whatever its own inputs say; if the master is active, the block is probably not wired to that master instance.
Set xActivate on the master instance and read the outputs: xActive TRUE means the master owns the port and you can move to the function-code block; xError TRUE means the master rejected its configuration or lost the module, and udtDiag names the reason; neither output TRUE means xActivate is not actually reaching the block, so monitor the input online and fix the binding - an unbound variable or a condition that never evaluates true produces exactly this silence.
With the master healthy, a function-code block that still refuses xActive is usually tied to a different master instance, or its own xActivate never arrives. One trap is documented for controllers with several execution levels: Siemens states for the S7-1200's MB_MASTER that Modbus master instructions must not run in the startup, diagnostic or time-error priority levels - a master called from the wrong task looks identical to a dead one.
Start address belongs to the request payload: the block evaluates it when xSendRequest fires, so changing it cannot wake a sleeping block. In the reported FC4 case a changed start address changed nothing - itself the diagnosis, because the fault sat upstream in this section.
| Observation on the function-code block | Where the fault sits |
|---|---|
xActive FALSE after xActivate TRUE |
Master not active, block tied to a different master instance, or xActivate not reaching the block |
xActive TRUE, no xDone and no xError after xSendRequest |
xSendRequest not a clean edge or level as the library documents; match the transition type |
xError TRUE with a timeout code |
Wiring, serial settings or slave address |
xDone TRUE with an apparently empty array |
Watch list beyond the count, or the wrong start address |
Decision: an inactive function-code block is an activation problem, never an address problem - repair the chain from xActivate to master xActive to block xActive before touching any request parameter.
Does the start address want 40127 or 126? #
Slave documents usually print holding registers as 4xxxx and input registers as 3xxxx, while the Modbus frame carries a zero-based offset, so the form the start-address input expects is whichever the FB library documents - prove it once with a register whose value you already know.
Worked check: holding reference 40127 corresponds to offset 126, because 40127 - 40001 = 126. The wrong form fails quietly: the slave returns the neighbouring register or answers with an exception code. Settle the convention with one known value - read a register whose current value you can see on the device display or through the USB converter, and compare.
The same reference-versus-offset confusion produces a named error on a different master, as in Why MB_MASTER on an S7-1200 reports Modbus error 16#8188.
Decision: enter the form the library documents, prove it once against a known register, and record the convention on the register map so nobody re-derives it per request.
What value belongs in iDataCount? #
iDataCount is the number of registers one request reads, and the inclusive count is last minus first plus 1, so registers 126 through 139 need iDataCount at 14: 139 - 126 = 13, and the closed span adds one more.
A short count returns the span without its final register: that final element exists, is never written, and looks exactly like the untouched-element problem of the first section. In the reported case the entered count was one short of the requested span, so either the device map ended one register earlier than described or the last register was silently missing - compare the final element against the converter reading, and the map wins. If the sheet really means a shorter span beginning with the same first register, the short count is correct and nothing is missing.
Decision: enter last minus first plus 1, then watch the final element while the poll runs - a frozen final element means the count or the start address is off by one.
What is the fastest order to work through the checks? #
Work the checks in data-path order and stop at the first one that fails: master active, function-code block active, request accepted and answered, values sane, then the right array elements watched - in the reported case every earlier hop passed and only the watch list was wrong.
- Watch elements 0 through one below the count, online, with the poll running and
xDoneTRUE. Values moving? The link was never at fault - the case that prompted this article ended here. xErrorTRUE with a timeout code? Work the wire: 100 to 120 ohm termination at both ends, A and B not swapped, identical serial settings, one address per slave.- Master
xActiveFALSE? Fix the activation and, on multi-task controllers, the execution level;udtDiagsays why the master refused. - Function-code block
xActiveFALSE with the master healthy? Check that it is tied to that master instance and that its ownxActivatetruly arrives. xDoneTRUE but values missing or implausible? Fix the watch list first - elements 0 upward,arrOutputDataoff the list - then the start-address convention, then the count.
Decision: diagnose in data-path order and trust the outputs - xDone TRUE ends the network discussion, and the fault then lives in the watch list, the start address or the count.
Questions asked
How do I tell a genuine zero in a register from an element the block never wrote?
Write a known non-zero value into one slave register with the device's own configuration tool, poll it, and watch the element it should land in. If that value arrives, the read path is proven and any remaining zeros are real register values or indexes beyond the count. If it never arrives, the fault is upstream of the watch list, and the wire, master and address checks apply.
How large should the result array be declared?
Size it for the largest register count any of your function-code instances uses, because the block writes its reply sequentially from element 0 and has nowhere else to put it. Elements above the largest count hold their initialization value for the whole run, so leaving them off the Watch window keeps the display honest and stops a frozen element from masquerading as a fault.
The registers arrive but the values look wrong - what usually causes that?
Modbus carries 16 bits per register, so a 32-bit value spans two consecutive registers and its word order depends on the slave device. When values arrive but make no sense, compare a few registers element by element against the converter or device reading, then correct the word order, byte order or scaling in the PLC program - the link itself is already proven by xDone.
Can I keep the Watch window open on the result array while polling continues?
Yes. With the controller online and the poll running, elements from 0 up to one below the count update on every accepted reply, while elements above that stay frozen at their initialization value. Editing the watch display does not touch the running poll; xActivate and the request sequence continue undisturbed, so you can rearrange the watch list until the registers you care about are visible.


