The invention discloses a
master station-terminal module distributed
clock synchronization method based on PID closed-
loop control, and belongs to the technical field of industrial
automatic control clock synchronization. Comprising the following steps: S1,
synchronizing clocks of a
master station and a slave
station by measuring and compensating network
transmission delay and node
crystal oscillator deviation, and establishing a
system time reference; s2, the slave
station periodically sends a data frame with a
timestamp T1 to the terminal module through a
bus by taking the
Sync0
signal as a reference; s3, the terminal module records local time T2 while receiving the data frame, compares the local time T2 with the
timestamp T1 in the frame, and calculates
clock skew; s4, the terminal module selects PID parameters according to the deviation, and a local clock is adjusted in a closed-loop mode to enable the clock deviation to approach zero; and S5, repeating the process in each communication period, and keeping all the terminal modules consistent with the
master station for a long time through continuous iteration. And a
Sync0
signal is used as a time reference and extends to an RS485
bus, and
microsecond-level
clock synchronization of a terminal module and a master
station is realized through a three-level synchronization architecture, so that the requirements of scenes such as multi-axis
servo control and high-speed
data acquisition on high-precision time consistency are met.