Skip to content

S7 communication and networks

Published: at 04:29 PM

Motivation

This procedure describes the setup of communication between S7-1200/1500 devices in a network to exchange data.

Instructions

Device and network configuration

  1. Open the device configuration (“Devices & networks”) and switch to the network view.

    Devices & networks

  2. Right-click on the interface of a CPU and select “Add subnet” from the context menu.

    Add subnet

  3. Connect each device to the subnet by dragging from the device interface to the subnet or vice versa - simply click and hold on one interface, drag the mouse to the target, and release to establish the connection.

    Connect device

    As an alternative, you can skip the “Add subnet” step and connect all devices simply by dragging the mouse from one interface to another.

    Connect devices to subnet

    Resulting connections should look like this:

    Devices connected to subnet

  4. Now click “Connections” and choose “S7 connection”.

    S7 connection

  5. Right-click on each CPU and select “Add new connection” from the context menu.

    Add new connection

    Alternatively, connections can also be established by dragging the mouse from one CPU interface to another in this view.

  6. In the “Add new connection” dialog, first ensure that “S7 connection” type is selected. Then select the target CPU, make sure the right “Local ID” is configured and then click “Add” to add the connection. Repeat for all connections to be established.

    Add connection

    Each connection has a “Local ID” that must be unique for the CPU. As recommended practice, use a sequence starting at 100 (ex.: 100, 101, 102, …).

  7. In the “Network view”, select the “Connections” tab to show the connection table. Rename each local connection name to correspond to the connection (ex.: S7_Connection_PLC1_PLC2).

    Connection table

    Note that for each connection created from source CPU to target CPU, a counterpart connection is automatically created. This is not strictly necessary for communication via PUT/GET instructions, since we could establish “one-way” connections by selecting an “Unspecified” device and manually configuring the connection. This approach could be used if limited connection resources are a concern. However, for easier configuration and “self-documentation” in TIA Portal network view, it is recommended to configure “two-way” connections.

  8. For each device, open the properties of the CPU and navigate to “Protection & Security > Connection mechanisms”. Activate the function “Permit access with “PUT/GET communication from remote partner”.

    Permit access with PUT/GET

Program

Reference project: Villa Costina v1.3.0 (2025-10-15). This project provides a template for interchange of information among 4 S7-1200 CPUs.

typeS7ConnectionControl PLC data type

typeS7ConnectionControl

This PLC data type is present in the client CPU program (PLC1) and contains control information for PUT/GET instructions.

S7Connections/S7ConnectionsData DB

S7ConnectionsData

This data block is present in the client CPU (PLC1) contains control data for PUT/GET instructions.

S7Connections/Send_PLCx and S7Connections/Receive_PLCx DBs

S7ConnectionsData

S7ConnectionsData

These data blocks are present in the client CPU (PLC1) and also with counterparts in the server CPUs (PLC2, PLC3 and PLC4). They contain the data do be transferred between CPUs.

Notes:

S7Connections FB

This function block implements and coordinates the calls to PUT/GET instructions.

PUT/GET call

In the PUT/GET instruction call, pay attention to these parameters:

Note: Along with the normal data, a heartbeat is transferred to the partner CPU in the form of a DINT variable incrementing at each second, so that the partner can detect a failure in communication.

The S7Connections FB is called in the Main OB.

S7Connections call

The "S7ConnectionsData".falhaPLCx tags should be used to signal communication error in SCADA/HMI and also take safety action on outputs that depend on data from partner CPUs.

Communication failure detection in server CPUs

Heartbeat signal must be used in the server CPUs to detect communication failure and take safety actions on outputs that depend on data from client CPU.

Heartbeat

Note about inter-CPU communication

PUT/GET communication

This is the modern, simplified approach for S7-1200:

Advantages:

How it works:

Typical use:

TCON/TDISCON/TSEND/TRCV (ISO-on-TCP)

This is the older, more traditional method:

Characteristics:

Modern recommendation

For new projects, Siemens recommends PUT/GET because:

The “safety” in modern implementations comes from the S7 protocol itself (authentication, connection monitoring) rather than from manual connection management. PUT/GET isn’t less safe - it just handles the complexity internally.

References

Histórico

DataDescrição
2025-10-18First version.