Skip to content

Commit

Permalink
extruder: Support disassociating a stepper from all extruders
Browse files Browse the repository at this point in the history
Support SYNC_STEPPER_TO_EXTRUDER commands with an EXTRUDER parameter
set to an empty string.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Jan 17, 2022
1 parent eb2a67c commit 02d5f97
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1835,8 +1835,9 @@ more information.
```
[extruder_stepper my_extra_stepper]
#extruder: extruder
# The extruder this stepper is synchronized to. The default is
# "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".
#step_pin:
#dir_pin:
#enable_pin:
Expand Down
4 changes: 3 additions & 1 deletion docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ The following standard commands are supported:
command will cause the given extruder STEPPER (as specified in an
[extruder](Config_Reference#extruder) or
[extruder stepper](Config_Reference#extruder_stepper) config
section) to become synchronized to the given EXTRUDER.
section) to become synchronized to the given EXTRUDER. If EXTRUDER
is an empty string then the stepper will not be synchronized to an
extruder.
- `SET_STEPPER_ENABLE STEPPER=<config_name> ENABLE=[0|1]`: Enable or
disable only the given stepper. This is a diagnostic and debugging
tool and must be used with care. Disabling an axis motor does not
Expand Down
7 changes: 5 additions & 2 deletions klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ def find_past_position(self, print_time):
mcu_pos = self.stepper.get_past_mcu_position(print_time)
return self.stepper.mcu_to_commanded_position(mcu_pos)
def sync_to_extruder(self, extruder_name):
toolhead = self.printer.lookup_object('toolhead')
toolhead.flush_step_generation()
if not extruder_name:
self.stepper.set_trapq(None)
return
extruder = self.printer.lookup_object(extruder_name, None)
if extruder is None or not isinstance(extruder, PrinterExtruder):
raise self.printer.command_error("'%s' is not a valid extruder."
% (extruder_name,))
toolhead = self.printer.lookup_object('toolhead')
toolhead.flush_step_generation()
self.stepper.set_position([extruder.last_position, 0., 0.])
self.stepper.set_trapq(extruder.get_trapq())
def _set_pressure_advance(self, pressure_advance, smooth_time):
Expand Down
29 changes: 29 additions & 0 deletions test/klippy/extruders.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,32 @@ G1 X25 Y25 E7.5
# Update step_distance
SET_EXTRUDER_STEP_DISTANCE EXTRUDER=extruder DISTANCE=.005
G1 X30 Y30 E8.0

# Disable extruder stepper motor
SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder EXTRUDER=
G1 X35 Y35 E8.5

# Disable my_extra_stepper stepper motor
SYNC_STEPPER_TO_EXTRUDER STEPPER=my_extra_stepper EXTRUDER=
G1 X40 Y40 E9.0

# Enable extruder stepper motor
SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder EXTRUDER=extruder
G1 X45 Y45 E9.5

# Switch to just my_extra_stepper stepper motor
SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder EXTRUDER=
SYNC_STEPPER_TO_EXTRUDER STEPPER=my_extra_stepper EXTRUDER=extruder
G1 X50 Y50 E10.0

# Test pressure advance move
SET_PRESSURE_ADVANCE EXTRUDER=my_extra_stepper ADVANCE=0.020
G1 X55 Y55 E0
G1 X55 Y55 E0.5
G1 X60 Y60 E1.1
G1 X50 Y50
SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=0.025
G1 X55 Y55 E1.5
G1 X50 Y50
G1 X55 Y55 E2.0
G1 X50 Y50

0 comments on commit 02d5f97

Please sign in to comment.