stepper: Support for multiple steppers controlling a single axis
Allow multiple steppers to be defined for a single cartesian axis. This adds support for dual-z setups. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
38643f52c9
commit
8c2fa2e2d6
|
@ -27,6 +27,24 @@
|
||||||
# activation.
|
# activation.
|
||||||
|
|
||||||
|
|
||||||
|
# Multi-stepper axes. On a cartesian style printer, the stepper
|
||||||
|
# controlling a given axis may have additional config blocks defining
|
||||||
|
# steppers that should be stepped in concert with the primary
|
||||||
|
# stepper. One may define any number of sections with a numeric suffix
|
||||||
|
# starting at 1 (for example, "stepper_z1", "stepper_z2", etc.).
|
||||||
|
#[stepper_z1]
|
||||||
|
#step_pin: ar36
|
||||||
|
#dir_pin: ar34
|
||||||
|
#enable_pin: !ar30
|
||||||
|
#step_distance: .005
|
||||||
|
# See the example.cfg for the definition of the above parameters.
|
||||||
|
#endstop_pin: ^ar19
|
||||||
|
# If an endstop_pin is defined for the additional stepper then the
|
||||||
|
# stepper will home until the endstop is triggered. Otherwise, the
|
||||||
|
# endstop will home until the endstop on the primary stepper for the
|
||||||
|
# axis is triggered.
|
||||||
|
|
||||||
|
|
||||||
# Heater cooling fans (one may define any number of sections with a
|
# Heater cooling fans (one may define any number of sections with a
|
||||||
# "heater_fan" prefix). A "heater fan" is a fan that will be enabled
|
# "heater_fan" prefix). A "heater fan" is a fan that will be enabled
|
||||||
# whenever its associated heater is active. In the event of an MCU
|
# whenever its associated heater is active. In the event of an MCU
|
||||||
|
|
|
@ -10,7 +10,7 @@ StepList = (0, 1, 2)
|
||||||
|
|
||||||
class CartKinematics:
|
class CartKinematics:
|
||||||
def __init__(self, toolhead, printer, config):
|
def __init__(self, toolhead, printer, config):
|
||||||
self.steppers = [stepper.PrinterHomingStepper(
|
self.steppers = [stepper.LookupMultiHomingStepper(
|
||||||
printer, config.getsection('stepper_' + n))
|
printer, config.getsection('stepper_' + n))
|
||||||
for n in ['x', 'y', 'z']]
|
for n in ['x', 'y', 'z']]
|
||||||
max_velocity, max_accel = toolhead.get_max_velocity()
|
max_velocity, max_accel = toolhead.get_max_velocity()
|
||||||
|
|
|
@ -10,9 +10,13 @@ StepList = (0, 1, 2)
|
||||||
|
|
||||||
class CoreXYKinematics:
|
class CoreXYKinematics:
|
||||||
def __init__(self, toolhead, printer, config):
|
def __init__(self, toolhead, printer, config):
|
||||||
self.steppers = [stepper.PrinterHomingStepper(
|
self.steppers = [
|
||||||
printer, config.getsection('stepper_' + n))
|
stepper.PrinterHomingStepper(
|
||||||
for n in ['x', 'y', 'z']]
|
printer, config.getsection('stepper_x')),
|
||||||
|
stepper.PrinterHomingStepper(
|
||||||
|
printer, config.getsection('stepper_y')),
|
||||||
|
stepper.LookupMultiHomingStepper(
|
||||||
|
printer, config.getsection('stepper_z'))]
|
||||||
self.steppers[0].mcu_endstop.add_stepper(self.steppers[1].mcu_stepper)
|
self.steppers[0].mcu_endstop.add_stepper(self.steppers[1].mcu_stepper)
|
||||||
self.steppers[1].mcu_endstop.add_stepper(self.steppers[0].mcu_stepper)
|
self.steppers[1].mcu_endstop.add_stepper(self.steppers[0].mcu_stepper)
|
||||||
max_velocity, max_accel = toolhead.get_max_velocity()
|
max_velocity, max_accel = toolhead.get_max_velocity()
|
||||||
|
|
|
@ -143,3 +143,49 @@ class PrinterHomingStepper(PrinterStepper):
|
||||||
"Endstop %s incorrect phase (got %d vs %d)" % (
|
"Endstop %s incorrect phase (got %d vs %d)" % (
|
||||||
self.name, pos, self.homing_endstop_phase))
|
self.name, pos, self.homing_endstop_phase))
|
||||||
return delta * self.step_dist
|
return delta * self.step_dist
|
||||||
|
|
||||||
|
# Wrapper for dual stepper motor support
|
||||||
|
class PrinterMultiStepper(PrinterHomingStepper):
|
||||||
|
def __init__(self, printer, config):
|
||||||
|
PrinterHomingStepper.__init__(self, printer, config)
|
||||||
|
self.endstops = PrinterHomingStepper.get_endstops(self)
|
||||||
|
self.extras = []
|
||||||
|
self.all_step_const = [self.step_const]
|
||||||
|
for i in range(1, 99):
|
||||||
|
if not config.has_section(config.section + str(i)):
|
||||||
|
break
|
||||||
|
extraconfig = config.getsection(config.section + str(i))
|
||||||
|
extra = PrinterStepper(printer, extraconfig)
|
||||||
|
self.extras.append(extra)
|
||||||
|
self.all_step_const.append(extra.step_const)
|
||||||
|
extraendstop = extraconfig.get('endstop_pin', None)
|
||||||
|
if extraendstop is not None:
|
||||||
|
mcu_endstop = pins.setup_pin(printer, 'endstop', extraendstop)
|
||||||
|
mcu_endstop.add_stepper(extra.mcu_stepper)
|
||||||
|
self.endstops.append(
|
||||||
|
(mcu_endstop, extra.mcu_stepper, extra.name))
|
||||||
|
else:
|
||||||
|
self.mcu_endstop.add_stepper(extra.mcu_stepper)
|
||||||
|
self.step_const = self.step_multi_const
|
||||||
|
def step_multi_const(self, print_time, start_pos, dist, start_v, accel):
|
||||||
|
for step_const in self.all_step_const:
|
||||||
|
step_const(print_time, start_pos, dist, start_v, accel)
|
||||||
|
def set_max_jerk(self, max_halt_velocity, max_accel):
|
||||||
|
PrinterHomingStepper.set_max_jerk(self, max_halt_velocity, max_accel)
|
||||||
|
for extra in self.extras:
|
||||||
|
extra.set_max_jerk(max_halt_velocity, max_accel)
|
||||||
|
def set_position(self, pos):
|
||||||
|
PrinterHomingStepper.set_position(self, pos)
|
||||||
|
for extra in self.extras:
|
||||||
|
extra.set_position(pos)
|
||||||
|
def motor_enable(self, print_time, enable=0):
|
||||||
|
PrinterHomingStepper.motor_enable(self, print_time, enable)
|
||||||
|
for extra in self.extras:
|
||||||
|
extra.motor_enable(print_time, enable)
|
||||||
|
def get_endstops(self):
|
||||||
|
return self.endstops
|
||||||
|
|
||||||
|
def LookupMultiHomingStepper(printer, config):
|
||||||
|
if not config.has_section(config.section + '1'):
|
||||||
|
return PrinterHomingStepper(printer, config)
|
||||||
|
return PrinterMultiStepper(printer, config)
|
||||||
|
|
Loading…
Reference in New Issue