105BCommunication processor
12.5 Modbus communication
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
583
Modbus TCP communication
Modbus TCP (Transmission Control Protocol) is a standard network communication protocol
that uses the PROFINET connector on the CPU for TCP/IP communication. No additional
communication hardware module is required.
Modbus TCP uses Open User Communications (OUC) connections as a Modbus
communication path. Multiple client-server connections may exist, in addition to the
connection between STEP 7 and the CPU. Mixed client and server connections are
supported up to the maximum number of connections allowed by the CPU model
(Page 394).
Each MB_SERVER connection must use a unique instance DB and IP port number. Only 1
connection per IP port is supported. Each MB_SERVER (with its unique instance DB and IP
port) must be executed individually for each connection.
Note
Modbus TCP will only operate correctly with CPU firmware release V1.02 or later. An
attempt to execute the Modbus instructions on an earlier firmware version will result in an
error.
A Modbus TCP client (master) must control the client-server connection with the
DISCONNECT parameter. The basic Modbus client actions are shown below.
1.
Initiate a connection to a particular server (slave) IP address and IP port number
2.
Initiate client transmission of a Modbus messages and receive the server responses
3.
When desired, initiate the disconnection of client and server to enable connection with a
different server.
Modbus RTU instructions in your program
●
MB_COMM_LOAD: One execution of MB_COMM_LOAD is used to set up PtP port
parameters like baud rate, parity, and flow control. After a CPU port is configured for the
Modbus RTU protocol, it can only be used by either the MB_MASTER or MB_SLAVE
instructions.
●
MB_MASTER: The Modbus master instruction enables the CPU to act as a Modbus RTU
master device and communicate with one or more Modbus slave devices.
●
MB_SLAVE: The Modbus slave instruction enables the CPU to act as a Modbus RTU
slave device and communicate with a Modbus master device.
Modbus TCP instructions in your program
●
MB_CLIENT: Make client-server TCP connection, send command message, receive
response, and control the disconnection from the server
●
MB_SERVER: Connect to a Modbus TCP client upon request, receive Modbus message,
and send response