| With the rapid development of industrial automation,the response time and synchronization performance of traditional fieldbus have been unable to meet the needs of the current manufacturing industry.As the representative of real-time industrial Ethernet,the EtherCAT(Ethernet for Control Automation Technology)protocol is favored by the majority of automation equipment manufacturers,experts and scholars due to its advantages of low latency and high synchronization.However,at present,the construction of domestic EtherCAT slave stations mostly relies on foreign dedicated slave station controller chips or IP(Intellectual Property)cores,and the development of domestic EtherCAT slave station controllers is relatively weak.Therefore,there is great significance to study the EtherCAT slave controller for the development of our country’s industrial automation.This article first analyzes the EtherCAT protocol in detail,and then designs an EtherCAT slave controller according to the requirements of the protocol.It has 8-channel FMMU(Field Memory Management Units)and 8-channel Sync Manager,supports 64-bit distributed clock,and the physical layer interface supports Ethernet and EBUS,application layer interface supports SPI Slave,8/16-bit synchronous/asynchronous Local Bus.According to the processing sequence of the data frame,the receiving and automatic forwarding of the data frame is realized first,and then the parsing of the data frame is completed,and the commands and data of the datagrame are extracted.The algorithm of bit-wise mapping from logical space to physical space and the buffer allocation and redirection algorithm for maintaining the data consistency between the master and slave microcontrollers are implemented.According to different addressing modes,the exchange of datagrame data and slave data is completed,and the interrupt signal in the communication process and the interface for communication with the microcontroller are designed.Based on the clock drift compensation method proposed by the EtherCAT protocol,the frequency for compensating for drift is improved,so that the synchronization of the slave station time is more accurate.Finally,the verification platform whitch depend on the Twin CAT master station with the slave station constructed by FPGA(Field Programmable Gate Array)and STM32 is built to verify the design,and the conformance test tool of the EtherCAT association is used to test the design.The verification results show that the timing of the design is closed at the operating frequency of 100 M.The built-in slave description file SSC-DEVICE of Twinc CAT is used to test all process data communication and Co E(CANopen over EtherCAT)mailbox data communication.The function is normal,the slave state jumps correctly,and the synchronization error of the distribution clock is within 100 ns,and it has passed the conformance test,meeting the requirements of the EtherCAT system for the slave control chip. |