The Modbus TCP protocol is implemented in the AC500 processor modules. Modbus is a master-slave (client-server) protocol. The client sends a request to the server and receives the responses. Each Ethernet interface can work as Modbus client and server interface in parallel if required.
The Modbus operating mode of an Ethernet interface is set in Modbus on TCP/IP protocol⮫ “Modbus on TCP/IP protocol”.
Modbus client
In this operating mode, the telegram traffic with the server(s) is handled via the function block ModTcpMast, which can be found through the Library Manager ⮫ “Library Manager functionality”. This function block sends Modbus request telegrams to the server(s) via the set interface and receives Modbus response telegrams from the server(s) via this interface.
The Modbus function blocks transferred by the client contain the following information:
-
Transaction identifier for synchronization between messages of server and client (2 byte)
-
Protocol identifier (0 for Modbus/TCP) (2 byte)
-
Length field (Number of bytes in frame) (2 byte)
-
Unit identifier (1 byte)
-
Function code that defines the request of the client (1 byte)
-
Data to be exchanged (n bytes)
Modbus server
In this operating mode, no function block is required for Modbus communication. Sending and receiving Modbus telegrams is performed automatically.
The AC500 CPUs process the following Modbus operation codes:
Function code |
Description |
|
---|---|---|
DEC |
HEX |
|
01 or 02 |
01 or 02 |
Read n bits |
03 or 04 |
03 or 04 |
Read n words |
05 |
05 |
Write one bit (encoded in one word) |
06 |
06 |
Write one word |
15 |
0F |
Write n bits (encoded in one byte) |
16 |
10 |
Write n words |
22 |
16 |
Mask write |
23 |
17 |
Read/write multiple words in one telegram |
The following restrictions apply to the length of the data to be sent:
Function code |
Max. length |
|
---|---|---|
DEC |
HEX |
|
01 or 02 |
01 or 02 |
2000 bits |
03 or 04 |
03 or 04 |
125 words / 62 double words |
05 |
05 |
1 bit |
06 |
06 |
1 word |
15 |
0F |
2000 bits |
16 |
10 |
123 words / 61 double words |
22 |
16 |
Write: 1 word |
23 |
17 |
Read: 125 words / 62 double words Write: 121 words / 60 double words |