homing: Verify the endstops are no longer triggered after retract move

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-11-18 13:39:48 -05:00
parent e0aa067cc9
commit ab1972d1cf
4 changed files with 28 additions and 10 deletions

View File

@ -86,8 +86,6 @@ Safety features
can be useful to detect a sensor failure (eg, thermistor short) that can be useful to detect a sensor failure (eg, thermistor short) that
could otherwise cause the PID to command excessive heating. could otherwise cause the PID to command excessive heating.
* Verify the endstop is no longer triggered after retraction.
* Possibly implement host based checking on the ratio between extrude * Possibly implement host based checking on the ratio between extrude
amount and head movement. amount and head movement.
* Enforce acceleration and speed limits on extruder stepper motor. * Enforce acceleration and speed limits on extruder stepper motor.

View File

@ -58,7 +58,7 @@ class CartKinematics:
homing_state.plan_home(list(coord), homepos, [s], s.homing_speed) homing_state.plan_home(list(coord), homepos, [s], s.homing_speed)
# Retract # Retract
coord[axis] = rpos coord[axis] = rpos
homing_state.plan_move(list(coord), 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_home(list(coord), homepos, [s], s.homing_speed/2.0)

View File

@ -96,7 +96,7 @@ class DeltaKinematics:
, s.homing_speed) , s.homing_speed)
# Retract # Retract
coord[2] = homepos[2] - s.homing_retract_dist coord[2] = homepos[2] - s.homing_retract_dist
homing_state.plan_move(list(coord), 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_home(list(coord), homepos, self.steppers

View File

@ -21,8 +21,9 @@ class Homing:
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, ()))
def plan_move(self, newpos, speed): def plan_retract(self, newpos, steppers, speed):
self.states.append((self.do_move, (newpos, 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):
@ -48,9 +49,14 @@ class Homing:
if coord[i] is not None: if coord[i] is not None:
thcoord[i] = coord[i] thcoord[i] = coord[i]
return thcoord return thcoord
def do_move(self, newpos, speed): def do_retract(self, newpos, steppers, speed):
# Issue a move command # 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
@ -68,15 +74,29 @@ class Homing:
return False return False
def do_wait_endstop(self): def do_wait_endstop(self):
# Check if endstops have triggered # Check if endstops have triggered
for name, es in self.endstops: while self.endstops:
name, es = 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))) name, str(e)))
# Finished self.endstops.pop(0)
del self.endstops[:] return False
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" % (
name,))
self.endstops.pop(0)
return False return False
def do_calc_position(self, callback): def do_calc_position(self, callback):
self.toolhead.set_position(self.fill_coord(callback(self))) self.toolhead.set_position(self.fill_coord(callback(self)))