The short answer
Modbus RTU
Modbus RTU is a serial master/slave protocol, normally carried on RS-485, in which a single master polls addressed slave devices for register data. Messages are binary with a CRC-16 check and are delimited by a silent interval of at least 3.5 character times. Its simplicity is why it is everywhere, and its lack of built-in diagnostics is why intermittent problems take patience to find.
Key points
- One master, up to 247 addressed slaves, one transaction at a time.
- Register documentation ambiguity is the most common integration problem: 40001 versus offset 0.
- Termination at both physical ends, and bias somewhere, are required for a stable bus.
- Every device on the segment must match baud rate, data bits, parity, and stop bits.
- There is no built-in security. Anything reachable can be read and written.
How a transaction works
The master sends a request containing a slave address, a function code, a starting register, a quantity, and a CRC. The addressed slave, and only that slave, responds with the same address, the same function code, the data, and its own CRC. Every other device on the bus stays silent. Nothing happens without the master initiating it.
That single-conversation model is why a device that answers slowly slows the whole bus, and why one device that transmits when it should not can make an entire segment appear broken.
Function codes you will actually use
| Code | Name | Operates on |
|---|---|---|
| 01 | Read Coils | Discrete outputs, read/write bits |
| 02 | Read Discrete Inputs | Discrete inputs, read-only bits |
| 03 | Read Holding Registers | 16-bit read/write registers — by far the most used |
| 04 | Read Input Registers | 16-bit read-only registers |
| 05 | Write Single Coil | One output bit |
| 06 | Write Single Register | One 16-bit register |
| 15 | Write Multiple Coils | A block of output bits |
| 16 | Write Multiple Registers | A block of 16-bit registers |
The addressing problem
This causes more wasted hours than every other Modbus issue combined. Two conventions describe the same register and documentation rarely says which is in use.
- Traditional data model addressing
- Holding registers are numbered from 40001. A device manual saying "flow rate is at 40010" is using this convention.
- Protocol addressing
- The number actually placed on the wire, starting at 0. Register 40010 in the traditional model is protocol address 9.
Traditional 40001 -> protocol address 0
Traditional 40010 -> protocol address 9
Traditional 4xxxx -> protocol address (xxxx - 1)
Off by exactly one register -> you configured 40010 as address 10
Reading 40001 as address 40001 -> illegal data address exception
If a value is close but consistently belongs to the neighboring
point in the device map, you are off by one.Data types and byte order
Modbus defines 16-bit registers and nothing larger. A 32-bit float or a 32-bit integer is carried in two consecutive registers, and the standard does not specify the order in which those registers appear. Vendors differ, and some devices are configurable.
| Arrangement | Also called | Symptom if wrong |
|---|---|---|
| Big-endian, high word first | ABCD | Correct on many devices |
| Little-endian, low word first | CDAB | Value is wildly wrong or reads as a tiny number |
| Byte-swapped | BADC | Value looks like noise |
| Full reverse | DCBA | Value looks like noise |
A practical test: read a value you know, such as a flow rate the device displays locally. If it reads as a huge number, a near-zero number, or nonsense, try swapping the word order first. The correct combination becomes obvious immediately.
The physical layer
RS-485 is a differential pair, and most intermittent Modbus problems are physical rather than protocol.
- Daisy chain the devices. RS-485 is a bus, not a star. Long stubs off a trunk cause reflections.
- Terminate both physical ends, typically 120 ohms. Terminate only the ends, not every device.
- Bias the idle line somewhere on the segment, usually at the master. Without bias, an idle line floats and receivers see noise as data.
- Use twisted shielded pair rated for RS-485, and ground the shield at one end.
- Connect the signal common. Many installations skip this and work until the ground potential difference grows.
- Verify polarity. A and B reversed at one device produces silence from that device only.
- Keep it away from drive output conductors. This is the leading cause of a bus that works until a pump starts.
Exception responses
| Code | Meaning | Usually means |
|---|---|---|
| 01 | Illegal function | The device does not support that function code |
| 02 | Illegal data address | Wrong register, or a block that runs past the end of the map |
| 03 | Illegal data value | A value outside what the register accepts |
| 04 | Slave device failure | An internal error in the device |
| 06 | Slave device busy | Device is processing; retry |
An exception is good news compared with silence. It proves the device heard you, the wiring is correct, the address is right, and the framing is valid. Only the content of the request is wrong, which is a much smaller problem than a bus that does not answer at all.
Timing and polling
Frames are delimited by silence: a gap of at least 3.5 character times marks the end of a message, and a gap of more than 1.5 character times inside a message invalidates it. This is why a gateway or a USB serial converter that introduces latency can break RTU framing even though the bytes all arrive.
- Poll no faster than the device can answer. Many field devices need tens of milliseconds per response.
- Read contiguous blocks rather than individual registers. One read of twenty registers is far cheaper than twenty reads.
- Set the response timeout longer than the slowest device, then set retries deliberately rather than leaving a default.
- Count and trend communication errors per device. A device at a 2% error rate today is a failure next month.
Frequently asked questions
- What is the difference between Modbus RTU and Modbus ASCII?
- RTU sends binary data with a CRC-16 and relies on silent intervals for framing. ASCII sends hexadecimal characters with a start and end delimiter and an LRC check. ASCII is more tolerant of latency but roughly half as efficient. RTU is far more common.
- How many devices can be on one RS-485 segment?
- The protocol addresses up to 247 slaves. The electrical limit is typically 32 standard unit loads on a segment, though many modern transceivers present a fraction of a unit load and allow more. Practically, keep segments small; a bus with forty devices is slow and hard to diagnose.
- Why does my device respond intermittently?
- In order of likelihood: missing or incorrect termination, missing bias, no signal common, cable routed near drive output conductors, a timeout shorter than the device response time, and polling faster than the device can answer.
- Can I have two masters on a Modbus RTU bus?
- Not on the same segment. Modbus RTU is single-master by design. Two masters will transmit over each other. If two systems need the data, use a gateway or a data concentrator that presents itself as a slave to both.
Related topics
- Modbus TCPModbus over Ethernet: what the MBAP header changes, why the CRC disappears, how the unit identifier works, and what does not get easier just because it is on Ethernet.
- Serial CommunicationsRS-232, RS-422, and RS-485 in practice: which is which, cable and distance, termination, biasing, the common reference wire everyone leaves off, and the settings that have to match at both ends.
- Modbus Device Intermittently OfflineA device that answers most of the time. Termination, bias, timing, and the physical layer details that produce a bus which almost works.
- How to Configure a Modbus ConnectionSet up a Modbus RTU or TCP link between a controller and a device: get the register map, match the physical and protocol settings, build the reads and writes, handle data types and the addressing offset, and verify with a protocol tool before trusting a value.
- EtherNet/IPHow EtherNet/IP moves control data: CIP over standard Ethernet, implicit I/O connections on a requested packet interval, explicit messaging, producer and consumer tags, and what the network has to provide.
- DNP3The protocol built for utility telemetry: master and outstation, static and event data classes, unsolicited reporting, time-stamped events, and why it suits slow links that Modbus does not.
Direct contact
Have a controls question?
Reach Eric Sullivan directly about anything on this site, a controls or automation topic, or one of his personal projects.