Detailed analysis of Beckhoff EtherCAT communication protocol

  1. Introduction
    1.1 Motion Control
    1.2 Real-Time Ethernet
    1.3 EtherCAT
  2. Introduction to EtherCAT Principles
    2.1 Real-time
    2.2 Port Management
    2.3 EtherCAT Network Topology
    2.4 EtherCAT Network Protocol Stack
    2.5 EtherCAT Data Frame Format
    2.6 EtherCAT Device Addressing Mode
    2.7 Distributed
    Clock 2.8 Application Layer
    2.9 Device Profile )
    2.10 Master station design
    2.11 Slave station design
  3. Application Layer
    3.1
    3.2 EtherCAT Slave Implementation (slave implementation)
  4. Application example
    4.1 Master station operating system (RTAI)
    4.2 Master station EtherCAT program (IGH)
    4.3 Master station application development (LinuxCNC)
    4.4 ET1200
    4.5 Slave station program design
    4.6 Experimental test
  5. Tools
    5.1 TwinCAT
    5.2 LinuxCNC
    5.3 Open Source EtherCAT Master
  6. Introduction
    1.1 Motion Control The motion
    control system deals with the movement on one or more coordinates in the mechanical system and the coordination between movements to achieve precise position control, speed and acceleration control, torque and force control, etc.

Single-axis motion control systems can be divided into open-loop, semi-closed-loop and closed-loop servo systems.

Multi-axis motion control system can be divided into point control, continuous trajectory control and synchronous control.

A typical motion control system, from a structural point of view, includes several parts such as the host computer control window, motion controller, drive, motor, and measurement feedback system: 1.2 Real-time Ethernet Real-time Ethernet (RTE, Real Time Ethernet) is
insert image description here
a
conventional An extension of Ethernet technology to meet the real-time data communication requirements in the field of industrial control. At present, there are many kinds of real-time industrial Ethernet protocols in the world. According to different real-time and cost requirements, different principles can be roughly divided into the following three categories: (1)
insert image description here
Industrial Ethernet based on TCP/IP still uses TCP /IP protocol stack, through the reasonable control of the upper layer to solve the uncertain factors in the communication process. This method has a higher transmission rate, is suitable for a large amount of data communication, and is more suitable for applications as gateways and switching devices, but cannot achieve good real-time performance. Commonly used communication control methods are: reasonable scheduling, reducing the probability of conflict; defining the priority of frame data, assigning the highest priority to real-time data; using switched Ethernet, etc. Typical protocols using this method include Modbus/TCP and Ethernet/IP.
(2) Industrial Ethernet based on Ethernet still uses standard, unmodified Ethernet communication hardware, but does not use TCP/IP to transmit data. It uses specific telegrams for transmission. The TCP/IP protocol stack can use the time control layer to distribute certain time slices to utilize network resources. Such protocols mainly include Ethernet Powerlink, EPA C Ethernet for Plant Automation ), PROFINET IRT, etc. In this way, better real-time performance can be achieved.
(3) The industrial Ethernet realized by modifying the Ethernet protocol realizes the hard real-time response time less than lms, and the slave station uses specific hardware to realize it. The communication in the real-time channel is controlled by the real-time MAC, which fundamentally avoids conflicts between messages. Non-real-time data can still be communicated in the channel according to the original protocol. Typical protocols include Beckhoff's EtherCAT, Siemens' PROFINET IRT, etc.
1.3 EtherCAT
The EtherCAT real-time Ethernet technology developed by German BECKHOFF Automation Company in 2003 broke through the system limitations of other Ethernet solutions: through this technology, there is no need to accept Ethernet data packets, decode them, and then copy the process data to each equipment.

  1. The principle of EtherCAT introduces that
    the EtherCAT slave device reads the corresponding data message when the message passes through its node, and the input data is also inserted into the message when the message passes through. The time delay of the whole process message is only a few nanoseconds, and the real-time performance is greatly improved

As an industrial Ethernet bus, EtherCAT takes full advantage of the full-duplex feature of Ethernet. Using the master-slave communication mode, the master station sends a message to the slave station, and the slave station reads data from it or inserts data into the slave station.

The master station can be realized by using a standard network card,
and the slave station can be realized by using a specific EtherCAT slave station controller ESC (EtherCAT Slave Controller) or FPGA. It
mainly completes the two functions of communication and control applications. The EtherCAT physical layer uses standard Ethernet physical layer devices.

The slave station can directly process the received message, read or insert relevant data, and then send the message to the next EtherCAT slave station. The last EtherCAT slave returns the processed message, which is then sent to the master by the first slave. The entire communication process is charged and operated in full-duplex mode, and the message sent by the TX line is returned to the master station through the RX line:
insert image description here

2.1 Real-
time Calculation of data packet refresh time
The data of all slave stations in the data packet determines the length of the data packet.

The minimum size of an Ethernet data packet is 84 bytes, and if it is less than 84 bytes, 84 bytes will be added. Due to some common overhead in EtherCAT Frame, an 84-byte packet contains a maximum of 18 bytes of process data. Considering that the data packet must go through each slave station twice before returning to the master station, the time for the data packet to transmit twice on the network at a fixed baud rate of 100 Mbps is its bus refresh time.

