IMDHMIControls LibraryShop main store

Troubleshooting

How to poll many Modbus RTU slaves from one serial master

Industrial networks Published 6 min read

Short answer

Poll each slave with its own MRX read or MWX write sequence, one active transaction on the port at a time, and pick the function code from the slave's data access type. A timeout means the serial path; a Modbus exception means the slave answered and rejected the request. Twenty-two slaves at 9600 baud poll in about one second.

On this page
  1. Read the transaction result before touching anything
  2. Triage table: one master, many slaves
  3. Pick the function code from the slave's access type
  4. Build the request list per device
  5. Example: cycle time for 22 slaves at 9600 baud
  6. One safety note
  7. Where the bugs actually live
  8. Questions asked

Twenty-two RTU slaves on one RS485 port do not need a clever driver: they need a scheduler. Each slave gets its own request built from an MRX (Modbus Network Read) or MWX (Modbus Network Write) instruction, and only one transaction is ever active on the port at a time. The BRX Do-more manual states that as a Modbus RTU client you do not have to hand-sequence MRX and MWX instructions in simple cases, but with this many devices the sequence is exactly what you want to own: a staged ladder block that steps through the slave list, tracks a per-device result, and raises a device-specific fault on loss of communication.

The value to commit to first: a per-slave status table. When slave 14 stops answering, the alarm must say "slave 14 timeout", not "Modbus error". That table is the difference between a diagnosable system and a nuisance alarm.

Read the transaction result before touching anything #

Every MRX and MWX ends in one of three outcomes, and each one sends you down a different branch:

  • Completed successfully — the response frame arrived with a valid CRC. Data handling is the next question, not the wiring.
  • Modbus exception received — the slave answered and refused the request. The function code, starting address, quantity or access permission is wrong against that slave's map. The serial path is proven good by the reply itself.
  • Timeout — no valid response. The serial path, addressing, slave availability or master ownership is the suspect list, in that order.

Raising the timeout value is never the first fix. It hides a mismatch instead of finding it. If a read fails, poll one known-good slave with a single read while keeping every other device's fault bit latched: if that read also fails, stay on the serial-path branch; if it succeeds, the fault is in the request mapping or the scheduling, and no timeout value will repair a wrong function code.

The same split applies at the protocol level — a register-block read that crosses an unmapped gap returns exception 02, which is the address branch of this tree (see why Modbus exception 02 appears when a read crosses a register map gap).

Triage table: one master, many slaves #

Use the symptom to pick the branch before changing anything:

Observed condition Likely branch Next check
Every slave times out Shared port or bus Port assignment, baud/parity/stop bits at master and slaves, wiring, second master on the bus
One slave times out, others fine That device Its address, power, and settings locally; compare against the master's request
Slave returns an exception Request content Function, address, quantity and access permission against the register map
Read completes but values look wrong Data interpretation Compare one known device value with the raw registers; check word order
One request works, full sequence fails Scheduling Only one active transaction per port; next request gated on the previous result

On that last row: polling dozens of drives or devices through one port has the same cycle-time math as drive commissioning, covered in why Modbus RTU drive polling on one serial port is slow. If writes to a device must be interlocked with process conditions, apply the same per-register permission thinking as safe Modbus writes to PLC output registers from SCADA.

Pick the function code from the slave's access type #

Vendor maps often collapse Modbus terminology. The Micro Motion map used with these flow meters, for example, states that "coil" covers both Modbus coils (read-write) and Modbus discrete inputs (read-only), and "register" covers both holding registers (read-write) and input registers (read-only). Read the access description beside each address before choosing an instruction:

Slave map wording Actual Modbus object Read Write
Read-only coil Discrete input MRX, function 2 none
Read/write coil Coil MRX, function 1 MWX, function 5 (single) or 15 (multiple)
Read-only register Input register MRX, function 4 none
Read/write register Holding register MRX, function 3 MWX, function 6 (single) or 16 (multiple)

A read-only "coil" needs function 2, not function 1, and changing the destination memory will not fix a wrong function code. When a request returns an exception, this table is the first thing to compare against the map.

For writes, use one function 15 or 16 block for contiguous writable points instead of a series of single writes; split noncontiguous points, because writing the intervening addresses can alter unrelated settings on that slave.

Build the request list per device #

One row per transaction, and the scheduler walks the rows:

  1. Slave address, function code, starting address, quantity.
  2. PLC destination (MRX) or source (MWX) memory.
  3. Access permission and data type from the map, including word order for any two-register value.
  4. Per-device communication status bit and fault timestamp.
  5. Documented quantity limits from both the instruction and the slave — a block that crosses an unmapped address fails even when its first address is valid.

Note that the slave's displayed register number may differ from the protocol offset; check the map's address convention before applying one. A successful transaction proves transfer, not interpretation: a 32-bit value occupies two registers and the word order depends on the device, so verify a known value in Data View before trusting the block.

