Modbus Function Code 6
Write Single Holding Register on Modbus
This function code is used to write a single holding register in a remote device. The Request PDU specifies the address of the register to be written. Registers are addressed starting at zero. Therefore register numbered 1 is addressed as 0.
Request
Function code | 1 Byte | 0x06 |
Register Address | 2 Bytes | 0x0000 to 0xFFFF |
Register Value | 2 Bytes | 0x0000 to 0xFFFF |
Response
The normal response is an echo of the request, returned after the register contents have been written.
Function code | 1 Byte | 0x06 |
Register Address | 2 Bytes | 0x0000 to 0xFFFF |
Register Value | 2 Bytes | 0x0000 to 0xFFFF |
Error
Error code | 1 Byte | 0x86 |
Exception code | 1 Byte | 01 or 02 or 03 or 04 |
Example
Request
This command is writing the contents of analog output holding register # 40005 to the slave device with address 11. Each holding register can store 16 bits.
0B 06 0004 ABCD 7604 |
- 0B: The Slave Address (0B hex = address 11)
- 06: The Function Code 6 (Write Single Holding Register)
- 0004: The Data Address of the register (0004 hex = 4, + 40001 offset = register #40005).
- ABCD: The value to write.
- 7604: The CRC (Cyclic Redundancy Check) for error checking.
Response
The normal response is an echo of the query, returned after the register contents have been written.
0B 06 0004 ABCD 7604 |
- 0B: The Slave Address (0B hex = address 11)
- 06: The Function Code 6 (Write Single Holding Register)
- 0004: The Data Address of the register (0004 hex = 4, + 40001 offset = register #40005).
- ABCD: The value written.
- 7604: The CRC (Cyclic Redundancy Check) for error checking.
Workflow Diagram for Modbus FC 6
Contents retrieved from
- http://modbus.org/
- http://www.simplymodbus.ca/
More information
- Códigos de función Modbus
- Código de función Modbus 1 - leer bobinas
- Código de función Modbus 2 - leer entradas discretas
- Código de función Modbus 3 - leer múltiples registros de retención
- Código de función Modbus 4 - leer registros de entrada
- Código de función Modbus 5 - escribir bobina única
- Código de función Modbus 6 - escribir registro de retención único
- Código de función Modbus 15 - escribir múltiples bobinas
- Código de función Modbus 16 - escribir múltiples registros de retención
- Referencias Modbus
- Conceptos básicos del protocolo Modbus