This article describes how to build EtherCAT communication with the Beckhoff TwinCAT3 and the Keyence KV-XLE02 Communication Unit. Note that the KV-XLE02 operates as an EtherCAT Slave.
Let’s Start!
EtherCAT?
EtherCAT is an Ethernet-based real-time fieldbus developed by the German company BECKHOFF, which is based on Ethernet and therefore allows the use of common Ethernet cables when building networks.
The KV-XLE02 operates as an EtherCAT slave and supports data communication via Process Data object communication (cyclic I/O) and Mailbox communication. Data is exchanged using a port called Sync Manager.
Object dictionary
The object dictionary is an information table for communication between the application and communication part in an EtherCAT device. Inside it, the information handled by the EtherCAT device is described.The individual pieces of information are called Objects.
It is possible to use Process Data Object communication to read and write process data in the CoE communication area of the relevant Object and to use Mailbox communication to read and write parameters in the manufacturer-specific area of the relevant Object.
Process data object communication function
Sync manager2 and Sync manager3 are used for the PDO communication function. Their communication function enables cyclic (I/O) communication between master and slave.
Communication is carried out by allocating parts of the data placed in the Object dictionary to Process Data Objects.There are two types of Process Data Objects.
- RxPDO transmitting data from master to slave
- TxPDO transmitting data from slave to master
Mailbox communication (Server) function
The Mailbox communication function is used for data communication at times other than Process Data Object communication and is managed by 0s and 1s in the Sync Manager. This communication function is used to communicate while taking a handshake. In addition, communication of all data placed in the object dictionary is possible.
What is DC (Distributed Clock)
DC (Distributed Clock) is a unique feature of EtherCAT that provides high-precision time synchronization, and the KV-XLE02 supports DC. The time synchronization function enables the EtherCAT master and each slave to synchronize their operation timings to the synchronized time.
Wiring for EtherCAT Network
The EtherCAT communication functionality of the KV-XLE02 supports both ring and line network topologies. It should be noted that even when connecting to an EtherCAT master device in one-to-one line fashion (EtherCAT communication on port 1 only), the EtherCAT communication function occupies both port 1 and port 2, so general Ethernet cannot also be used on port 2! Port 2 is not used for EtherCAT communication.
Cable connection method
IN Port (PORT1)
Input port for EtherCAT communication. It must be connected to the OUT port of another EtherCAT device. If you connect to the IN port of another EtherCAT device, the communication will not work properly.
OUT Port (PORT2)
Output port for EtherCAT communication. It must be connected to the IN port of another EtherCAT device. If it is connected to the OUT port of another EtherCAT device, the communication will not work properly.
Download ESI File
Download the ESI File for KV-XLE02 from the link below.
https://www.keyence.co.jp/search/all/?q=KV-XLE02%20ESI
Implementation
Keyence Side
The first step is to build the keyence side.
Unit Configuration
Launch KV Studio and click Unit configuration>KV-8000 to open the Hardware Configuration setting window.
Add KV-XLE02
Add KV-XLE02 to Hardware Configuration on the Select Unit screen to the right.
Setup unit
Next, open the Setup unit Tab and change the settings for KV-XLE02.
Base
The Base setting sets the device that controls the status and control of the KV-XLE02 main unit.
Port1/Port2 Settings
In this article, we will connect to Beckhoff TwinCAT3 as EtherCAT Slave, so we set the Industrial Ethernet in Port1 settings and Port2 settings to “EtherCAT(Slave) )” in Port1 settings and Port2 settings.
EtherCAT Slave Settings
Dsiable for ExplictDeviceID.
Refresh setting
Open the Refresh setting tab and set the data size and the first device to be exchanged with the Beckhoff TwinCAT3. In this example, Input and Output are also set to 16 words.
Program
Create a simple data verification program in the User program.
Download
The last step is to download the project to KV8000.
TwinCAT3 Side
The next step is to build TwinCAT3 Side.
Install ESI File
ESI File downloaded from Keyence HP is stored in the following Link.
C:\TwinCAT\3.1\Config\Io\EtherCAT
Add EtherCAT Master
Create a TwinCAT3 project and add a new communication Driver at I/O>Devices>Add New Item.
Select EtherCAT>EtherCAT Master and proceed with Ok.
Let’s configure the Ethernet Adapter to be used as EtherCAT Master in TwinCAT3 this time.
Scan Network
This time we will scan the EtherCAT Slave using TwinCAT3’s Slave auto-detection feature: Device>Right click>Scan.
Done!KV-XLE02 is found.
Configuration
The next step is to configure the KV-XLE02.
Process Data
Open the Tab in Proess Data and set the PDOs to be exchanged between KV-XLE02 and TwinCAT3.
Outputs
Click on Outputs, and check 0x1600 (in this case, there are 16 words of output data).
Inputs
Click on Inputs and put 0x1A00 in Check (in this case, there are 16 words of input data).
Add PLC
Next, to add a PLC, click PLC>Add New Item.
Select Standard PLC Project > Add to add a PLC.
Add GVL
Now click GVL>Add>Global Variable List to add a GVL.
Enter a GVL name.
Define Process Input/Process Output variables for Mapping with KV-XLE02.
Program
The last step is to create a simple program.
Build
Before Mapping, compile the project at Build>Build Solution.
Input Mapping
To map with the input data, right-click > Change Multi Link with all the variables you just added selected.
Let’s link with the Input Process Data defined earlier in GVL.
Output Mapping
The output should be linked using the same operation.
Activate Configuration
Finally, click Activate Configuration to Download the project to TwinCAT3 Runtime.
Proceed with Ok.
Click OK and change TwinCAT Runtime to Run Mode.
Login
Login.
Result
Finally, check the communication status of KV-XLE02.
When you open the Online Tab, the State Machine is in the OP state.
This means that KV-XLE02 is currently in a normal state.
The TwinCAT3 side also received the data output by KV-XLE02.
The TwinCAT3 side also did the same, and KV-XLE02 received the output data.
Now, to check the Unit status, right-click on KV-XLE02>Unit Monitor.
You can check the current operating status of KV-XLE02.
Click on Communication Monitor.
The Communication Monitor screen appears.
From the Drop-List, you can only select the communication mode that KV-XLE02 is currently set to, so this time it is EtherCAT (Slave).
Done!I can confirm that it is currently in OP status.