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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-02-21 13:51:27 -05:00
parent 4a8aece6a7
commit 6627d036ac
2 changed files with 25 additions and 12 deletions

View File

@ -638,10 +638,11 @@ max_accel: 1
### [extruder] ### [extruder]
The extruder section is used to describe both the stepper controlling The extruder section is used to describe the heater parameters for the
the printer extruder and the heater parameters for the nozzle. See the nozzle hotend along with the stepper controlling the extruder. See the
[pressure advance guide](Pressure_Advance.md) for information on [command reference](G-Codes.md#extruder) for additional information.
tuning pressure advance. See the [pressure advance guide](Pressure_Advance.md) for information
on tuning pressure advance.
``` ```
[extruder] [extruder]
@ -652,7 +653,10 @@ microsteps:
rotation_distance: rotation_distance:
#full_steps_per_rotation: #full_steps_per_rotation:
#gear_ratio: #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: nozzle_diameter:
# Diameter of the nozzle orifice (in mm). This parameter must be # Diameter of the nozzle orifice (in mm). This parameter must be
# provided. # provided.

View File

@ -79,6 +79,8 @@ class ExtruderStepper:
cmd_SET_PRESSURE_ADVANCE_help = "Set pressure advance parameters" cmd_SET_PRESSURE_ADVANCE_help = "Set pressure advance parameters"
def cmd_default_SET_PRESSURE_ADVANCE(self, gcmd): def cmd_default_SET_PRESSURE_ADVANCE(self, gcmd):
extruder = self.printer.lookup_object('toolhead').get_extruder() 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) extruder.extruder_stepper.cmd_SET_PRESSURE_ADVANCE(gcmd)
def cmd_SET_PRESSURE_ADVANCE(self, gcmd): def cmd_SET_PRESSURE_ADVANCE(self, gcmd):
pressure_advance = gcmd.get_float('ADVANCE', self.pressure_advance, pressure_advance = gcmd.get_float('ADVANCE', self.pressure_advance,
@ -181,12 +183,16 @@ class PrinterExtruder:
self.trapq_append = ffi_lib.trapq_append self.trapq_append = ffi_lib.trapq_append
self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves
# Setup extruder stepper # Setup extruder stepper
self.extruder_stepper = ExtruderStepper(config) self.extruder_stepper = None
self.extruder_stepper.stepper.set_trapq(self.trapq) if (config.get('step_pin', None) is not None
pa = config.getfloat('pressure_advance', 0., minval=0.) or config.get('dir_pin', None) is not None
smooth_time = config.getfloat('pressure_advance_smooth_time', or config.get('rotation_distance', None) is not None):
0.040, above=0., maxval=.200) self.extruder_stepper = ExtruderStepper(config)
self.extruder_stepper._set_pressure_advance(pa, smooth_time) 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 # Register commands
gcode = self.printer.lookup_object('gcode') gcode = self.printer.lookup_object('gcode')
if self.name == 'extruder': if self.name == 'extruder':
@ -201,7 +207,8 @@ class PrinterExtruder:
def get_status(self, eventtime): def get_status(self, eventtime):
sts = self.heater.get_status(eventtime) sts = self.heater.get_status(eventtime)
sts['can_extrude'] = self.heater.can_extrude 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 return sts
def get_name(self): def get_name(self):
return self.name return self.name
@ -259,6 +266,8 @@ class PrinterExtruder:
start_v, cruise_v, accel) start_v, cruise_v, accel)
self.last_position = move.end_pos[3] self.last_position = move.end_pos[3]
def find_past_position(self, print_time): def find_past_position(self, print_time):
if self.extruder_stepper is None:
return 0.
return self.extruder_stepper.find_past_position(print_time) return self.extruder_stepper.find_past_position(print_time)
def cmd_M104(self, gcmd, wait=False): def cmd_M104(self, gcmd, wait=False):
# Set Extruder Temperature # Set Extruder Temperature