Modbus RTU Frame Builder & CRC-16 (0xA001) Validator

Build or validate Modbus RTU hex frames with exact CRC-16/MODBUS (polynomial 0xA001, Lo/Hi wire order), byte-map SVG, RS-485 timing and C99/Python code.

Jump to results

Inputs

Frame mode & addressing
1–247 unicast, 0 broadcast.
Zero-based protocol PDU address (0–65535).
Count for reads, 0 or 1 for FC05, or a 16-bit value for FC06.
Raw validation & RS-485 bus

Results

Estimates
Modbus RTU Frame (Hex)01 03 00 00 00 0A C5 CD
Computed CRC-16
0xCDC5
Wire CRC order (Lo Hi)
C5 CD
Slave ID & Function
ID 1 · Read Holding Registers (0x03)
Frame length / air time
8 bytes · 9.17 ms
Inter-char timeout (t1.5)
1,719 µs
Frame silent gap (t3.5)
4,010 µs
RTU frame byte map · 8 bytes
B0 01 B1 03 B2 00 B3 00 B4 00 B5 0A B6 C5 B7 CD CRC-16/MODBUS: 0xCDC5 · Wire order: C5 CD (Lo → Hi)
  • Slave ID
  • Function Code
  • Address / Payload
  • CRC-16 Lo / Hi
Frame field breakdown
FieldBytes (Hex)Byte count
Slave ID011
Func 0x03031
Address00 002
Quantity00 0A2
CRC LoC51
CRC HiCD1
Copyable C99 & Python 3 CRC-16/MODBUS functions
#include <stddef.h>
#include <stdint.h>

/* CRC-16/MODBUS: init 0xFFFF, reflected polynomial 0xA001, wire order Lo then Hi */
uint16_t modbus_crc16(const uint8_t *buf, size_t len) {
  uint16_t crc = 0xFFFFU;
  for (size_t i = 0; i < len; ++i) {
    crc ^= (uint16_t)buf[i];
    for (int bit = 0; bit < 8; ++bit) {
      if (crc & 0x0001U) crc = (uint16_t)((crc >> 1) ^ 0xA001U);
      else crc >>= 1;
    }
  }
  return crc;
}

/* Test vector: 01 03 00 00 00 0A C5 CD (CRC=0xCDC5, wire: 0xC5 0xCD) */
static const uint8_t frame_pdu[6] = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x0A };
def modbus_crc16(data: bytes) -> int:
    crc = 0xFFFF
    for b in data:
        crc ^= b
        for _ in range(8):
            crc = ((crc >> 1) ^ 0xA001) if (crc & 1) else (crc >> 1)
    return crc & 0xFFFF

pdu = bytes.fromhex("01 03 00 00 00 0A")
crc = modbus_crc16(pdu)
rtu_frame = pdu + crc.to_bytes(2, "little")
assert rtu_frame.hex(" ").upper() == "01 03 00 00 00 0A C5 CD"
print(rtu_frame.hex(" ").upper())

Modbus RTU transmits the CRC low byte first, followed by the high byte, whereas multi-byte register addresses and values are big-endian.

Assemble and verify CRC-16/MODBUS RTU frames over RS-485

Modbus RTU packs binary frames tightly on half-duplex RS-485 links with no start/stop delimiter characters. Instead, devices detect frame boundaries using silent idle intervals of at least 3.5 character times (t3.5) and verify integrity with a 16-bit cyclic redundancy check.

A frequent firmware bug is byte-swapping the CRC: while Modbus register addresses and 16-bit register data travel big-endian (high byte first), the trailing CRC-16/MODBUS checksum is always transmitted little-endian (low byte first, high byte second) using reflected polynomial 0xA001.

Formulas

  • CRC-16/MODBUS: init = 0xFFFF, reflected poly = 0xA001, LSB-first shift
  • Wire order: [SlaveID, FuncCode, ...Data..., CRC & 0xFF, CRC >> 8]
  • Character time = 11 bits ÷ baud rate; t3.5 = 3.5 × T_char (or 1,750 µs above 19,200 bps)

Worked example

Reading 10 holding registers starting at address 0x0000 from Slave ID 1 produces PDU bytes 01 03 00 00 00 0A. Its CRC-16 is 0xCDC5, transmitted on the wire as C5 CD to form 01 03 00 00 00 0A C5 CD.

Frequently asked questions

Why is Modbus CRC-16 sent low byte first?

The original Modicon RTU specification defines data words as big-endian but appends the 16-bit CRC register LSB-first so serial hardware shift registers can check the remainder directly to zero.

What is the difference between PDU address 0 and register 40001?

40001 is a human-readable convention meaning Holding Register (FC03) at zero-based PDU offset 0x0000. Always enter the zero-based protocol address in the RTU frame.

Why do t1.5 and t3.5 clamp at 750 µs and 1,750 µs above 19,200 baud?

The Modbus Serial Line specification fixes t1.5 = 750 µs and t3.5 = 1,750 µs for baud rates above 19,200 bps so microcontroller timer interrupts remain practical without false frame splits.