stepper: Raise an error if position_endstop is not in min/max range

Raise an error during config parsing if the position_endstop is not
between the position_min and position_max.  This avoids a confusing
error message during homing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-05-18 19:34:17 -04:00
parent 2740838b2e
commit 11816295e7
2 changed files with 22 additions and 11 deletions

View File

@ -15,13 +15,14 @@ class DeltaKinematics:
def __init__(self, toolhead, printer, config):
stepper_configs = [config.getsection('stepper_' + n)
for n in ['a', 'b', 'c']]
stepper_a = stepper.PrinterHomingStepper(printer, stepper_configs[0])
stepper_a = stepper.PrinterHomingStepper(
printer, stepper_configs[0], need_position_minmax = False)
stepper_b = stepper.PrinterHomingStepper(
printer, stepper_configs[1],
default_position=stepper_a.position_endstop)
printer, stepper_configs[1], need_position_minmax = False,
default_position_endstop=stepper_a.position_endstop)
stepper_c = stepper.PrinterHomingStepper(
printer, stepper_configs[2],
default_position=stepper_a.position_endstop)
printer, stepper_configs[2], need_position_minmax = False,
default_position_endstop=stepper_a.position_endstop)
self.steppers = [stepper_a, stepper_b, stepper_c]
self.need_motor_enable = self.need_home = True
self.radius = radius = config.getfloat('delta_radius', above=0.)

View File

@ -71,21 +71,31 @@ class PrinterStepper:
# Support for stepper controlled linear axis with an endstop
class PrinterHomingStepper(PrinterStepper):
def __init__(self, printer, config, default_position=None):
def __init__(self, printer, config, need_position_minmax=True,
default_position_endstop=None):
PrinterStepper.__init__(self, printer, config)
# Endstop and its position
ppins = printer.lookup_object('pins')
self.mcu_endstop = ppins.setup_pin('endstop', config.get('endstop_pin'))
self.mcu_endstop.add_stepper(self.mcu_stepper)
if default_position is None:
if default_position_endstop is None:
self.position_endstop = config.getfloat('position_endstop')
else:
self.position_endstop = config.getfloat(
'position_endstop', default_position)
'position_endstop', default_position_endstop)
# Axis range
self.position_min = config.getfloat('position_min', 0.)
self.position_max = config.getfloat(
'position_max', 0., above=self.position_min)
if need_position_minmax:
self.position_min = config.getfloat('position_min', 0.)
self.position_max = config.getfloat(
'position_max', above=self.position_min)
else:
self.position_min = 0.
self.position_max = self.position_endstop
if (self.position_endstop < self.position_min
or self.position_endstop > self.position_max):
raise config.error(
"position_endstop in section '%s' must be between"
" position_min and position_max" % config.get_name())
# Homing mechanics
self.homing_speed = config.getfloat('homing_speed', 5.0, above=0.)
self.homing_retract_dist = config.getfloat(