diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-12-20 14:11:38 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-12-20 14:41:20 -0500 |
commit | 1d21bf66c605d114055e50d715e2dcbe2ddfd86a (patch) | |
tree | 6ef44bf18778d30ffeedec86f6e36cd01d737588 /klippy/homing.py | |
parent | 1b0750597312625c23e3389226e418dda1373df2 (diff) | |
download | kutter-1d21bf66c605d114055e50d715e2dcbe2ddfd86a.tar.gz kutter-1d21bf66c605d114055e50d715e2dcbe2ddfd86a.tar.xz kutter-1d21bf66c605d114055e50d715e2dcbe2ddfd86a.zip |
homing: Handle speed rounding when homing speed greater than max_velocity
Commit 002dc0df added rounding to the homing speed, but it did not
work if the configured homing speed was less than the printer's
maximum velocity. Move the speed rounding from stepper.py to
homing.py and make sure the rounded speed is less than the maximum
speed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/homing.py')
-rw-r--r-- | klippy/homing.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/klippy/homing.py b/klippy/homing.py index 9f56a6e9..3a926083 100644 --- a/klippy/homing.py +++ b/klippy/homing.py @@ -3,7 +3,7 @@ # Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net> # # This file may be distributed under the terms of the GNU GPLv3 license. -import logging +import logging, math HOMING_STEP_DELAY = 0.00000025 ENDSTOP_SAMPLE_TIME = .000015 @@ -31,6 +31,15 @@ class Homing: self.toolhead.move(self._fill_coord(newpos), speed) def set_homed_position(self, pos): self.toolhead.set_position(self._fill_coord(pos)) + def _get_homing_speed(self, speed, endstops): + # Round the requested homing speed so that it is an even + # number of ticks per step. + speed = min(speed, self.toolhead.get_max_velocity()[0]) + mcu_stepper = endstops[0][0].get_steppers()[0] + adjusted_freq = mcu_stepper.get_mcu().get_adjusted_freq() + dist_ticks = adjusted_freq * mcu_stepper.get_step_dist() + ticks_per_step = math.ceil(dist_ticks / speed) + return dist_ticks / ticks_per_step def homing_move(self, movepos, endstops, speed): # Start endstop checking print_time = self.toolhead.get_last_move_time() @@ -67,6 +76,7 @@ class Homing: est_steps = sum([est_move_d / s.get_step_dist() for es, n in endstops for s in es.get_steppers()]) self.toolhead.dwell(est_steps * HOMING_STEP_DELAY, check_stall=False) + speed = self._get_homing_speed(speed, endstops) # Setup for retract verification self.toolhead.get_last_move_time() start_mcu_pos = [(s, name, s.get_mcu_position()) |