Modbus Functions
General Description
The Modbus protocol offers a number of functions that are used to read or write data over the Modbus network. The Modbus protocol also offers diagnostic and network-management functions.
Only the Modbus functions handled by the VigiPacT relays are described here.
Functions
The following functions are available:
Function Code |
Subfunction Code |
Name |
Description |
---|---|---|---|
1 (0x01) |
– |
Read coils |
Read output bits |
2 (0x02) |
– |
Read discrete inputs |
Read input bits |
3 (0x03) |
– |
Read holding registers |
Read n registers |
5 (0x05) |
– |
Write single coil |
Write 1 bit |
6 (0x06) |
– |
Write single register |
Write 1 register |
16 (0x10) |
– |
Write multiple registers |
Write n registers |
43 (0x2B) |
14 (0x0E) |
Read device identification |
Read the identification data of the server |
Read Register Example
The following table shows how to read the measured current in register 1005. The address of register 1005 is 1005-1 = 1004= 0x03EC. The Modbus address of the Modbus server is 247 = 0xF7.
Client Request |
Server Reply |
||
---|---|---|---|
Field Name |
Example |
Field Name |
Example |
Modbus server address |
0xF7 |
Modbus server address |
0xF7 |
Function code |
0x03 |
Function code |
0x03 |
Address of the register to read (MSB) |
0x03 |
Data length in bytes |
0x02 |
Address of the register to read (LSB) |
0xEC |
Register value (MSB) |
0x12 |
Number of registers (MSB) |
0x00 |
Register value (LSB) |
0x34 |
Number of registers (LSB) |
0x01 |
CRC (MSB) |
0xXX |
CRC (MSB) |
0xXX |
CRC (LSB) |
0xXX |
CRC (LSB) |
0xXX |
– |
The content of register 60023 1005 (address 0x03EC) is 0x1234 = 4660. Therefore the measured current is 4660 mA.