Communication processor and Modbus TCP
13.5 Modbus communication
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
1171
Modbus TCP instructions
MB_CLIENT (Communicate using PROFINET as Modbus TCP client) instruction
Table 13- 56 MB_CLIENT instruction
REQ:=_bool_in_,
DISCONNECT:=_bool_in_,
MB_MODE:=_usint_in_,
MB_DATA_ADDR:=_udint_in_,
MB_DATA_LEN:=_uint_in_,
DONE=>_bool_out_,
BUSY=>_bool_out_,
ERROR=>_bool_out_,
STATUS=>_word_out_,
MB_DATA_PTR:=_variant_inout_,
CONNECT:=_variant_inout_);
MB_CLIENT communicates as a
Modbus TCP client through the
PROFINET port on the S7-1200 CPU.
No additional communication hard-
ware module is required.
MB_CLIENT can make a client-server
connection, send a Modbus function
request, receive a response, and
control the disconnection from a Mod-
bus TCP server.
Table 13- 57 Data types for the parameters
REQ In Bool FALSE = No Modbus communication request
TRUE = Request to communicate with a Modbus TCP server
DISCONNECT IN Bool The DISCONNECT parameter allows your program to control connec-
tion and disconnection with a Modbus server device.
If DISCONNECT = 0 and a connection does not exist, then MB_CLIENT
attempts to make a connection to the assigned IP address and port
number.
If DISCONNECT = 1 and a connection exists, then a disconnect opera-
tion is attempted. Whenever this input is enabled, no other operation will
MB_MODE IN USInt Mode selection: Assigns the type of request (read, write, or diagnostic).
See the Modbus functions table below for details.
MB_DATA_ADDR IN UDInt Modbus starting Address: Assigns the starting address of the data to be
accessed by MB_CLIENT. See the following Modbus functions table for
MB_DATA_LEN IN UInt Modbus data Length: Assigns the number of bits or words to be ac-
cessed in this request. See the following Modbus functions table for
MB_DATA_PTR IN_OUT Variant Pointer to the Modbus data register: The register buffers data going to or
coming from a Modbus server. The pointer must assign a non-optimized
global DB or an M memory address.
CONNECT IN_OUT Variant
Reference to a Data block structure that contains connection parameters
in the system data type "TCON_IP_v4".
DONE OUT Bool The DONE bit is TRUE for one scan, after the last request was complet-