Modbus RTU FC16 (0x10) Write Multiple Registers Frame Builder

Construct multi-register Modbus RTU Function 0x10 (FC16) hex frames with automatic byte-count header, big-endian 16-bit packing and CRC-16.

Jump to results

Inputs

Frame mode & addressing
1–247 unicast, 0 broadcast.
Zero-based protocol PDU address (0–65535).
Comma-separated decimal or 0x hex 16-bit words (FC16 only).
Raw validation & RS-485 bus

Results

Estimates
Modbus RTU Frame (Hex)02 10 01 00 00 02 04 01 F4 03 E8 B1 CB
Computed CRC-16
0xCBB1
Wire CRC order (Lo Hi)
B1 CB
Slave ID & Function
ID 2 · Write Multiple Registers (0x10)
Frame length / air time
13 bytes · 7.45 ms
Inter-char timeout (t1.5)
859 µs
Frame silent gap (t3.5)
2,005 µs
RTU frame byte map · 13 bytes
B0 02 B1 10 B2 01 B3 00 B4 00 B5 02 B6 04 B7 01 B8 F4 B9 03 B10 E8 B11 B1 B12 CB CRC-16/MODBUS: 0xCBB1 · Wire order: B1 CB (Lo → Hi)
  • Slave ID
  • Function Code
  • Address / Payload
  • CRC-16 Lo / Hi
Frame field breakdown
FieldBytes (Hex)Byte count
Slave ID021
Func 0x10101
Start Reg01 002
Qty (2)00 022
Bytes (4)04 01 F4 03 E85
CRC LoB11
CRC HiCB1
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: 02 10 01 00 00 02 04 01 F4 03 E8 B1 CB (CRC=0xCBB1, wire: 0xB1 0xCB) */
static const uint8_t frame_pdu[11] = { 0x02, 0x10, 0x01, 0x00, 0x00, 0x02, 0x04, 0x01, 0xF4, 0x03, 0xE8 };
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("02 10 01 00 00 02 04 01 F4 03 E8")
crc = modbus_crc16(pdu)
rtu_frame = pdu + crc.to_bytes(2, "little")
assert rtu_frame.hex(" ").upper() == "02 10 01 00 00 02 04 01 F4 03 E8 B1 CB"
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.

Pack atomic multi-register writes using Modbus FC16 (0x10)

Function Code 0x10 (decimal 16) writes a contiguous block of 16-bit registers atomically—essential when updating 32-bit floats, 32-bit counters or paired voltage/current limits that must not be half-written.

FC16 inserts an explicit Byte Count byte (`2 × register count`) immediately before the big-endian data payload. Enter comma-separated decimal or `0x` hex words and copy the complete CRC-protected frame.

Formulas

  • FC16 PDU = [ID, 0x10, Addr_Hi, Addr_Lo, Qty_Hi, Qty_Lo, ByteCount, Data...]
  • ByteCount = 2 × Number of 16-bit registers
  • Total frame length = 9 + (2 × Qty) bytes

Worked example

Writing 0x01F4 (500) and 0x03E8 (1000) to Slave 2 at 0x0100 sets ByteCount = 0x04 and produces the 13-byte frame with exact CRC-16 Lo/Hi bytes.

Frequently asked questions

Why do 32-bit registers require FC16 instead of two FC06 writes?

FC16 commits both 16-bit halves in a single transaction so the slave never acts on a torn combination of old upper bits and new lower bits.

What does a slave return after a valid FC16 write?

The slave returns an 8-byte confirmation containing [ID, 0x10, Addr_Hi, Addr_Lo, Qty_Hi, Qty_Lo, CRC_Lo, CRC_Hi] without echoing the data payload.

Why is FC16 sometimes written as 0x10?

Decimal 16 equals hexadecimal 0x10. Do not confuse decimal function 10 (unused) with hex 0x10 (FC16).