Routed S7 communications using the example of ProfinetProfibus in the “thousandth series” of Simatic

S7 connections for many years already. And many people know a lot about him too. And even use a lot. It is very easy to work with them – I created an S7 connection, placed the PUT / GET function blocks (the easiest option) or BSEND / BRECEIVE where necessary, performed the download, and that’s all – a complete preview, just know, control the state of the NDR and Error flags.

Most often, both communication partners are on the same network. But what if the CPUs are in different Profinet networks? Or, even cooler, one exchange participant is connected to some intermediate node via Profinet, and the second one is connected to the same intermediate node via Profibus. For example, like this:

How to organize an exchange between PLC_1 and PLC_2?
How to organize an exchange between PLC_1 and PLC_2?

It is necessary to organize an exchange between PLC_1 and PLC_2. Only … they are not directly connected in any way, but both are connected to PLC_3, but through heterogeneous communication channels. The situation may be different, for example, PLC_2 is connected to the X2 interface of PLC_1, and PLC_3 is connected to the X1 interface of PLC_1, and it is required to organize an exchange between PLC_2 and PLC_3.

The problem is even easier than you might think. There is no need to program the PLC_3 as an exchange intermediate – it is enough to use the S7 packet routing function, which is implicitly present in the TIA Portal: both PG packets and data exchange packets.

Let’s digress for a minute. How does S7 routing work for PG packets (that is, to be able to connect to the PLC by the programmer)? It is enough to create a network configuration of devices and perform a download for each CPU. After that, the routing function works automatically, there is no need to place the PC/PG in the network configuration, as required in the classic Step 7. Suppose the programmer is connected to the PN_IE_1 network (via Industrial Ethernet), and there is a need to connect to the PLC_1. In this case, when going online for diagnostics or download, you must specify the type of PG interface: PN_IE, the network interface of the programmer itself, and as the connection path: network PN/IE_1 (the network to which the programmer is connected).

Connecting to a remote controller via Profibus via Profinet
Connecting to a remote controller via Profibus via Profinet
S7 routing works automatically
S7 routing works automatically

Let’s return to the original task – organizing communication between PLC_1 and PLC_2 via a configured S7 connection using the PUT / GET mechanism (to simplify the task, we only read the data, the rest is a matter of technology).

  1. Open Devices&networks, click connections, select S7 connection

2. Left-click on the PLC_2 interface and drag the line to the X3 (profibus) interface of the PLC_1 controller. Click on “Add S7 routed connection”

3. Enjoy the result on the “Connections” tab

4. In the PLC_1 settings, we allow access using the PUT / GET method

PUT/GET function blocks require additional permission
PUT/GET function blocks require additional permission

5. Create a global standard access data block on PLC_1 (uncheck the Optimized block access checkbox in the DB settings without fail!). In the data block, we create the necessary variables (I created one … there was no point in less)

Standard access only, optimized not allowed
Standard access only, optimized not allowed

6. To make life easier, copy the created DB1 from PLC_1 to PLC_2.

7. In OB1 PLC_2 we create the following ingenious program:

genius program
genius program
Configuration FB Get tab
Configuration FB Get tab

8. We load all PLCs, raise the GET_DB.Req flag for PLC_2, rejoice, satisfied with ourselves, go into the sunset

Controller data block PLC_1
Controller data block PLC_1
OB1 controller PLC_2
OB1 controller PLC_2

Note. An exchange using the PUT / GET mechanism is possible not only for one “atomic” value, but also for data structures too. The maximum allowed data transfer depends on the type of CPU and can be found in the online help for the respective communication program blocks.

The examples discussed above are PG packet routing (to connect the programmer, that is, Step 7) and routed connections to exchange information. There is a third way – routing HMI (OP) connections. We complicate the scheme a little:

In total, we see 3 connections for 4 devices (the question of how much this is game and why it is, remains undisclosed). I draw your attention to the fact that now in order to connect HMI_1 and PLC_3, two router nodes are required. In the general case, it is impossible to display information on one panel from all three devices without additional programming. Using S7 routing – you can. We act in the same way, click on the “Connections” button on the Devices & Networks window, select “HMI Connection”.

We connect HMI_1 and PLC_2, connections are created automatically. We connect HMI_1 and PLC_1, and then PLC_3, in this case the Connect to subnet menu already appears, where we select Add S7 routed connection, in the same way as before.

All connections created

Next, we pull out the tags from all three controllers on the screen, compile, load, and check.

The entire assembly
The entire assembly
The numbers are being updated.
The numbers are being updated.

I draw your attention to the fact that the PG-rooting function has not gone away. Having a physical connection only to the PN_IE_2 network, it remains possible to open online, for example, the PLC_3 controller.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *