Modbus RTU FC06 Write Single Register Frame & CRC-16 Generator

Build Modbus RTU Function 0x06 Write Single Register hex commands for VFD speed setpoints and relay control with exact CRC-16 checksums.

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 06 20 00 13 88 8F 5C
Computed CRC-16
0x5C8F
Wire CRC order (Lo Hi)
8F 5C
Slave ID & Function
ID 1 · Write Single Register (0x06)
Frame length / air time
8 bytes · 4.58 ms
Inter-char timeout (t1.5)
859 µs
Frame silent gap (t3.5)
2,005 µs
RTU frame byte map · 8 bytes
B0 01 B1 06 B2 20 B3 00 B4 13 B5 88 B6 8F B7 5C CRC-16/MODBUS: 0x5C8F · Wire order: 8F 5C (Lo → Hi)
  • Slave ID
  • Function Code
  • Address / Payload
  • CRC-16 Lo / Hi
Frame field breakdown
FieldBytes (Hex)Byte count
Slave ID011
Func 0x06061
Address20 002
Value13 882
CRC Lo8F1
CRC Hi5C1
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 06 20 00 13 88 8F 5C (CRC=0x5C8F, wire: 0x8F 0x5C) */
static const uint8_t frame_pdu[6] = { 0x01, 0x06, 0x20, 0x00, 0x13, 0x88 };
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 06 20 00 13 88")
crc = modbus_crc16(pdu)
rtu_frame = pdu + crc.to_bytes(2, "little")
assert rtu_frame.hex(" ").upper() == "01 06 20 00 13 88 8F 5C"
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.

Send single-register control writes with Modbus RTU FC06

Function Code 0x06 writes a single 16-bit unsigned integer into a holding register—commonly used to command VFD motor frequency (e.g., 5000 = 50.00 Hz), toggle control words or update PID setpoints.

Unlike read requests, a compliant Modbus slave echoes back the exact same 8-byte FC06 frame verbatim upon success, making loopback CRC verification straightforward.

Formulas

  • FC06 PDU = [ID, 0x06, Addr_Hi, Addr_Lo, Val_Hi, Val_Lo]
  • 5000 decimal = 0x1388 (big-endian bytes 13 88)
  • Success response = exact echo of 8-byte request

Worked example

Writing 5000 (0x1388) to register 0x2000 (8192) on Slave 1 generates `01 06 20 00 13 88 8F 5C`, taking 4.58 ms on the wire at 19,200 bps.

Frequently asked questions

How do I write a negative signed setpoint using FC06?

Convert the signed 16-bit integer to two’s complement unsigned (65536 + value). For example, −100 becomes 65436 (0xFF9C).

Do all Modbus devices accept FC06 for writing 1 register?

Most do, though some inverters and BMS controllers strictly require FC16 (Write Multiple Registers) even when writing a single 16-bit word.

What happens if I send FC06 to Slave Address 0?

Address 0 is Modbus broadcast: every slave executes the write silently and no slave sends a reply frame.