From 6627d036ac7c04877af99f1c996b7947b375af86 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 21 Feb 2022 13:51:27 -0500 Subject: [PATCH] extruder: Allow an extruder object to be created without a stepper This may be useful for dual hotend printers that have only one stepper. Signed-off-by: Kevin O'Connor --- docs/Config_Reference.md | 14 +++++++++----- klippy/kinematics/extruder.py | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 223b576f..bc66b86a 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -638,10 +638,11 @@ max_accel: 1 ### [extruder] -The extruder section is used to describe both the stepper controlling -the printer extruder and the heater parameters for the nozzle. See the -[pressure advance guide](Pressure_Advance.md) for information on -tuning pressure advance. +The extruder section is used to describe the heater parameters for the +nozzle hotend along with the stepper controlling the extruder. See the +[command reference](G-Codes.md#extruder) for additional information. +See the [pressure advance guide](Pressure_Advance.md) for information +on tuning pressure advance. ``` [extruder] @@ -652,7 +653,10 @@ microsteps: rotation_distance: #full_steps_per_rotation: #gear_ratio: -# See the "stepper" section for a description of the above parameters. +# See the "stepper" section for a description of the above +# parameters. If none of the above parameters are specified then no +# stepper will be associated with the nozzle hotend (though a +# SYNC_EXTRUDER_MOTION command may associate one at run-time). nozzle_diameter: # Diameter of the nozzle orifice (in mm). This parameter must be # provided. diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index 99d5daf8..e3303982 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -79,6 +79,8 @@ class ExtruderStepper: cmd_SET_PRESSURE_ADVANCE_help = "Set pressure advance parameters" def cmd_default_SET_PRESSURE_ADVANCE(self, gcmd): extruder = self.printer.lookup_object('toolhead').get_extruder() + if extruder.extruder_stepper is None: + raise gcmd.error("Active extruder does not have a stepper") extruder.extruder_stepper.cmd_SET_PRESSURE_ADVANCE(gcmd) def cmd_SET_PRESSURE_ADVANCE(self, gcmd): pressure_advance = gcmd.get_float('ADVANCE', self.pressure_advance, @@ -181,12 +183,16 @@ class PrinterExtruder: self.trapq_append = ffi_lib.trapq_append self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves # Setup extruder stepper - self.extruder_stepper = ExtruderStepper(config) - self.extruder_stepper.stepper.set_trapq(self.trapq) - pa = config.getfloat('pressure_advance', 0., minval=0.) - smooth_time = config.getfloat('pressure_advance_smooth_time', - 0.040, above=0., maxval=.200) - self.extruder_stepper._set_pressure_advance(pa, smooth_time) + self.extruder_stepper = None + if (config.get('step_pin', None) is not None + or config.get('dir_pin', None) is not None + or config.get('rotation_distance', None) is not None): + self.extruder_stepper = ExtruderStepper(config) + self.extruder_stepper.stepper.set_trapq(self.trapq) + pa = config.getfloat('pressure_advance', 0., minval=0.) + smooth_time = config.getfloat('pressure_advance_smooth_time', + 0.040, above=0., maxval=.200) + self.extruder_stepper._set_pressure_advance(pa, smooth_time) # Register commands gcode = self.printer.lookup_object('gcode') if self.name == 'extruder': @@ -201,7 +207,8 @@ class PrinterExtruder: def get_status(self, eventtime): sts = self.heater.get_status(eventtime) sts['can_extrude'] = self.heater.can_extrude - sts.update(self.extruder_stepper.get_status(eventtime)) + if self.extruder_stepper is not None: + sts.update(self.extruder_stepper.get_status(eventtime)) return sts def get_name(self): return self.name @@ -259,6 +266,8 @@ class PrinterExtruder: start_v, cruise_v, accel) self.last_position = move.end_pos[3] def find_past_position(self, print_time): + if self.extruder_stepper is None: + return 0. return self.extruder_stepper.find_past_position(print_time) def cmd_M104(self, gcmd, wait=False): # Set Extruder Temperature