The invention discloses a task synchronization and scheduling method for compensating
CAN bus clock drift, which relates to the technical field of industrial
automation control, and comprises the following four steps: initializing a
system, loading a real-
time protocol stack, completing hardware self-inspection and
clock calibration, and sending a ready
signal after confirming that a link is smooth; performing synchronization parameter configuration and task planning, defining
clock synchronization reference parameters, dividing four types of tasks and setting priorities; performing dynamic calibration and data buffering on master and slave clocks,
broadcasting a synchronous message with a
timestamp by a
master station, correcting a local
timer by a slave
station through a soft phase-locked loop, and constructing an annular buffer area to realize
time domain decoupling; task cooperative scheduling and abnormal
fault tolerance are carried out, a control task is triggered based on a calibration clock, edge calculation is carried out to reconstruct a motion state and feed-forward compensation is carried out, a multi-dimensional state is monitored in real time, and a
fault tolerance mechanism is triggered. According to the method,
clock synchronization precision and control stability are greatly improved,
bus bandwidth limitation is broken through, high dynamic tracking precision is achieved, and long-term stable operation of the
system is guaranteed.