There is no "read all slaves" request. Each response belongs to the slave the scheduler selected, and the device's status bit comes from that transaction's own result.

Example: cycle time for 22 slaves at 9600 baud #

Inputs:

  • 22 slave devices (the thread's case), each polled with one read of 10 holding registers (function 3).
  • 9600 baud, 8-E-1 on the RS485 port, so one character is 11 bits: 9600 ÷ 11 ≈ 873 characters per second, about 1.15 ms per character.
  • RTU framing: a read of 10 registers is an 8-byte request and a 25-byte response (address, function, byte count, 20 data bytes, CRC), with a 3.5-character silent gap before and after each frame.

Arithmetic: 33 bytes on the wire × 1.15 ms ≈ 38 ms, plus two 3.5-character gaps ≈ 8 ms, plus a slave turnaround of roughly 5 to 10 ms — call it 50 to 55 ms per transaction. Twenty-two slaves × 52 ms ≈ 1.15 s for a full scan.

Result and decision: at 9600 baud this port delivers a complete poll of all 22 devices in roughly 1.1 to 1.2 s. If the process needs 500 ms resolution, drop the register count per request (halving to 5 registers takes about 10 ms off each transaction, still over a second total) or move to 19200 baud, where the same scan halves to roughly 0.6 s. If even that is too slow, the answer is a second physical serial port or splitting the devices across two networks — not a longer timeout and not parallel triggers on one port.

One safety note #

If any polled slave feeds an interlock or a safety-related stop, treat loss of communication as a defined state: the sequence must drive the dependent outputs to their documented safe state on timeout, and that behavior belongs in the safety function's validation, not just in the polling program.

Where the bugs actually live #

In order of how often they turn out to be the cause: duplicated slave addresses; a read-only point written with the wrong function; two requests active on the port at once; a block crossing an unmapped register; word order on the one floating-point value nobody verified. Build the per-device status table first, restore one known-good transaction, then expand — and the scheduler you wrote on day one becomes the diagnostic tool for every device you add later. For a deeper look at how these two instructions sequence their transactions, the guide on how MRX and MWX poll Modbus RTU devices efficiently covers the instruction-side behavior.

Questions asked

Can I read all my slaves with one broadcast request?

No. Modbus RTU broadcast (slave address 0) is write-only and returns no responses, so you get no data and no per-device status. Reading all slaves means a scheduler that issues one addressed request per slave in turn, with each response attributed to the slave the request selected. Per-device communication status comes from each transaction's own result, not from a shared flag.

Why does my read work for one slave but fail in the full sequence?

On RTU, only one transaction can be active on the port at a time. If every MRX in the program triggers together, later requests collide with responses still in flight, and the master sees timeouts. Gate the sequence so the next request starts only after the previous one finishes, and keep the timeout long enough to cover a full slave response plus the inter-frame gap.

What is the difference between a timeout and a Modbus exception?

A timeout means no valid response arrived: the wiring, baud, parity, slave address, slave power, termination or a second master is wrong, or the slave is offline. An exception means the slave received the request and answered no: the function code, starting address, quantity or access permission does not match its map. The fix lives in the request, not in the serial settings.

How do I write ten coils without ten separate MWX instructions?

Use one multiple-coil write, function 15, when the coils are contiguous and the slave documents support for it. Pack the ten bits into consecutive output words and write the starting address and quantity of 10. Noncontiguous coils stay as single writes, function 5, because writing the intervening addresses could change unrelated points on that slave.

Keep reading

  • How-to

    Connect an S7-200 to a Modbus RTU sensor and read its register

    Confirm the exact S7-200 CPU and Micro/WIN library first, then call MBUS_CTRL once on every scan to initialize the Modbus RTU master and MBUS_MSG to read the sensor's holding register with matching serial settings (example: 9600 baud, even parity). Decode the returned 16-bit word with the sensor's documented scale, and use a gateway if the library is unavailable.

    Industrial networks

  • Troubleshooting

    Speeding Up Modbus RTU Writes Behind Polled Reads

    The writes are slow because the Modbus client driver owns the serial port and services one enabled instruction at a time, so a write queues behind every enabled read. Put each transaction in its own stage, put the write stages first, and advance the chain on completion; a write then waits at most one in-flight transaction.

    Industrial networks

  • Troubleshooting

    Why Modbus RTU drive polling on one serial port is slow

    Modbus RTU carries one request-response transaction at a time, and at 19.2 kbit/s each drive transaction costs 40-60 ms, so 18 drives polled with a read and a write each need about 1.5-2.5 s per cycle no matter how the messages are chained. Cut the transaction count, schedule command writes ahead of status reads, set each drive's communication-loss timeout above the finished cycle, and change networks when the arithmetic cannot meet the update rate.

    Industrial networks