×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 102020340, Entry date: 08/15/2019
(6)
Rate

How do you program and parameterize Modbus/TCP communication between S7-1500 CPUs and S7-1200 CPUs?

  • Entry
  • Associated product(s)
Modbus/TCP communication between S7-1500 CPUs and S7-1200 CPUs is presented. The instructions "MB_CLIENT" and "MB_SERVER" are called and parameterized in the user program of the S7-1500 CPU and the S7-1200 CPU.

The "MB_CLIENT" instruction communicates as Modbus/TCP client via the PROFINET interface of the CPU. You use the "MB_CLIENT" instruction to establish a connection between the client and the server, send requests and receive responses, and control disconnection of the connection. The "MB_CLIENT" instruction is called in a separate function block "ModbusClient".

The "MB_SERVER" instruction communicates as Modbus/TCP server via the PROFINET interface of the CPU. The "MB_SERVER" instruction processes connection requests of a Modbus/TCP client, receives requests from Modbus functions and sends response messages. The "MB_SERVER" instruction is called in a function block "ModbusServer".

In this example two Modbus functions are demonstrated via two Modbus/TCP connections.
The S7-1500 CPU establishes the first connection as Modbus TCP client. The S7-1200 CPU is Modbus TCP server.
The S7-1200 CPU establishes the second connection as Modbus TCP client. The S7-1500 CPU is Modbus TCP server.

The Modbus/TCP connections are established each via a Modbus block pair (MB_CLIENT and MB_SERVER). The "MB_CLIENT" and "MB_SERVER" instructions are each called in a separate function block ("ModbusClient" and "ModbusServer").



Fig. 1

The following document describes:

  • The call and parameterization of the function block "ModbusClient", that internally calls the "MB_CLIENT" instruction, in the user program of the S7-1500 CPU and S7-1200 CPU.
  • The call and parameterization of the function block "ModbusServer", that internally calls the "MB_SERVER" instruction, in the user program of the S7-1500 CPU and S7-1200 CPU.

  net_modbus_tcp_s7-1500_s7-1200_en.pdf (1,0 MB) 

Download
The download includes the "ModbusTCP_S71500_V15-1.zip" project.
Copy the "ModbusTCP_S71500_V15-1.zip" file into a separate folder and then start the file with a double-click. You then use STEP 7 to open and process the unpacked project data.

 Registrierung notwendig  ModbusTCP_S71500_V15-1.zip (2,9 MB)

 
Note
The "MB_CLIENT" and "MB_SERVER" instructions are in the "MODBUS TCP" library. For the S7-1200 with firmware version V4.0 you can use the "MB_CLIENT" and "MB_SERVER" instructions from up to and including library version V3.1. For S7-1200 with firmware version V4.1 and higher and for S7-1500 you can use the "MB_CLIENT" and "MB_SERVER" instructions from all library versions.

Further Information
Detailed information about the "MB_CLIENT" and "MB_SERVER" instructions is available in the manual in Entry ID 109755202.

Creation Environment

The screens and downloads in this FAQ response were created with STEP 7 Professional V15.1 and "MODBUS TCP" library V4.1.
Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.