MB_SERVER
MB_SERVER
Description of MB_SERVER
Description
The "MB_SERVER" instruction communicates as Modbus TCP server via a PROFINET
connection. The instruction "MB_SERVER" processes connection requests of a Modbus
TCP client, receives and processes Modbus requests and sends responses.
For the S7-1200 with firmware version V4.0 you can use the "MB_SERVER" instruction up
to and including library version V3.1. With the S7-1200 as of firmware version V4.1 and the
S7-1500, you can use the "MB_SERVER" instruction of all library versions.
The connection can take place via the local interface of the CPU or CM/CP.
To use the instruction, you do not require an additional hardware module.
NOTICE
Security information
Note that each client of the network is given read and write access to the process image
inputs and outputs and to the data block or bit memory area defined by the Modbus hold-
ing register.
The option is available to restrict access to an IP address to prevent unauthorized read
and write operations. Note, however, that the shared address can also be used for unau-
thorized access.
Parameters
The following table shows the parameters of the "MB_SERVER" instruction:
-1-
Description of MB_SERVER (S7-1200, S7-1500)
-2-
Description of MB_SERVER (S7-1200, S7-1500)
Note
Use of Modbus function 23 in the instruction "MB_SERVER"
The instruction "MB_SERVER" supports the use of Modbus function 23 with which you
can write to a holding register and read from a holding register in a job; however, the in-
struction "MB_CLIENT" does NOT support this function and returns an error code.
Also note that for a job with read access and write access, write access is executed be-
fore the read access.
You can find additional information on valid data types under "Overview of the valid data
types".
-3-
Description of MB_SERVER (S7-1200, S7-1500)
The "MB_SERVER" instruction allows incoming Modbus functions (1, 2, 4, 5 and 15) direct
read and write access to the process image inputs and outputs of the CPU (use of the data
types BOOL and WORD).
For S7-1200-CPUs, the address space for the process image of the inputs and the process
image of the outputs is 1 KB; it is 32 KB each for S7-1500-CPUs.
The following table shows the address space of the Modbus functions listed above.
Modbus function
Function
Function Data area Address space
code
01 Read: Bits Output 0 to 65.535
02 Read: Bits Input 0 to 65.535
04 Read: WORD Input 0 to 65.535
05 Write: Bit Output 0 to 65.535
15 Write: Bits Output 0 to 65.535
Incoming Modbus requests with the function codes 3, 6, 16 and 23 write or read the Mod-
bus holding registers (you specify the holding register with the MB_HOLD_REG parame-
ter).
Modbus address
0 99
0 (WORD)
CPU address MW100 MW298
Modbus address
20 119
20 (WORD)
CPU address MW100 MW298
Modbus functions
The following table lists all the Modbus functions that are supported by the "MB_SERVER"
instruction.
-4-
Description of MB_SERVER (S7-1200, S7-1500)
Example
An example project for the Modbus TCP communication between two S7-1500 CPUs can
be found in the Service and Support Portal under Entry ID 94766380.
Two Modbus functions are used in this example. For each Modbus function, a Modbus
TCP connection is established using a Modbus block pair (MB_CLIENT and MB_SERV-
ER).
See also
-5-
Description of MB_SERVER (S7-1200, S7-1500)
-6-