Table 13- 69 MB_SERVER execution condition codes
STATUS
Response code
(W#16#)
to Modbus serv-
er (B#16#)
7001
7002
7003
8187
818C
8381
01
8382
03
8383
02
8384
03
8385
03
In addition to the MB_SERVER errors listed above, errors can be returned from the
1
underlying T block communication instructions (TCON, TDISCON, TSEND, and TRCV).
13.5.2.4
Modbus TCP examples
Example: MB_SERVER Multiple TCP connections
You can have multiple Modbus TCP server connections. To accomplish this, MB_SERVER
must be independently executed for each connection. Each connection must use an
independent instance DB, connection ID, and IP port. The S7-1200 allows only one
connection per IP port.
For best performance, MB_SERVER should be executed every program cycle, for each
connection.
The CONNECT parameter uses system data type TCP_IP_v4.For the example, these data
structures are in a DB named "Modbus connections". The "Modbus connections" DB
contains two TCP_IP_v4 structures "TCPpassive_1" (for connection 1) and "TCP_passive_2"
(for connection 2).The connection properties ID and LocalPort described in the network
comments are data elements stored in the CONNECT data structure.
The TCP_IP_v4 CONNECT data also contains an IP address in the RemoteAddress ADDR
array. IP address assignments within TCPpassive_1 and TCP_passive_2 do not affect the
establishment of TCP server connections, but determine which Modbus TCP clients are
allowed to communicate though the connections to each MB_SERVER. MB_SERVER
passively listens for a modbus client message and compares the incoming message IP
address with the IP address stored in the corresponding RemoteAddress ADDR array.
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
1
Modbus protocol errors
MB_SERVER is waiting for a Modbus client to connect to the assigned TCP port. This
code is returned on the first execution of a connect or disconnect operation.
MB_SERVER is waiting for a Modbus client to connect to the assigned TCP port. This
code is returned for any subsequent executions, while waiting for completion of a connect
or disconnect operation.
A disconnect operation has successfully completed (Only valid for one PLC scan).
MB_HOLD_REG is not valid, could be pointing into an optimized DB, or is pointing to an
area of less than 2 bytes.
Pointer MB_HOLD_REG points to a non-optimized DB area (must be a non-optimized
global DB area or M memory area) or Blocked process timeout exceeds the limit of 55
seconds. (S7-1200 specific)
Function code not supported
Data length error
Data address error or access outside the bounds of the MB_HOLD_REG address area
Data value error
Data diagnostic code not supported (function code 08)
Communication processor and Modbus TCP
13.5 Modbus communication
1185