Example FB14-15 SFB14-15 GET-PUT

In response to a question from a colleague, I will carry out the following practice, which involves exchanging data between two CPU 300 with PN port, using the FB14 GET and FB15 PUT functions. Since these cannot be simulated in PLCSIM, I will replace them with SFB14-15, which serve the same purpose and can be executed in PLCSIM. We start with a project that has our two CPUs configured with an IP address in the same range and on the same subnet.

The first thing we do is run Netpro to create a new link between the two devices, which we can do by inserting -> new link.

Following the wizard, we select PLC_2 and a link of type S7 Link, accept, and the next window shows the link between the two devices. We need to keep in mind that we will need to know the local ID for our SFB block.

Upon confirmation, we can see that the link has been created; we just need to compile and save. Once this is done, we move on to programming.

The exercise consists of the following: PLC_1 will read and write data in PLC_2, specifically in DB1, which is an array of 10 of type word. Both PLC_1 and PLC_2 have the same DB1, but when we configure ADDR_1 in our SFB14, it points to the first memory address of the data we want to read and its length. For this, we use pointer format as observed, and the data read from PLC_2 is stored in DB1 of PLC_1 starting from the memory address specified in RD_1, and this will occur on a positive edge detected in REQ. ID refers to the ID when the link was configured, the NDR bit indicates the operation status, and any failure is recorded in the ERROR bit and its code in STATUS.

The parameterization of SFB15 is exactly the same, except that in SD_1 are the data we are going to write.

The example program would look as can be seen, except that SFB15 and DB15 are missing in PLC_1 to write to PLC_2.

Taking advantage of the functionality of PLCSIM, we open two instances and load both programs in their respective.

We use the variable table of PLC_2 to change the data in our DB1 since in this PLC we do not need anything else to verify functionality.

At the same time, we have executed PLC_1 and with PLCSIM we force the input E0.0, causing REQ to detect a positive edge and execute the GET function. To verify, we open DB1 and observe that the data has been read correctly.

March 17, 2013