Example: MB_CLIENT 1: Multiple requests with common TCP connection
Multiple Modbus client requests can be sent over the same connection. To accomplish this,
use the same instance DB, connection ID, and port number.
Because both MB_CLIENT boxes use the same CONNECT parameter TCON_IP_v4 data
structure ("Modbus_connections".TCPactive_1), the connection ID, port number, and IP
address are identical. The CONNECT IP address data assigns the IP address, of the target
Modbus TCP server.
Only one MB_CLIENT can be active at any given time. Once a client completes its
execution, the next client can begin execution. Your program logic is responsible for the
execution sequence logic. The example shows both clients reading remote data from a
single Modbus client and transferring the data to the Modbus client's CPU (M memory
starting at M1000.0). A returned error is captured, which is optional.
Network 1: Modbus function 1 - Read 16 output bits from a Modbus TCP server with the IP
address assigned in "Modbus connections".TCPactive_1.
Network 2: Modbus function 2 - Read 32 input bits from a Modbus TCP server with the IP
address assigned in "Modbus connections".TCPactive_1.
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
Communication processor and Modbus TCP
13.5 Modbus communication
1187