Beckhoff EAP communication

Communicating between Beckhoff controllers part 1: EAP

As communicating between different controllers would be necessary for some projects, we found it beneficial and pragmatic to discuss the available methods/protocols for communicating and exchanging variables between controllers within the TwinCAT environment. In this posts we are going to describe the implementing each of the below protocols in a simple Step by step illustrative method. The communication options we will discuss are:

  1. EAP (EtherCAT Automation Protocol)
  2. ADS Communication
  3. OPC UA

Part 1 EAP

The TwinCAT EAP device enables data transfer from any variables, which might be called process variables (PV), from a TwinCAT controller A to a TwinCAT controller B, via a standard network adapter, which is supported by the TwinCAT real-time Ethernet driver. The communication is based on the Publisher/Subscriber principle. The senders referred to as Publishers. On the other side, there are receivers, referred to as Subscribers. The publisher sends messages to all or several network devices without knowing which one is the receiver (if any). on the other side, there are receivers which are interested in certain messages and receive them without being aware of the publisher. please note that a controller has the ability to publish and subscribe at the same time.

Here for a better understanding of the implementation procedure, as a test setup, we are going to set up communication between a CX5010 as a publisher device and C6015 IPC as a subscriber device. we are going to publish an Integer variable which is changing its value in each second. The principle and the method can be applied to larger numbers of variables in different types.

As you can see in the below picture, the CX5010 and C6015 are connected via Ethernet Cable/Switch. The engineering PC (laptop) is also connected to the switch for configuration.

Add an EAP device

We start by CX5010. After creating a new program, An EtherCAT Automation Protocol device can be added via the path [I/O] → [Devices] → [Add New Item…] and from the Insert Device dialog (as shown in below picture)

Then a dialog appears in which we need to select the appropriate network adapter (see below)

The EAP device is visible with the designation Device 1. Here we need to choose PCI\TCI8254x2, as the Ethernet cable is connected to the upper port which is port number 2 in CX controllers.

Add the publisher variables

We need a publisher to send variable via EAP device. It can be done via path [I/O] → [Devices] →[Device 1 (EtherCAT Automation Protocol)] → [Add New Item…]

Then on the dialog Select the Network Variable Publisher and click on [OK]. We can select more than one publisher as well.

We can rename the publisher like the other TwinCAT contexts.

Now, we need to create Publisher Variables (TxData). with a same procedure, and by right-clicking on the context menu of the publisher, we can select a new item, and then on the “insert network variable” dialog, we need to select the type of variable, a Name, and ID. Here we select integer type variable with the TwinCAT recommended name and ID.

You can see the overall configuration of the EAP device in the below picture. It has both Input and Output variables but its Output variable (VarData) is the variable that on one hand, we can link to a PLC variable and on the other hand, can be Subscribed/received by subscribers.

Now, our publisher is ready. We need to make a PLC variable and small program to change the variable. We created the “Status” as a variable to be published and within these codes, in the MAIN program, the value would be increased in each second.

PROGRAM MAIN
VAR
    Status AT %Q* : INT;
    ton : ton;
    m : INT;
END_VAR
CASE m OF
    0:
    ton(IN:=TRUE , PT:= T#1S );
    IF ton.Q THEN
        m:=1;
        ton(IN:= FALSE);
    END_IF
    1:
    Status := Status +1;
    m:=0;
END_CASE

Now, we can link the “Status” variable in our PLC into VarState of EAP device (like normal linking of a variable into I/O). Therefore the publishing side (PLC1) of our project is ready.

Setup the subscriber

By creating a new program and selecting our IPC (C6015) as the target, we can create the subscriber for our project. But before that, we have an important task to do.  we need to make a route between two controllers. within the recent program which is created for the second controller (C6015 IPC), we can Browse, choose, and add a route to the first controller (CX5010). The route is necessary for having communication between controllers.

The procedure creating a Subscriber is similar to creating Publisher. Here also we need to add an EAP device and by right-clicking on the EAP device and selecting “add new item”, this time we can create a Subscriber.

Then, the subscriber variable needs to be imported or define. We can open “Import Network Variable” dialog by right-clicking on the subscriber context menu and clicking  “Add New Item”. By Clicking the “Browse for computer…” icon, we can select CX5010 PLC within the target lists.

Then, all of the published variables by the controller would be listed on the dialog.

If we select one of the available variables and confirm (OK), it would be added as a Subscribed variable (see below).

Pub-State_Of_PLC1 is the variable which we have subscribed to it and it is published by CX5010 PLC. If we have proper communication between the controllers we can see/link the online value of the published variable by checking online value or linking the “VarData” which is listed within the input variables.

After activating the configuration of both programs, and by going online into both controllers, you should be able to see that any change of the published variable in publisher controller (in our test CX5010 PLC) would be visible in the Subscribed variable in the subscribed controller ( in our test C6015 IPC). in the below picture you can see our published variable online value in both controllers is the same.

Conclusion

In this post we showed an step by step tutorial for setting up the EAP communication protocol for ease communication between Beckhoff controllers. For more information have a look at the official Beckhoff documation as well. In the next post we will discuss another communication protocol : ADS