homing: Check homing distance to verify endstop trigger after retract
Instead of checking the endstop trigger directly after a retract move, verify some distance is traveled during the following homing operation. This reduces the amount of synchronization between mcu and host during homing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a5637bb9d4
commit
9755182adf
|
@ -61,7 +61,8 @@ class CartKinematics:
|
||||||
homing_state.plan_retract(list(coord), [s], s.homing_speed)
|
homing_state.plan_retract(list(coord), [s], s.homing_speed)
|
||||||
# Home again
|
# Home again
|
||||||
coord[axis] = r2pos
|
coord[axis] = r2pos
|
||||||
homing_state.plan_home(list(coord), homepos, [s], s.homing_speed/2.0)
|
homing_state.plan_second_home(
|
||||||
|
list(coord), homepos, [s], s.homing_speed/2.0)
|
||||||
homing_state.plan_calc_position(self.get_homed_position)
|
homing_state.plan_calc_position(self.get_homed_position)
|
||||||
def motor_off(self, move_time):
|
def motor_off(self, move_time):
|
||||||
self.limits = [(1.0, -1.0)] * 3
|
self.limits = [(1.0, -1.0)] * 3
|
||||||
|
|
|
@ -101,8 +101,8 @@ class DeltaKinematics:
|
||||||
homing_state.plan_retract(list(coord), self.steppers, s.homing_speed)
|
homing_state.plan_retract(list(coord), self.steppers, s.homing_speed)
|
||||||
# Home again
|
# Home again
|
||||||
coord[2] -= s.homing_retract_dist
|
coord[2] -= s.homing_retract_dist
|
||||||
homing_state.plan_home(list(coord), homepos, self.steppers
|
homing_state.plan_second_home(list(coord), homepos, self.steppers
|
||||||
, s.homing_speed/2.0)
|
, s.homing_speed/2.0)
|
||||||
homing_state.plan_calc_position(self.get_homed_position)
|
homing_state.plan_calc_position(self.get_homed_position)
|
||||||
def motor_off(self, move_time):
|
def motor_off(self, move_time):
|
||||||
self.limit_xy2 = -1.
|
self.limit_xy2 = -1.
|
||||||
|
|
|
@ -254,6 +254,8 @@ class GCodeParser:
|
||||||
if not axes:
|
if not axes:
|
||||||
axes = [0, 1, 2]
|
axes = [0, 1, 2]
|
||||||
homing_state = homing.Homing(self.toolhead, axes)
|
homing_state = homing.Homing(self.toolhead, axes)
|
||||||
|
if self.inputfile:
|
||||||
|
homing_state.set_no_verify_retract()
|
||||||
self.toolhead.home(homing_state)
|
self.toolhead.home(homing_state)
|
||||||
def axes_update(homing_state):
|
def axes_update(homing_state):
|
||||||
newpos = self.toolhead.get_position()
|
newpos = self.toolhead.get_position()
|
||||||
|
|
|
@ -10,20 +10,25 @@ class Homing:
|
||||||
def __init__(self, toolhead, changed_axes):
|
def __init__(self, toolhead, changed_axes):
|
||||||
self.toolhead = toolhead
|
self.toolhead = toolhead
|
||||||
self.changed_axes = changed_axes
|
self.changed_axes = changed_axes
|
||||||
|
self.verify_retract = True
|
||||||
|
|
||||||
self.eventtime = 0.
|
self.eventtime = 0.
|
||||||
self.states = []
|
self.states = []
|
||||||
self.endstops = []
|
self.endstops = []
|
||||||
|
def set_no_verify_retract(self):
|
||||||
|
self.verify_retract = False
|
||||||
def set_axes(self, axes):
|
def set_axes(self, axes):
|
||||||
self.changed_axes = axes
|
self.changed_axes = axes
|
||||||
def get_axes(self):
|
def get_axes(self):
|
||||||
return self.changed_axes
|
return self.changed_axes
|
||||||
def plan_home(self, forcepos, movepos, steppers, speed):
|
def plan_home(self, forcepos, movepos, steppers, speed):
|
||||||
self.states.append((self.do_home, (forcepos, movepos, steppers, speed)))
|
self.states.append((self.do_home, (forcepos, movepos, steppers, speed)))
|
||||||
self.states.append((self.do_wait_endstop, ()))
|
self.states.append((self.do_wait_endstop, (False,)))
|
||||||
|
def plan_second_home(self, forcepos, movepos, steppers, speed):
|
||||||
|
self.states.append((self.do_home, (forcepos, movepos, steppers, speed)))
|
||||||
|
self.states.append((self.do_wait_endstop, (self.verify_retract,)))
|
||||||
def plan_retract(self, newpos, steppers, speed):
|
def plan_retract(self, newpos, steppers, speed):
|
||||||
self.states.append((self.do_retract, (newpos, steppers, speed)))
|
self.states.append((self.do_retract, (newpos, steppers, speed)))
|
||||||
self.states.append((self.do_verify_retract, ()))
|
|
||||||
def plan_calc_position(self, callback):
|
def plan_calc_position(self, callback):
|
||||||
self.states.append((self.do_calc_position, (callback,)))
|
self.states.append((self.do_calc_position, (callback,)))
|
||||||
def plan_axes_update(self, callback):
|
def plan_axes_update(self, callback):
|
||||||
|
@ -50,13 +55,7 @@ class Homing:
|
||||||
thcoord[i] = coord[i]
|
thcoord[i] = coord[i]
|
||||||
return thcoord
|
return thcoord
|
||||||
def do_retract(self, newpos, steppers, speed):
|
def do_retract(self, newpos, steppers, speed):
|
||||||
# Issue a move command
|
|
||||||
self.toolhead.move(self.fill_coord(newpos), speed)
|
self.toolhead.move(self.fill_coord(newpos), speed)
|
||||||
# Query endstops
|
|
||||||
print_time = self.toolhead.get_last_move_time()
|
|
||||||
for s in steppers:
|
|
||||||
es = s.query_endstop(print_time)
|
|
||||||
self.endstops.append((s.name, es))
|
|
||||||
return False
|
return False
|
||||||
def do_home(self, forcepos, movepos, steppers, speed):
|
def do_home(self, forcepos, movepos, steppers, speed):
|
||||||
# Alter kinematics class to think printer is at forcepos
|
# Alter kinematics class to think printer is at forcepos
|
||||||
|
@ -65,37 +64,27 @@ class Homing:
|
||||||
print_time = self.toolhead.get_last_move_time()
|
print_time = self.toolhead.get_last_move_time()
|
||||||
for s in steppers:
|
for s in steppers:
|
||||||
es = s.enable_endstop_checking(print_time, s.step_dist / speed)
|
es = s.enable_endstop_checking(print_time, s.step_dist / speed)
|
||||||
self.endstops.append((s.name, es))
|
self.endstops.append((s, es, s.mcu_stepper.get_mcu_position()))
|
||||||
self.toolhead.move(self.fill_coord(movepos), speed)
|
self.toolhead.move(self.fill_coord(movepos), speed)
|
||||||
move_end_print_time = self.toolhead.get_last_move_time()
|
move_end_print_time = self.toolhead.get_last_move_time()
|
||||||
self.toolhead.reset_print_time()
|
self.toolhead.reset_print_time()
|
||||||
for name, es in self.endstops:
|
for s, es, last_pos in self.endstops:
|
||||||
es.home_finalize(es.print_to_mcu_time(move_end_print_time))
|
es.home_finalize(es.print_to_mcu_time(move_end_print_time))
|
||||||
return False
|
return False
|
||||||
def do_wait_endstop(self):
|
def do_wait_endstop(self, verify_retract):
|
||||||
# Check if endstops have triggered
|
# Check if endstops have triggered
|
||||||
while self.endstops:
|
while self.endstops:
|
||||||
name, es = self.endstops[0]
|
stepper, es, last_pos = self.endstops[0]
|
||||||
try:
|
try:
|
||||||
if es.check_busy(self.eventtime):
|
if es.check_busy(self.eventtime):
|
||||||
return True
|
return True
|
||||||
except mcu.MCUError, e:
|
except mcu.MCUError, e:
|
||||||
raise EndstopError("Failed to home stepper %s: %s" % (
|
raise EndstopError("Failed to home stepper %s: %s" % (
|
||||||
name, str(e)))
|
stepper.name, str(e)))
|
||||||
self.endstops.pop(0)
|
post_home_pos = stepper.mcu_stepper.get_mcu_position()
|
||||||
return False
|
if verify_retract and last_pos == post_home_pos:
|
||||||
def do_verify_retract(self):
|
|
||||||
while self.endstops:
|
|
||||||
name, es = self.endstops[0]
|
|
||||||
try:
|
|
||||||
if es.check_busy(self.eventtime):
|
|
||||||
return True
|
|
||||||
except mcu.MCUError, e:
|
|
||||||
raise EndstopError("Failed to retract stepper %s: %s" % (
|
|
||||||
name, str(e)))
|
|
||||||
if es.get_last_triggered():
|
|
||||||
raise EndstopError("Endstop %s still triggered after retract" % (
|
raise EndstopError("Endstop %s still triggered after retract" % (
|
||||||
name,))
|
stepper.name,))
|
||||||
self.endstops.pop(0)
|
self.endstops.pop(0)
|
||||||
return False
|
return False
|
||||||
def do_calc_position(self, callback):
|
def do_calc_position(self, callback):
|
||||||
|
|
Loading…
Reference in New Issue