Modbus RTU Frame Builder & Decoder
Use this Modbus RTU Frame Builder & Decoder to create valid Modbus request frames, calculate the Modbus CRC-16 automatically, or decode captured RTU frames into slave address, function code, register or coil address, quantity, data bytes and CRC status.
0xCDC5 appears on the wire as C5 CD.
-
-
What Is a Modbus RTU Frame Builder & Decoder?
A Modbus RTU Frame Builder & Decoder creates or interprets the binary message format used by Modbus RTU devices on serial communication links. Instead of manually assembling slave address, function code, data fields and CRC bytes, the calculator generates the complete request automatically.
Decoder mode performs the reverse operation. Paste a captured RTU frame and the tool verifies its CRC, identifies the slave address and function code, and interprets common register, coil, write and exception-message fields.
This is useful when working with PLCs, industrial sensors, variable-frequency drives, energy meters, remote I/O modules, gateways, embedded controllers and other Modbus-compatible equipment.
Modbus RTU Frame Format
A normal Modbus RTU application data unit contains a slave address, function code, function-specific data and a two-byte CRC.
Unlike Modbus TCP, RTU does not use an MBAP header. Device addressing and integrity checking are carried directly by the serial RTU frame.
How to Build a Modbus RTU Request
Select the Modbus server/slave device that should receive the request.
Choose whether you want to read coils, read registers or write values.
Provide the 16-bit starting coil or register address carried in the Modbus PDU.
The required fields change automatically according to the chosen function.
The calculator appends the correct Modbus CRC-16 low byte and high byte.
Modbus RTU CRC-16
Modbus RTU uses a 16-bit cyclic redundancy check for error detection. The CRC
register starts at hexadecimal FFFF. Each message byte is XORed
into the low portion of the CRC register and processed bit by bit using the
reflected polynomial associated with hexadecimal A001.
Modbus CRC Byte Order
A common source of errors is confusing the numerical CRC value with its transmitted byte sequence.
Modbus RTU sends the lower-order CRC byte first, followed by the higher-order CRC byte.
Modbus Function Code 03 Example
Function code 03 reads holding registers. A request contains the starting protocol address and the number of registers to read.
Supported Modbus RTU Function Codes
| Hex | Function | Typical Request Data |
|---|---|---|
| 01 | Read Coils | Starting address + coil quantity |
| 02 | Read Discrete Inputs | Starting address + input quantity |
| 03 | Read Holding Registers | Starting address + register quantity |
| 04 | Read Input Registers | Starting address + register quantity |
| 05 | Write Single Coil | Coil address + FF00 or 0000 |
| 06 | Write Single Register | Register address + 16-bit value |
| 0F | Write Multiple Coils | Address, quantity, byte count and packed coil states |
| 10 | Write Multiple Registers | Address, quantity, byte count and register values |
Function 01 — Read Coils
Function code 01 requests the ON/OFF state of one or more coils. The request contains a starting coil address and quantity.
The corresponding response normally contains a byte count followed by packed coil status bits.
Function 03 — Read Holding Registers
Function 03 is among the most commonly encountered Modbus functions. It reads one or more 16-bit holding registers.
The request specifies the starting protocol address and quantity. A normal response contains the same function code followed by a byte count and two bytes for every returned register.
Function 04 — Read Input Registers
Function 04 has a request structure similar to function 03, but reads input registers rather than holding registers.
Function 05 — Write Single Coil
Function 05 writes one coil. Modbus represents the requested state with a specific 16-bit field.
The normal server response echoes the function code, coil address and written value.
Function 06 — Write Single Register
Function 06 writes one 16-bit holding register. The request contains the register protocol address followed by the new 16-bit register value.
Function 10 — Write Multiple Registers
Function code hexadecimal 10 writes multiple consecutive registers. The request contains the start address, number of registers, data-byte count and the register values themselves.
The builder calculates quantity and byte count automatically from the values entered.
Function 0F — Write Multiple Coils
Function hexadecimal 0F writes multiple coil states. Because each coil is one bit, the coil states are packed into data bytes rather than transmitted as one byte per coil.
The least-significant bit of the first data byte represents the first coil, with subsequent coil states following through progressively higher bits and then additional bytes.
Modbus Register Address vs 40001-Style Number
A major source of Modbus confusion is the difference between the protocol address transmitted in the request and the human-readable reference number often shown in manuals.
Protocol Address
The zero-based 16-bit address actually transmitted in the Modbus request PDU.
Reference Number
Documentation may describe registers using notation such as 40001 or 40002. This notation is not transmitted literally as the 16-bit protocol address.
Modbus RTU Request vs Response
Request
A client/master sends a slave address, function code and parameters describing the requested operation.
Response
The server/slave returns the requested data, echoes write information or sends an exception response if the operation cannot be completed.
Decoder mode examines the frame structure and interprets common request and response layouts where sufficient information is available.
Modbus Exception Responses
When a Modbus server reports an error, it sets the most significant bit of the requested function code. The next byte contains the exception code.
| Exception | Meaning |
|---|---|
| 01 | Illegal Function |
| 02 | Illegal Data Address |
| 03 | Illegal Data Value |
| 04 | Server Device Failure |
| 05 | Acknowledge |
| 06 | Server Device Busy |
| 08 | Memory Parity Error |
| 0A | Gateway Path Unavailable |
| 0B | Gateway Target Device Failed to Respond |
How the Decoder Validates CRC
The decoder removes the final two bytes from the entered frame, recalculates the Modbus CRC over every preceding byte and compares the result with the received CRC bytes.
Modbus RTU vs Modbus TCP
| Feature | Modbus RTU | Modbus TCP |
|---|---|---|
| Transport | Serial | TCP/IP |
| Integrity field | CRC-16 | No RTU CRC |
| Header | No MBAP header | MBAP header |
| Unit addressing | RTU slave address | Unit Identifier field |
| Common function codes | Shared Modbus PDU functions | Shared Modbus PDU functions |
Common Modbus RTU Frame Mistakes
Reversing CRC Bytes
The low-order CRC byte is transmitted first.
Using Register Reference Number
A manual’s 40001-style notation may not equal the transmitted address.
Wrong Function Code
Holding registers, input registers, coils and discrete inputs have different functions.
Incorrect Quantity
Read requests specify number of objects, not number of response bytes.
Wrong Multi-Write Byte Count
Function 10 requires two data bytes for each 16-bit register value.
Including CRC in CRC Calculation
The CRC is calculated over the frame bytes before the two CRC bytes are appended.
Modbus RTU Frame Builder & Decoder FAQs
How do I build a Modbus RTU frame?
What CRC does Modbus RTU use?
Which CRC byte comes first in Modbus?
What does function 03 do?
What does function 04 do?
What does function 06 do?
What does function 10 do?
What does function 0F do?
What is Modbus slave address 0?
What is the normal Modbus RTU slave range?
How do I verify a Modbus CRC?
Why does my register address differ by one?
Is Modbus RTU big endian?
What is a Modbus exception response?
Does Modbus TCP use the RTU CRC?
Can this tool decode responses?
Build and Decode Modbus RTU Frames
Create Modbus read and write requests with the correct CRC, or paste a raw serial frame to validate its CRC and inspect slave address, function code, register information, data bytes and exception status.