Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support [extruder] sections without a stepper #5294

Merged
merged 3 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/Config_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All dates in this document are approximate.

## Changes

20220304: There is no longer a default for the `extruder` parameter of
[extruder_stepper](Config_Reference.md#extruder_stepper) config
sections. If desired, specify `extruder: extruder` explicitly to
associate the stepper motor with the "extruder" motion queue at
startup.

20220210: The `SYNC_STEPPER_TO_EXTRUDER` command is deprecated; the
`SET_EXTRUDER_STEP_DISTANCE` command is deprecated; the
[extruder](Config_Reference.md#extruder) `shared_heater` config option
Expand Down
18 changes: 11 additions & 7 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand Down Expand Up @@ -1825,10 +1829,10 @@ See the [command reference](G-Codes.md#extruder) for more information.

```
[extruder_stepper my_extra_stepper]
#extruder: extruder
extruder:
# The extruder this stepper is synchronized to. If this is set to an
# empty string then the stepper will not be synchronized to an
# extruder. The default is "extruder".
# extruder. This parameter must be provided.
#step_pin:
#dir_pin:
#enable_pin:
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/extruder_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PrinterExtruderStepper:
def __init__(self, config):
self.printer = config.get_printer()
self.extruder_stepper = extruder.ExtruderStepper(config)
self.extruder_name = config.get('extruder', 'extruder')
self.extruder_name = config.get('extruder')
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
def handle_connect(self):
Expand Down
26 changes: 19 additions & 7 deletions klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def _set_pressure_advance(self, pressure_advance, smooth_time):
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")
strapq = extruder.extruder_stepper.stepper.get_trapq()
if strapq is not extruder.get_trapq():
raise gcmd.error("Unable to infer active extruder 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,
Expand Down Expand Up @@ -181,12 +186,16 @@ def __init__(self, config, extruder_num):
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':
Expand All @@ -201,7 +210,8 @@ def update_move_time(self, flush_time):
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
Expand Down Expand Up @@ -259,6 +269,8 @@ def move(self, print_time, move):
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
Expand Down
2 changes: 2 additions & 0 deletions klippy/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def _query_mcu_position(self):
raise error("Internal error in stepcompress")
self._set_mcu_position(last_pos)
self._mcu.get_printer().send_event("stepper:sync_mcu_position", self)
def get_trapq(self):
return self._trapq
def set_trapq(self, tq):
ffi_main, ffi_lib = chelper.get_ffi()
if tq is None:
Expand Down
1 change: 1 addition & 0 deletions test/klippy/extruders.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ min_temp: 0
max_temp: 210

[extruder_stepper my_extra_stepper]
extruder: extruder
step_pin: PH5
dir_pin: PH6
enable_pin: !PB5
Expand Down