105BCommunication processor
12.5 Modbus communication
S7-1200 Programmable controller
590
System Manual, 11/2011, A5E02486680-05
12.5.2.2
MB_SERVER (Modbus TCP)
Table 12- 55 MB_SERVER instruction
LAD / FBD
SCL
Description
"MB_SERVER_DB"(
DISCONNECT:=_bool_in_,
CONNECT_ID:=_uint_in_,
IP_PORT:=_uint_in_,
NDR=>_bool_out_,
DR=>_bool_out_,
ERROR=>_bool_out_,
STATUS=>_word_out_,
MB_HOLD_REG:=_variant_inout_);
MB_SERVER communicates as a
Modbus TCP server through the
PROFINET connector on the S7-1200
CPU. No additional communication
hardware module is required.
MB_SERVER can accept a request to
connect with Modbus TCP client ,
receive a Modbus function request, and
send a response message.
Table 12- 56 Data types for the parameters
Parameter and type
Data type Description
DISCONNECT
IN
Bool
MB_SERVER attempts to make a "passive" connection with a partner device.
This means that the server is passively listening for a TCP connection request
from any requesting IP address.
If DISCONNECT = 0 and a connection does not exist, then a passive
connection can be initiated.
If DISCONNECT = 1 and a connection exists, then a disconnect operation is
initiated. This allows your program to control when a connection is accepted.
Whenever this input is enabled, no other operation will be attempted.
CONNECT_ID
IN
UInt
CONNECT_ID uniquely identifies each connection within the PLC. Each
unique instance of the MB_CLIENT or MB_SERVER instruction must contain a
unique CONNECT_ID parameter.
IP_PORT
IN
UInt
Default value = 502: The IP port number that identifies the IP port that will be
monitored for a connection request from a Modbus client.
These TCP port numbers are not allowed for a MB_SERVER passive
connection: 20, 21, 25, 80, 102, 123, 5001, 34962, 34963, and 34964.
MB_HOLD_REG
IN_OUT Variant
Pointer to the MB_SERVER Modbus holding register: The holding register
must either be a standard global DB or a M memory address. This memory
area is used to hold the values a Modbus client is allowed to access using
Modbus register functions 3 (read), 6 (write), and 16 (write).
NDR
OUT
Bool
New Data Ready: 0 = No new data, 1 = Indicates that new data has been
written by a Modbus client
DR
OUT
Bool
Data Read: 0 = No data read, 1 = Indicates that data has been read by a
Modbus client.
ERROR
OUT
Bool
The ERROR bit is TRUE for one scan, after MB_SERVER execution was
terminated with an error. The error code value at the STATUS parameter is
valid only during the single cycle where ERROR = TRUE.
STATUS
OUT
Word
Execution condition code