Controller function codes
- Last UpdatedAug 29, 2024
- 2 minute read
The MBTCP Communication Driver uses function codes to communicate with the various controllers supporting the Modbus protocol. The implementation for the MBTCP Communication Driver uses the document, " Open Modbus/TCP Specification," Release 1.1, dated December 6, 2002 as a reference.
These function codes and their descriptions are listed in the following table.
Note: In communicating with the Generic Modbus PLCs, the MBTCP Communication Driver acts as a master and sends out the function codes to the PLCs.
|
Code |
Name |
Description |
|---|---|---|
|
01 (0x01) |
Read Coils |
Reads the ON/OFF status of discrete outputs (0X references, coils) in the slave. |
|
02 (0x02) |
Read Discrete Inputs |
Reads the ON/OFF status of discrete inputs (1XXXXX references) in the slave. |
|
03 (0x03) |
Read Holding Registers |
Reads the binary contents of holding registers (4XXXXX references) in the slave. |
|
04 (0x04) |
Read Input Registers |
Reads the binary contents of input registers (3XXXXX references) in the slave. |
|
05 (0x05) |
Write Single Coil |
Forces a single coil (0X reference) to either ON or OFF. |
|
06 (0x06) |
Write Single Register |
Presets a value into a single holding register (4XXXXX reference). |
|
15 (0x0F) |
Write Multiple Coils |
Forces each coil (0XXXXX reference) in a sequence of coils to either ON or OFF. |
|
16 (0x10) |
Write Multiple Registers |
Presets values into a sequence of holding registers (4XXXXX references). |
|
20 (0x14) |
Read General Reference |
Returns the contents of registers in the Extended Memory file (6XXXXX) references. |
|
21 (0x15) |
Write General Reference |
Writes the contents of registers in the Extended Memory file (6XXXXX) references. |
|
22 (0x16) |
Mask Write Holding Register |
Modifies the contents of a specified (4XXXXX reference) holding register using a combination of an AND mask, an OR mask, and the register’s current contents. The function can be used to set or clear individual bits in the register. |