Ozeki
Function Code 15 Function Code 15 | References References

Modbus Function Code 16

Write Multiple Holding Registers on Modbus

This function code is used to write a block of contiguous registers (1 to 123 registers) in a remote device. The requested written values are specified in the request data field. Data is packed as two bytes per register.

Request

Function code1 Byte0x10
Starting Address2 Bytes0x0000 to 0xFFFF
Quantity of Registers2 Bytes0x0001 to 0x007B
Byte Count1 Byte2 x N*
Registers ValueN* x 2 Bytesvalue
*N = Quantity of Registers
Table 1 - Command structure

Response

The normal response returns the function code, starting address, and quantity of registers written.

Function code1 Byte0x10
Starting Address2 Bytes0x0000 to 0xFFFF
Quantity of Registers2 Bytes1 to 123 (0x7B)
Table 2 - Response structure

Error

Error code1 Byte0x90
Exception code1 Byte01 or 02 or 03 or 04
Table 3 - Error structure. Scroll below for details.

Example

Request

This command is writing the contents of two analog output holding registers # 40019 & 40020 to the slave device with address 11. Each holding register can store 16 bits.

0B 10 0012 0002 04 0B0A C102 A0D5
  • 0B: The Slave Address (0B hex = address 11)
  • 10: The Function Code 16 (Write Multiple Holding Registers, 16 = 10 hex)
  • 0012: The Data Address of the first register (0012 hex = 18, +40001 offset = register #40019).
  • 0002: The number of registers to write.
  • 04: The number of data bytes to follow (2 registers x 2 bytes each = 4 bytes).
  • 0B0A: The value to write to register 40019
  • C102: The value to write to register 40020
  • A0D5: The CRC (Cyclic Redundancy Check) for error checking.

Response

0B 10 0012 0002 E167
  • 0B: The Slave Address (0B hex = address 11)
  • 10: The Function Code 16 (Write Multiple Holding Registers, 10 hex - 16)
  • 0012: The Data Address of the first register (# 40019 - 40001 = 18 (0012 hex) ).
  • 0002: The number of registers written.
  • E167: The CRC (Cyclic Redundancy Check) for error checking.

Workflow Diagram for Modbus FC 16

FC=16 workflow
Figure 1 - Write states of Multiple Holding Registers

Contents retrieved from

  • http://modbus.org/
  • http://www.simplymodbus.ca/

Copyright © 2000- - Ozeki Ltd | info@ozeki.hu
Home > Technology > Modbus > Appendix > Function Code 16
Legal | Privacy | Terms of use | 5883
18.208.126.130 | 87.229.102.173 | Login