Modbus RTU: frame format, timing, CRC and RS-485 wiring
Part of the Modbus guide
Modbus RTU is the binary serial form of Modbus. Each frame is a one-byte device address, a function code, the data, and a two-byte CRC-16, sent as a continuous stream of characters and separated from the next frame by at least 3.5 character times of silence. It runs almost always on RS-485, with one client polling up to 247 addressable devices on a shared pair of wires.
This page belongs to the Modbus guide. The data model and register addressing are in What is the Modbus protocol?; the Ethernet variant is in Modbus TCP.
Modbus RTU frame format
| Field | Size | Notes |
|---|---|---|
| Address | 1 byte | 1 to 247 for a single device, 0 for broadcast, 248 to 255 reserved |
| Function code | 1 byte | Same codes as every other Modbus variant |
| Data | 0 to 252 bytes | Depends on the function code |
| CRC | 2 bytes | CRC-16 over address, function code and data, low byte first |
The largest RTU frame is 256 bytes: 253 bytes of PDU (function code plus data), one address byte and two CRC bytes. There is no start or end marker. The receiver knows a frame is over when the line goes quiet.
A server replies with its own address in the first byte, so the client can confirm who answered. A request to address 0 is a broadcast: every server acts on it and none replies, which limits broadcasts to write functions.
A decoded request and response
The client asks device 17 for three holding registers starting at register 108 (written 40108 in many manuals, address 0x006B on the wire).
Request: 11 03 00 6B 00 03 76 87
11 device address 17
03 function code: read holding registers
00 6B starting address 107 (register 108)
00 03 quantity: 3 registers
76 87 CRC-16 (0x8776, low byte sent first)Response: 11 03 06 02 2B 00 00 00 64 C8 BA
11 device address 17
03 function code, echoed
06 byte count: 6 data bytes follow
02 2B register 108 = 0x022B = 555
00 00 register 109 = 0
00 64 register 110 = 0x0064 = 100
C8 BA CRC-16 (0xBAC8, low byte sent first)If register 108 did not exist, the device would answer with the function code plus 0x80 and an exception code instead:
Exception: 11 83 02 C1 34
83 0x03 + 0x80: the read failed
02 exception code 02, illegal data addressThe function code reference has the layouts for the other codes and the full exception list.
How is the Modbus RTU CRC calculated?
The CRC is 16 bits wide, starts at 0xFFFF, and uses the reflected polynomial 0xA001. Each byte of the frame is XORed into the low byte of the CRC, then the CRC is shifted right eight times; whenever the bit shifted out is 1, the CRC is XORed with 0xA001.
def modbus_crc(frame: bytes) -> bytes:
crc = 0xFFFF
for byte in frame:
crc ^= byte
for _ in range(8):
if crc & 1:
crc = (crc >> 1) ^ 0xA001
else:
crc >>= 1
return bytes([crc & 0xFF, crc >> 8]) # low byte first
modbus_crc(bytes.fromhex("1103006B0003")).hex() # '7687'The byte order is the one place Modbus breaks its own big-endian rule: register addresses and values go high byte first, the CRC goes low byte first. A receiver that computes a different CRC discards the frame silently. The server sends nothing, and the client sees a timeout, never an error message. Persistent timeouts on a device that is powered and addressed correctly usually mean corrupted frames.
Character format and frame timing
Each byte travels as an 11-bit character: one start bit, eight data bits sent least significant bit first, one parity bit and one stop bit. The serial line specification makes even parity the default. A device set to no parity must send two stop bits so the character stays 11 bits long, although plenty of equipment offers 8N1 anyway. The specification requires support for 9600 and 19200 baud, with 19200 as the default.
All of these must match on every device on the line: baud rate, parity and stop bits. One mismatched device does not just fail to answer; if it transmits at all, it corrupts traffic for the others.
Framing depends on silence:
| Rule | Requirement | At 9600 baud | At 19200 baud | Above 19200 baud |
|---|---|---|---|---|
| Gap between frames | At least 3.5 character times | 4.0 ms | 2.0 ms | 1.75 ms fixed |
| Gap between characters in a frame | At most 1.5 character times | 1.7 ms | 0.86 ms | 0.75 ms fixed |
A pause longer than 1.5 character times inside a frame makes the receiver treat the frame as incomplete and drop it. This matters when Modbus RTU passes through anything that buffers bytes: USB serial adapters with long latency timers, radio modems, and serial device servers that packetize on a timer. Each can open a gap in the middle of a frame or glue two frames together.
RS-485 wiring: termination, biasing and polarity
Modbus RTU over RS-485 is a bus. The cable runs from device to device in a single line, not a star, and the specification limits each tap to a short stub. The rules that matter:
- Terminate both ends, and only the ends. A resistor across the data pair at each end of the trunk absorbs reflections. The specification gives 150 ohms, or 120 ohms in series with a 1 nF capacitor when the line is biased. A terminator in the middle of the run, or a third one, loads the bus and shrinks the signal.
- Bias the line in one place. When no device is transmitting, an undriven pair floats, and receivers can read noise as a start bit. A pull-up on one conductor and a pull-down on the other (450 to 650 ohms each in the specification) hold the idle line in a defined state. This is done once for the whole bus, normally at the client.
- Connect the common. RS-485 is differential, but the transceivers still need a shared reference. The specification’s two-wire bus has three conductors: the pair and a common.
- Check polarity by signal, not by label. The specification names the conductors D0 and D1 and maps them to A and B, but manufacturers label terminals A/B, +/-, or D+/D- without agreeing on which is which. A device wired backwards never answers. Swapping the two wires on that device is a safe test.
- Count the loads. The specification allows 32 devices on a segment without a repeater; the 247 limit is an addressing limit, not an electrical one.
Give every device a unique address before it joins the bus. Two devices with the same address answer at the same time and both replies are destroyed, which looks like an intermittent CRC fault on one address.
Why polls are slow, and how to set the timeout
A serial bus carries one transaction at a time, and each one costs real time. At 9600 baud a character takes about 1.15 ms. Reading 10 holding registers is an 8-byte request and a 25-byte response:
Request 8 bytes x 1.15 ms 9.2 ms
Response 25 bytes x 1.15 ms 28.6 ms
Silence 2 x 3.5 characters 8.0 ms
Total on the wire 45.8 ms, plus the device's processing timeTwenty devices polled for a few blocks each add up to seconds per scan. To shorten it, raise the baud rate if the cable length allows, read contiguous registers in one request instead of many small ones, and poll slow-changing values less often.
A timeout that is too short makes a healthy device look dead; one that is too long stalls the whole scan every time a device is offline, because the client waits out the full timeout before moving to the next address. Set it from the slowest device’s documented response time plus the transmission time above, and take devices that are powered down out of the poll list.
Reading Modbus RTU with ControlCom
The ControlCom Edge Server, the on-site component of ControlCom Connect, has a Modbus RTU client. Its Connection tab takes the serial Device Path with Baudrate, Data Bits, Stop Bits and Parity, an Interval (the polling period, 1000 ms by default) and a Timeout (15 seconds by default). Round size caps how many consecutive registers go into one request. Each device on the bus is added as a unit with its Unit ID. Because the Edge Server runs in a container, the serial device has to be mounted into it as a volume. The Modbus client documentation lists the fields.
The values land in platform variables, described in the platform overview. Pump station and treatment plant PLCs are a common case; the water pumping stations page covers that setup.
The Edge Server polls the devices on an RS-485 run and publishes each register as a variable in ControlCom Connect, so the meter or drive at the end of the cable shows up in trends and alarms.