Modbus Function Code 16 (Write Multiple Holding Registers): Engineering Protocol Guide & Packet Analysis
In industrial automation, Modbus Function Code 16 (0x10 — Write Multiple Registers) is the workhorse command for configuring field devices, writing supervisory setpoints, and downloading recipes. While Function Code 06 is limited to updating a single 16-bit register, modern field equipment—such as variable frequency drives (VFDs), solar power inverters, multiloop PID controllers, flow computers, and power quality analyzers—predominantly utilizes multi-register data types, including 32-bit IEEE 754 floating-point process variables, 32-bit signed integers, and 64-bit cumulative energy totals.
Using FC16 ensures that multi-register values are updated atomically. If a SCADA system or PLC attempted to update a 32-bit floating-point setpoint using two separate FC06 commands, a control loop executing between the two writes would read a corrupted hybrid value, resulting in hazardous plant operations. FC16 eliminates this risk by writing the entire register block in a single, uninterruptible transaction.
1. Memory Model & Addressing: 4xxxx Holding Registers
Modbus Function Code 16 operates exclusively on the Holding Registers memory table. In historical Modbus terminology (often termed PLC 5-digit or 6-digit notation), Holding Registers occupy the 40001–49999 or 400001–465536 reference address space.
At the wire protocol (PDU) layer, Modbus uses 0-based 16-bit hexadecimal offsets:
- PLC Reference
40001translates to protocol offset0x0000. - PLC Reference
40108translates to protocol offset0x006B(107 decimal). - PLC Reference
44001translates to protocol offset0x0FA0(4000 decimal).
Crucial Automation Tip: The 1-Based Off-by-One Trap
When configuring master software like Modbus Poll, SCADA platforms, or Python PyModbus scripts against a slave device, always verify whether the device manual documents 1-based PLC addresses (e.g. 40001) or 0-based protocol offsets. Entering 40001 as offset 1 will write to PLC register 40002, misaligning all subsequent registers in the block write.
2. Modbus FC16 Request & Response Frame Layout
Unlike FC06 which sends only the address and value, FC16 includes the starting address, register count, byte count, and the payload bytes.
Modbus RTU FC16 Request Packet (Master to Slave)
Modbus RTU FC16 Normal Response Packet (Slave to Master)
A compliant slave executes the block write and returns an acknowledgment frame echoing the starting address and register count. It does not return the register data:
3. Multi-Register Data Formats & 32-Bit Float Endianness
Modbus registers are defined as 16-bit unsigned integers (0 to 65535). When transmitting 32-bit floating-point numbers (IEEE 754), 32-bit signed/unsigned integers, or 64-bit double-precision numbers, data is mapped across consecutive registers.
Because Modbus was designed in 1979 before standardizing floating-point endianness, manufacturers adopted different word and byte ordering rules. Suppose we want to write the float value 25.0 (Hex: 0x41C80000) across registers 100 and 101:
| Byte Order Name | Byte Sequence | Register 100 (Hex) | Register 101 (Hex) | Typical Manufacturers |
|---|---|---|---|---|
| Big-Endian (ABCD) | A, B, C, D | 0x41 0xC8 | 0x00 0x00 | Schneider Electric, Siemens, Yokogawa |
| Little-Endian (DCBA) | D, C, B, A | 0x00 0x00 | 0xC8 0x41 | Rockwell / Allen-Bradley (some modules) |
| Mid-Little-Endian / Byte Swapped (BADC) | B, A, D, C | 0xC8 0x41 | 0x00 0x00 | Select energy meters, European RTUs |
| Mid-Big-Endian / Word Swapped (CDAB) | C, D, A, B | 0x00 0x00 | 0x41 0xC8 | Modicon 984, Advantech, Omron |
4. Python PyModbus Implementation Example
The following Python script demonstrates executing Modbus Function Code 16 over TCP and RTU to write integer and 32-bit float parameters using pymodbus:
5. Modbus Exception Codes Encountered with FC16
When an FC16 request cannot be processed by the target slave, an Exception Frame is returned (Function Code = 0x10 | 0x80 = 0x90):
- 0x01 (Illegal Function): The slave device does not implement Function Code 16 (often seen in legacy or budget sensor transmitters that only permit FC06 single-register updates).
- 0x02 (Illegal Data Address): The starting register offset plus the quantity of registers exceeds the valid holding register boundary of the device.
- 0x03 (Illegal Data Value): Occurs if the quantity of registers is 0, or exceeds 123 (RTU) / 125 (TCP), or if the Byte Count field in byte 6 does not equal
Quantity * 2. - 0x04 (Slave Device Failure): The slave encountered an unrecoverable hardware or EEPROM flash write error while writing the holding registers.
6. Testing & Simulating FC16 with Modbus Simulator
Before commissioning PLC logic or deploying SCADA scripts into live manufacturing lines, engineers use Modbus Slave Simulator to test multi-register writes without risking machinery damage:
- Open Modbus Simulator and select Modbus TCP Server or Modbus RTU Slave.
- Configure your desired slave ID (e.g., Node 1) and communication port (Port 502 or COM port).
- Navigate to the Holding Registers (4xxxx) table.
- Configure the data display format (16-bit Int, 32-bit Float ABCD, CDAB, BADC, or 32-bit Long).
- Execute your PLC or SCADA FC16 block write script. Watch registers update in real-time with zero latency and inspect raw hexadecimal traffic in the built-in packet analyzer.
Simulate Modbus FC16 Block Writes Instantly
Download Modbus Simulator for Windows 10 & 11. Test Modbus RTU, TCP, and ASCII master/slave communications with built-in float32 byte-swapping and live packet logging.
Download Modbus Simulator Free →Frequently Asked Questions
What is Modbus Function Code 16?
Modbus Function Code 16 (0x10 / Write Multiple Holding Registers) is the standard industrial command used by a Modbus master (client) to write a block of contiguous 16-bit holding registers (4xxxx address range) into a remote slave (server) device in a single atomic communication frame.
How many registers can be written in a single Function Code 16 request?
Under the Modbus Application Protocol Specification V1.1b3, a single Function Code 16 request can write from 1 up to 123 registers (246 data bytes) in Modbus RTU due to the 256-byte maximum ADU limit, or up to 125 registers in Modbus TCP.
How are 32-bit float values (IEEE 754) written using FC16?
Modbus registers are strictly 16 bits wide. A 32-bit floating-point number spans two consecutive 16-bit registers (4 bytes). Because Modbus does not define multi-register endianness, devices use one of four byte orders: Big-Endian (ABCD / High word first, MSB first), Little-Endian (DCBA / Low word first, LSB first), Mid-Little-Endian / Byte Swapped (BADC), or Mid-Big-Endian / Word Swapped (CDAB).
What is the normal response from a slave for Function Code 16?
The normal (successful) response from the slave echoes the Function Code (0x10), the 2-byte Starting Address, and the 2-byte Quantity of Registers written. The register data payload is not echoed back, keeping response frames compact and fast.
What is the difference between Function Code 06 and Function Code 16?
Function Code 06 (0x06) can only write exactly one single 16-bit register per transmission. Function Code 16 (0x10) writes multiple contiguous registers (up to 123 registers), making it essential for atomic 32-bit floating-point parameters, 64-bit energy counters, multi-axis drive parameters, recipes, and batch configuration.
What causes Modbus Exception Code 03 with Function Code 16?
Exception 03 (Illegal Data Value) occurs if: (1) the Quantity of Registers is 0 or exceeds 123 (RTU) / 125 (TCP), or (2) the Byte Count field does not equal exactly 2 times the Quantity of Registers.