homing: Remove no longer needed homing time delay code

Now that homing is implemented via "drip moves", it is no longer
necessary to round the homing speed and it is no longer necessary to
add a delay for cpu processing time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-06-27 13:11:58 -04:00 committed by KevinOConnor
parent 43064d197d
commit dd34768e3a
5 changed files with 11 additions and 44 deletions

View File

@ -5,7 +5,6 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, math, collections
HOMING_STEP_DELAY = 0.00000025
HOMING_START_DELAY = 0.001
ENDSTOP_SAMPLE_TIME = .000015
ENDSTOP_SAMPLE_COUNT = 4
@ -32,25 +31,15 @@ class Homing:
return thcoord
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.
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 _endstop_notify(self):
self.endstops_pending -= 1
if not self.endstops_pending:
self.toolhead.signal_drip_mode_end()
def homing_move(self, movepos, endstops, speed, dwell_t=0.,
def homing_move(self, movepos, endstops, speed,
probe_pos=False, verify_movement=False):
# Notify endstops of upcoming home
for mcu_endstop, name in endstops:
mcu_endstop.home_prepare()
if dwell_t:
self.toolhead.dwell(dwell_t, check_stall=False)
# Start endstop checking
print_time = self.toolhead.get_last_move_time()
start_mcu_pos = [(s, name, s.get_mcu_position())
@ -98,42 +87,30 @@ class Homing:
raise EndstopError("Probe triggered prior to movement")
raise EndstopError(
"Endstop %s still triggered after retract" % (name,))
def home_rails(self, rails, forcepos, movepos, limit_speed=None):
def home_rails(self, rails, forcepos, movepos):
# Alter kinematics class to think printer is at forcepos
homing_axes = [axis for axis in range(3) if forcepos[axis] is not None]
forcepos = self._fill_coord(forcepos)
movepos = self._fill_coord(movepos)
self.toolhead.set_position(forcepos, homing_axes=homing_axes)
# Determine homing speed
# Perform first home
endstops = [es for rail in rails for es in rail.get_endstops()]
hi = rails[0].get_homing_info()
max_velocity = self.toolhead.get_max_velocity()[0]
if limit_speed is not None and limit_speed < max_velocity:
max_velocity = limit_speed
homing_speed = min(hi.speed, max_velocity)
homing_speed = self._get_homing_speed(homing_speed, endstops)
second_homing_speed = min(hi.second_homing_speed, max_velocity)
# Calculate a CPU delay when homing a large axis
axes_d = [mp - fp for mp, fp in zip(movepos, forcepos)]
est_move_d = abs(axes_d[0]) + abs(axes_d[1]) + abs(axes_d[2])
est_steps = sum([est_move_d / s.get_step_dist()
for es, n in endstops for s in es.get_steppers()])
dwell_t = est_steps * HOMING_STEP_DELAY
# Perform first home
self.homing_move(movepos, endstops, homing_speed, dwell_t=dwell_t)
self.homing_move(movepos, endstops, hi.speed)
# Perform second home
if hi.retract_dist:
# Retract
axes_d = [mp - fp for mp, fp in zip(movepos, forcepos)]
move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
retract_r = min(1., hi.retract_dist / move_d)
retractpos = [mp - ad * retract_r
for mp, ad in zip(movepos, axes_d)]
self.toolhead.move(retractpos, homing_speed)
self.toolhead.move(retractpos, hi.speed)
# Home again
forcepos = [rp - ad * retract_r
for rp, ad in zip(retractpos, axes_d)]
self.toolhead.set_position(forcepos)
self.homing_move(movepos, endstops, second_homing_speed,
self.homing_move(movepos, endstops, hi.second_homing_speed,
verify_movement=self.verify_retract)
# Signal home operation complete
ret = self.printer.send_event("homing:homed_rails", self, rails)

View File

@ -66,10 +66,7 @@ class CartKinematics:
else:
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
# Perform homing
limit_speed = None
if axis == 2:
limit_speed = self.max_z_velocity
homing_state.home_rails([rail], forcepos, homepos, limit_speed)
homing_state.home_rails([rail], forcepos, homepos)
def home(self, homing_state):
# Each axis is homed independently and in order
for axis in homing_state.get_axes():

View File

@ -60,10 +60,7 @@ class CoreXYKinematics:
else:
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
# Perform homing
limit_speed = None
if axis == 2:
limit_speed = self.max_z_velocity
homing_state.home_rails([rail], forcepos, homepos, limit_speed)
homing_state.home_rails([rail], forcepos, homepos)
def motor_off(self, print_time):
self.limits = [(1.0, -1.0)] * 3
for rail in self.rails:

View File

@ -101,8 +101,7 @@ class DeltaKinematics:
homing_state.set_axes([0, 1, 2])
forcepos = list(self.home_position)
forcepos[2] = -1.5 * math.sqrt(max(self.arm2)-self.max_xy2)
homing_state.home_rails(self.rails, forcepos, self.home_position,
limit_speed=self.max_z_velocity)
homing_state.home_rails(self.rails, forcepos, self.home_position)
def motor_off(self, print_time):
self.limit_xy2 = -1.
for rail in self.rails:

View File

@ -63,10 +63,7 @@ class PolarKinematics:
else:
forcepos[axis] += position_max - hi.position_endstop
# Perform homing
limit_speed = None
if axis == 2:
limit_speed = self.max_z_velocity
homing_state.home_rails([rail], forcepos, homepos, limit_speed)
homing_state.home_rails([rail], forcepos, homepos)
def home(self, homing_state):
# Always home XY together
homing_axes = homing_state.get_axes()