Distributed systems are widely used in various communication,measurement and control and detection systems.With the expansion of application fields,the requirements for clock synchronization accuracy of distributed systems in engineering applications are increasing.The traditional NTP is simple to implement,but the synchronization accuracy is only milliseconds.Satellite timing technology can achieve high-precision synchronization,but the implementation cost is expensive and the installation of equipment is restricted by the environment.The IEEE1588 protocol is the mainstream clock synchronization protocol in distributed systems due to its good versatility and high cost performance.However,the protocol only specifies the basic clock synchronization algorithm.In some time-sensitive networks,the system’s requirements for synchronization accuracy are often not met.To this end,this article deeply researches the synchronization principle of IEEE1588 protocol,analyzes the source of synchronization error,and proposes an improved clock synchronization algorithm.The clock synchronization technology is realized by pure software and software and hardware coordination methods,reaching the order of microseconds and nanoseconds.The clock synchronization accuracy of the order of magnitude,the specific work is as follows.First of all,in the pure software implementation method,a corresponding mathematical analysis model is established for the clock synchronization error caused by the jitter delay when the message is transmitted between the protocol stacks,the CPU interrupt processing delay,and the frequency drift of the crystal oscillator.A fuzzy adaptive PI clock synchronization error correction algorithm based on Kalman filter is proposed.Experimental results show that the algorithm uses the Kalman filter to obtain the estimated value of the clock deviation and compensates for the deviation by introducing a fuzzy adaptive PI controller,which can effectively suppress the clock synchronization error and make the clock synchronization accuracy reach the microsecond level,while improving the response speed of the slave clock.Secondly,in order to further improve the accuracy of clock synchronization,the FPGA+ARM software and hardware cooperative implementation method is used to stamp and obtain the time stamp information at the GMII interface to shield the jitter delay of the protocol stack.Through the analysis of the protocol synchronization model,a real-time clock adjustment module of the slave clock is designed,and a high-precision tunable clock is realized through FPGA.At the same time,a device driver is developed in the system driver layer to ensure the normal operation of the synchronization system.Finally,based on the coordination of software and hardware to achieve clock synchronization,the clock synchronization error caused by the asymmetry of message transmission delay is studied.Through research,a secondary filtering algorithm for screening non-normal data packets is proposed.By using an oscilloscope to observe the deviation of the second pulse signal of the master and slave clocks,various indicators are statistically analyzed.Experimental results show that this method can effectively suppress synchronization errors caused by transmission delays,achieve nanosecond clock synchronization accuracy,and meet the requirements of smart substations and 5G services for clock synchronization accuracy.It has strong engineering application prospects.Aiming at the factors that affect the accuracy of clock synchronization in the actual environment,this paper proposes to use pure software and hardware and software to complete the clock synchronization technology.This method has important theoretical significance and practical application value. |