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>
This commit is contained in:
Kevin O'Connor 2017-12-20 14:11:38 -05:00
parent 1b07505973
commit 1d21bf66c6
5 changed files with 18 additions and 11 deletions

View File

@ -48,7 +48,9 @@ class CartKinematics:
rpos = s.position_endstop + s.homing_retract_dist
r2pos = rpos + s.homing_retract_dist
# Initial homing
homing_speed = s.get_homing_speed()
homing_speed = s.homing_speed
if axis == 2:
homing_speed = min(homing_speed, self.max_z_velocity)
homepos = [None, None, None, None]
homepos[axis] = s.position_endstop
coord = [None, None, None, None]

View File

@ -56,7 +56,9 @@ class CoreXYKinematics:
rpos = s.position_endstop + s.homing_retract_dist
r2pos = rpos + s.homing_retract_dist
# Initial homing
homing_speed = s.get_homing_speed()
homing_speed = s.homing_speed
if axis == 2:
homing_speed = min(homing_speed, self.max_z_velocity)
homepos = [None, None, None, None]
homepos[axis] = s.position_endstop
coord = [None, None, None, None]

View File

@ -112,7 +112,7 @@ class DeltaKinematics:
s = self.steppers[0] # Assume homing speed same for all steppers
self.need_home = False
# Initial homing
homing_speed = s.get_homing_speed()
homing_speed = min(s.homing_speed, self.max_z_velocity)
homepos = [0., 0., self.max_z, None]
coord = list(homepos)
coord[2] = -1.5 * math.sqrt(max(self.arm2)-self.max_xy2)

View File

@ -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())

View File

@ -122,13 +122,6 @@ class PrinterHomingStepper(PrinterStepper):
self.homing_endstop_accuracy = self.homing_stepper_phases
def get_endstops(self):
return [(self.mcu_endstop, self.name)]
def get_homing_speed(self):
# Round the configured homing speed so that it is an even
# number of ticks per step.
adjusted_freq = self.mcu_stepper.get_mcu().get_adjusted_freq()
dist_ticks = adjusted_freq * self.step_dist
ticks_per_step = round(dist_ticks / self.homing_speed)
return dist_ticks / ticks_per_step
def get_homed_offset(self):
if not self.homing_stepper_phases or self.need_motor_enable:
return 0.