[technology] high performance EtherCAT master station scheme based on Xilinx FPGA board
Technical background
EtherCAT is an open real-time Ethernet communication protocol, which was developed by German Beifu Automation Co., Ltd. EtherCAT has the characteristics of high performance, low cost and easy to use. At present, it is widely used in the industrial field.
Zcu102 evaluation suite can help designers quickly start the design for automotive, industrial, video and communication applications. The suite has zynq based on Xilinx 16nm finfet+ programmable logic architecture ? UltraScale+ ? MPSoC device, providing a quad core arm ? Cortex ?- A53, dual core cortex-r5f real-time processor and a Mali ?- 400 MP2 image processing unit. Zcu102 supports all main peripherals and interfaces that can realize various application development.
KPa EtherCAT master station is a set of EtherCAT protocol stack with stable quality, high popularity and high cost performance, which has great reference value. This paper will introduce the transplantation and testing of kPa EtherCAT master station on zcu102 platform.
Introduction to kPa EtherCAT
EtherCAT (Ethernet control automation technology) is a high-performance industrial communication protocol for deterministic Ethernet. It extends the IEEE 802.3 Ethernet standard, making data transmission predictable timing and high-precision synchronization. As an integral part of IEC 61158, this open standard is often used in mechanical design, motion control and other applications.
01
Introduction to kPa EtherCAT master station software
According to different functions, kPa EtherCAT master station software provides four versions of master station protocol stacks: basic, standard, premium and extension. Therefore, in addition to supporting etg1500 to define two master station types: Class A and class B, kPa also supports some extended functions, such as data- and frame logger (recording data and messages), access rights (setting different access permissions), multi master (multi master, redundancy) Cable redundancy, hot connect, others.
It provides ready-made development packages based on a variety of different hardware platforms and OS, supports mainstream hardware platforms such as SOC (arm+fpga) /arm/x86 /powerpc, and supports Linux (xenomai / RT preempt) / windows (intime / RTX) / qnx/ ucos/ VxWorks, etc. A master station scheme that meets the development requirements of almost all users' master stations at present.
The kPa master station protocol stack adopts a modular architecture, which can realize each special project application. It allows the master station to expand freely to adapt to different sizes of applications, different operating systems and various hardware platforms. Each module can be customized or redeveloped separately without destroying the integrity of other modules. The main station structure is shown in the following figure:The main functional modules of kPa are:
(1) Application layer: the application layer is responsible for interacting with different programming / configuration environments and with different applications or devices. Ensure the smooth access to the master station function at the application or process task end; It interacts with the master through the remote procedure calls service, providing tcp/ip and UDP connections, such as mailbox related communication with the slave device through UDP.
(2) Mailbox module: the core mailbox module of EtherCAT master station uses different protocols to process service data objects (SDP), data transmission and data exchange. Support Coe, foe, EOE, SOE, VOE, AOE and other email services.
(3) Process image module: process image is abbreviated as pi. Its address is proposed by EtherCAT network information (Eni) file, which can be automatically generated by configuration tool kPa studio. Accessing process images from control / process tasks is performed by the master interface.
(4) Distribution clock module: enables all EtherCAT devices (including master station and slave station) to always share the same EtherCAT system time. This is achieved by compensating compilation and drift time.
(5) Frame schedule module: different PDOS adopt different scanning cycles. In the configuration tool kPa studio, the user can define the scanning rate of each slave station separately. The frame scheduling table module manages the EtherCAT frame rates and forwards them to the EtherCAT network driver.
(6) Osal operating system abstract layer module: contains the packaging of function functions related to the operating system, such as processing threads, timers, mutexes, etc; Including the network adaptation driver module: extract the core of the master stack from the underlying network implementation.
02
KPa EtherCAT master master redundancy technology
Unlike other industrial interfaces based on Ethernet, EtherCAT uses hop to hop communication protocol: data packets are common to all slave devices connected to the bus, and it passes from one device to another. The master station is the manager, which circularly creates data packets with read or write requests, inputs and outputs them, and sends them to the bus at strict intervals. Each slave device can insert (write) or extract (read) data blocks explicitly addressed to it.
This function was originally designed to make effective use of bus throughput, but it is also very useful for fault tolerance: any device connected to the bus is fully aware of the activities of all slaves, and can transparently obtain or sniff the data transmitted between the bus master and slave. Users do not need to modify any slave equipment, add any other signals or change the transmission protocol, and this function will not increase any cost (except for the more intelligent master equipment).
KPa EtherCAT master uses this edge effect to introduce another bus master (or multiple masters) into the bus. During normal operation, this redundant master station is passive and can sniff data but cannot input its own messages. The passive master is considered secondary, while the active master is considered primary. Since all secondary master stations are consistent with bus activity, they can replace the primary master station at any time when the latter fails.In addition, in order to detect abnormal conditions on the bus, the auxiliary master station may not need any special control equipment or additional signal lines. EtherCAT messages are carried out regularly and strictly at time intervals. When an auxiliary passive master station does not receive the expected message, it knows that there is no master station on the bus. The redundant master station can take over control immediately and send its own message without waiting until the end of the current cycle. This message will be correct and meaningful, because the auxiliary master station is tracking all changes and becoming the replacement of the faulty master station.
EtherCAT configurations that enable master redundancy include an active (Master) master and one or more passive (auxiliary) Masters. The main equipment may not be configured as master redundancy, but it is best to use kPa EtherCAT master software to maximize the effectiveness of this technology. The secondary master is connected to the bus as a shadow agent. It sniffs the data packets in transmission without any change. At the same time, the master station calculates the arrival time of each telegram and tracks the possible delay between the expected and actual arrival time.
03
Introduction to kPa EtherCAT master station hardware
The hardware of the master station mainly consists of three parts, as shown in the following figure: zcu102 master station development board and expanded FMC network card. KPa MAC IPCore builds an FPGA network card on the PL side. The FreeRTOS master can run in both R5 CPU and A53 CPU. In addition, a PC is required to input operating system instructions through a serial port terminal. The EtherCAT network diagnosis configuration tool kPa EtherCAT studio on the PC side connects the zcu102 master board through RPC services, which can realize the configuration of master and slave stations, scan and generate network configuration files.
KPa EtherCAT master station migration
Hardware development board
Xilinx HW-Z1-ZCU102 revision1.1
EtherCAT master station software development package
MDK_ xilinx-2018.3_ freertos_ a53_ trial_ v2.4.48714.0-release. zip
HW_ SAMPLE_ xilinx-2018.3_ freertos_ a53_ trial_ v2.4.48714.0-release. zip
Software compilation
Set MDK_ xilinx-2018.3_ freertos_ a53_ trial_ v2.4.48714.0-release. Zip extract to MDK_ Under folder A53
Enter \mdk_ A53 \ modify the corresponding sample program under the path of samples. Here, each different sample program contains different APIs and has different functions. Here, 24_ Taking driverotationcia402 as an example, this is a sample program that simply runs single axis servo. In order to adapt to Maixin servo driver, it is necessary to keep the description in C file consistent with that in Eni file, and save it after modification
Enter \mdk_ A53, open build Bat, modify the compiler path, which is the Xilinx SDK installation path
Run CMD, enter this path, and run build Bat, compile all sample codes, including 24 samples, and generate 24 samples under the \build\samples path_ DriveRotationCiA402. ELF file
Create a running program
Enter MDK_ A53\external\boot path, according to the readme file and 24_ DriveRotationCiA402. BIF file;
Copy zcu102_ Design generated by vivado project in FreeRTOS_ 1_ wrapper. Bit file to this path, overwriting the original bit file;
Copy zcu102_ freertos\project_ 1\project_ 1. Fsbl under sdk\fsbl\release Elf to this path, overwriting the original fsbl ELF file;
Copy 24 generated under the path \build\samples_ DriveRotationCiA402. Elf to this path;
Copy the generated Eni file (master.xml) to this path
Open Xilinx xsct tool, enter the \externals\boot path, and generate boot bin
Boot Copy the bin file to the SD card, set the development board, start the SD card, and run on power
Master station performance data
Network configuration: Beckhoff ek1100+el1004+el2004+el6692 (60 bytes frame).
Test data running on R5 CP (X32):
Test data running on A53 CPU (x64):
Performance analysis method of third-party packet capturing tools
Generally, EtherCAT master station performance test will pay attention to the master station communication cycle, whether the cycle time is stable, and how much jitter. Therefore, it can be set to test jitter under different cycle times, such as 2ms, 1ms, 500us, 250us, 125us, etc. it can use a third-party grab tool +wireshark for message analysis. For different master station cycles, it is necessary to modify the code and the cycle time of Eni file. Here, 1ms master station cycle is used, The mailbox task cycle is 5ms (5 times of the master station cycle).
Conduct targeted analysis on Wireshark packets, and set the time display format as follows
Use ecat ADO = = 0x130 command, filter out the message at which the slave station enters the op state. Here it is 33900, which means that the message before 33900 cannot be used to analyze the cycle time, because PDO data / periodic data is sent only after the slave station enters the Op.
Analyze the periodic message and note that each periodic message contains three sub messages (logical addressing) and a DC related armw command
Filter out periodic messages and use the instruction ecat sub1.cmd == LRD && ecat. Sub1.cnt = = 0, filter out the periodic messages whose sub message 1 is LRD and the calculator value is 0 (indicating that it is sent from the master station and does not pass through the slave station). Select triangle to sort the messages, which can be from small to large, or from large to small. The minimum cycle is 999.496us.
