diff --git a/config/example-extras.cfg b/config/example-extras.cfg index 9c815813..bb07c926 100644 --- a/config/example-extras.cfg +++ b/config/example-extras.cfg @@ -706,6 +706,20 @@ #position_max: # See the example.cfg for the definition of the above parameters. +# Support for additional steppers synchronized to the movement of an +# extruder (one may define any number of sections with an +# "extruder_stepper" prefix). +#[extruder_stepper my_extra_stepper] +#extruder: extruder +# The extruder this stepper is synchronized to. The default is +# "extruder". +#step_pin: +#dir_pin: +#enable_pin: +#step_distance: +# See the "extruder" section in example.cfg for the definition of +# the above parameters. + # Manual steppers (one may define any number of sections with a # "manual_stepper" prefix). These are steppers that are controlled by # the MANUAL_STEPPER g-code command. For example: "MANUAL_STEPPER diff --git a/klippy/extras/extruder_stepper.py b/klippy/extras/extruder_stepper.py new file mode 100644 index 00000000..f6d0e9ea --- /dev/null +++ b/klippy/extras/extruder_stepper.py @@ -0,0 +1,25 @@ +# Code for supporting multiple steppers in single filament extruder. +# +# Copyright (C) 2019 Simo Apell +# +# This file may be distributed under the terms of the GNU GPLv3 license. +import logging +import stepper + +class ExtruderStepper: + def __init__(self, config): + self.printer = config.get_printer() + self.extruder_name = config.get('extruder', 'extruder') + self.stepper = stepper.PrinterStepper(config) + self.stepper.set_max_jerk(9999999.9, 9999999.9) + self.stepper.setup_itersolve('extruder_stepper_alloc') + self.printer.register_event_handler("klippy:connect", + self.handle_connect) + def handle_connect(self): + extruder = self.printer.lookup_object(self.extruder_name) + self.stepper.set_trapq(extruder.get_trapq()) + toolhead = self.printer.lookup_object('toolhead') + toolhead.register_step_generator(self.stepper.generate_steps) + +def load_config_prefix(config): + return ExtruderStepper(config) diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index b5613c99..b4450596 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -95,6 +95,8 @@ class PrinterExtruder: return self.name def get_heater(self): return self.heater + def get_trapq(self): + return self.trapq def stats(self, eventtime): return self.heater.stats(eventtime) def check_move(self, move): diff --git a/test/klippy/extruders.cfg b/test/klippy/extruders.cfg new file mode 100644 index 00000000..5d61141c --- /dev/null +++ b/test/klippy/extruders.cfg @@ -0,0 +1,63 @@ +# Config for extruder testing +[stepper_x] +step_pin: ar54 +dir_pin: ar55 +enable_pin: !ar38 +step_distance: .0125 +endstop_pin: ^ar3 +position_endstop: 0 +position_max: 200 +homing_speed: 50 + +[stepper_y] +step_pin: ar60 +dir_pin: !ar61 +enable_pin: !ar56 +step_distance: .0125 +endstop_pin: ^ar14 +position_endstop: 0 +position_max: 200 +homing_speed: 50 + +[stepper_z] +step_pin: ar46 +dir_pin: ar48 +enable_pin: !ar62 +step_distance: .0025 +endstop_pin: ^ar18 +position_endstop: 0.5 +position_max: 200 + +[extruder] +step_pin: ar26 +dir_pin: ar28 +enable_pin: !ar24 +step_distance: .004242 +nozzle_diameter: 0.500 +filament_diameter: 3.500 +heater_pin: ar10 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: analog13 +control: pid +pid_Kp: 22.2 +pid_Ki: 1.08 +pid_Kd: 114 +min_temp: 0 +max_temp: 210 + +[extruder_stepper my_extra_stepper] +step_pin: ar8 +dir_pin: ar9 +enable_pin: !ar11 +step_distance: .002 + +[mcu] +serial: /dev/ttyACM0 +pin_map: arduino + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 diff --git a/test/klippy/extruders.test b/test/klippy/extruders.test new file mode 100644 index 00000000..034b0559 --- /dev/null +++ b/test/klippy/extruders.test @@ -0,0 +1,13 @@ +# Extruder tests +DICTIONARY atmega2560.dict +CONFIG extruders.cfg + +# Extrude only +G1 E5 +G1 E-2 +G1 E7 + +# Home and extrusion moves +G28 +G1 X20 Y20 Z1 +G1 X25 Y25 E7.5