Skip to content

Commit

Permalink
mcu: fix endstop probing
Browse files Browse the repository at this point in the history
Account for oversample time when calculating the the
trigger time of an endstop homing/probing event.

Signed-off-by:  Eric Callahan <[email protected]>
  • Loading branch information
Arksine authored and miklschmidt committed Oct 16, 2024
1 parent 0dfb36c commit cb2e8e0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions klippy/mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def __init__(self, mcu, pin_params):
self._home_cmd = self._query_cmd = None
self._mcu.register_config_callback(self._build_config)
self._rest_ticks = 0
self._oversample_ticks = 0
self._dispatch = TriggerDispatch(mcu)
def get_mcu(self):
return self._mcu
Expand Down Expand Up @@ -324,9 +325,11 @@ def home_start(self, print_time, sample_time, sample_count, rest_time,
clock = self._mcu.print_time_to_clock(print_time)
rest_ticks = self._mcu.print_time_to_clock(print_time+rest_time) - clock
self._rest_ticks = rest_ticks
sample_ticks = self._mcu.seconds_to_clock(sample_time)
self._oversample_ticks = sample_ticks * (sample_count - 1)
trigger_completion = self._dispatch.start(print_time)
self._home_cmd.send(
[self._oid, clock, self._mcu.seconds_to_clock(sample_time),
[self._oid, clock, sample_ticks,
sample_count, rest_ticks, triggered ^ self._invert,
self._dispatch.get_oid(), MCU_trsync.REASON_ENDSTOP_HIT],
reqclock=clock)
Expand All @@ -344,7 +347,9 @@ def home_wait(self, home_end_time):
return home_end_time
params = self._query_cmd.send([self._oid])
next_clock = self._mcu.clock32_to_clock64(params['next_clock'])
return self._mcu.clock_to_print_time(next_clock - self._rest_ticks)
return self._mcu.clock_to_print_time(
next_clock - self._rest_ticks + self._oversample_ticks
)
def query_endstop(self, print_time):
clock = self._mcu.print_time_to_clock(print_time)
if self._mcu.is_fileoutput():
Expand Down

0 comments on commit cb2e8e0

Please sign in to comment.