1. Based on this principle, taking a data packet containing 1000 channels of switching signals as an example, the calculation process is as follows:
Process data length: 1000/8=125Bytes
data packet length: 84-18+125=191Bytes=191*8 Bit= 1528 Bit
bus refresh time: (1528Bit/100,000,000 Bps)*2=15.28us * 2 = 30.56us
Note that the usual digital modules are pure output or input modules, not hybrid modules. So for 1000 digital signals, 125 bytes will be allocated in Frame.

2. Taking the EtherCAT data packet containing 100 EtherCAT servo drive process data as an example, if the process data of each servo only includes control word (2 bytes), status word (2 bytes), target position (4 bytes ), the actual position (4 bytes), the calculation process of the bus refresh time is as follows:

Process data length: 100*(2+4)=600 Byte.
Data packet length: 84-18+600=1266 Byte =671*8 Bit =5328 Bit
Bus refresh time: (5328 Bit/100,000,000 Bps) *2=100.656µs
1
2
3
Note that only 6 bits are allocated for one servo in Frame This is because according to the default setting of EtherCAT in the control software TwinCAT of Beckhoff Company, the Input and Output of the slave station use the same data segment, so when the data packet enters the servo drive, the data segment stores the control word and the target position , and when it comes out, it stores the status word and actual position of the servo.

The above two data of 30.56µs and 101.28µs are the origin of the data in the official EtherCAT promotional materials that it takes 30µs to refresh 1000 digital quantities, and only 100µs to refresh 100 servo axes. In fact, depending on the type of slave station, whether it contains distributed clocks, whether clock synchronization is enabled, and the parameter settings of clock synchronization are different, 8-12 bytes may be added to the data packet to transmit the synchronization clock value, and the corresponding Adding a Bit mark for each slave station, etc., will add a few microseconds to the refresh time, which is ignored for now.

The above calculation is only the theoretical time required for data packet transmission. In fact, there will be a short hardware delay when the data packet passes through each slave station. The delay of the slave station of the 100M super five network cable interface is about 1µs, while the delay of the EBus IO module slave station is about 0.3µs. If there are many slave stations in the control task below the millisecond level, this time is also considerable. Calculate The refresh cycle should be taken into account.

2.2 Port management
A slave controller can have up to 4 ports, if a port is closed, the controller will actively connect to the next port. Ports can be actively opened or closed with EtherCAT commands. Logical port settings determine the order in which EtherCAT frames are processed and sent.
insert image description here
insert image description here
insert image description here
insert image description here
2.3 EtherCAT network topology
All data frames propagate in the network in a "logical closed-loop" manner, regardless of the hardware topology of the network, whether it is a chain, daisy chain, star or tree topology.
insert image description here
All data frames are sent by the Master, and pass through all slave stations on the network in sequence in a strictly defined order beforehand, and return to the Master after going through a complete closed loop.
All data frames pass through the EtherCAT Processing Unit (EtherCAT Processing Unit) in the slave only once.

Line topology:
any number of devices connected in a line up to
65535 devices
——————————————— Copyright statement: This article is an original article of CSDN blogger "pwl999", following the CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement for reprinting .  Original link: https://blog.csdn.net/pwl999/article/details/109397700
Data processing chain topology
insert image description here
Data processing chain topology with branch lines
insert image description here
Tree topology:
insert image description here
real-time star topology:
insert image description here
redundant cable
insert image description here
selection redundant cables can meet Rapidly increasing system reliability requirements to ensure that the network will not be paralyzed when equipment is replaced. You can economically add redundancy by simply adding a standard Ethernet port on the master device side (no dedicated network card or interface required), and changing a single cable from a bus topology to a ring topology. Yes (see Figure 7). When a device or cable fails, it only takes one cycle to complete the switchover. Therefore, even for applications with motion control requirements, there will be no problem if the cable fails.

EtherCAT also supports hot backup master redundancy. Since the EtherCAT slave station controller chip will automatically return the data frame immediately when the loop is interrupted, the failure of one device will not lead to the paralysis of the entire network. For example, e-chain equipment can be configured as a branch topology in case cables are disconnected.
2.4 EtherCAT network protocol stack
insert image description here
insert image description here
CoE (Can over EtherCAT)
PDO (Process Data Object process data object)
SDO (Service Data Object service data object)
PDI (Process Data Interface process data interface) (uC, SSI, I/O)
1
2
3
4
ESM (EtherCAT State Machine)
ESI (EtherCAT Slave Information) (XML device description)
ENI (EtherCAT Network Information)
CTT (Conformance Test Tool Conformance Test Tool)
SM (SyncManagers Synchronization Manager)
MDP (modular device description Modular device description )
1
2
3
4
5
6
2.5 EtherCAT data frame format
EtherCAT data is directly embedded in the Ethernet data frame for transmission, but a special frame type is used, which is Ox88A4. The structure of the EtherCAT data frame is shown in the figure: EtherCAT data packet consists of two parts: data header and data entity
insert image description here
. The EtherCAT data header contains 2 bytes, and each data packet can contain only one EtherCAT sub-message, or multiple sub-messages; one EtherCAT sub-message corresponds to a slave station, so one EtherCAT data packet can operate
multiple One EtherCAT slave station, the corresponding data length is between 44-1498 bytes, and the EtherCAT data frame structure definition:

Guess you like

Origin blog.csdn.net/weixin_41883890/article/details/125167723