From 640ff1ad566361f5a57c4827aa0185be958933af Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 5 May 2018 20:14:46 -0400 Subject: [PATCH] clocksync: Change timer frequency to avoid resonating with other timers If the clock querying messages occur at a similar frequency to other events on the micro-controller or host, then it's possible for the load created by those other events to skew the clock synchronization. In particular, the 500ms lcd screen update could resonate with the 1 second clock query. Use an unusual clock querying frequency to avoid this issue. Signed-off-by: Kevin O'Connor --- klippy/clocksync.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/klippy/clocksync.py b/klippy/clocksync.py index d572c386..caea39dc 100644 --- a/klippy/clocksync.py +++ b/klippy/clocksync.py @@ -54,10 +54,12 @@ class ClockSync: if pace: freq = self.mcu_freq serial.set_clock_est(freq, self.reactor.monotonic(), 0) - # MCU clock querying (status callback invoked from background thread) + # MCU clock querying (_handle_status is invoked from background thread) def _status_event(self, eventtime): self.status_cmd.send() - return eventtime + 1.0 + # Use an unusual time for the next event so status messages + # don't resonate with other periodic events. + return eventtime + .9839 def _handle_status(self, params): # Extend clock to 64bit last_clock = self.last_clock