Skip to content

Commit

Permalink
homing_heaters: Added ability to re-heat within a threshold
Browse files Browse the repository at this point in the history
This PR allows bed mesh calibration to work well with probes that are
sensitive to EMI coming from the bed heater while still being able to
maintain the bed temperature.
This works through adding an additional configuration setting to the
```[homing_heaters]``` section that will cause homing to wait for the
heaters to re-heat if they are outside the threshold AFTER homing has
occurred.
Note that in order to work properly this feature PR relies on the bugfix
in PR #6779.

Signed-off-by: Nick Weedon <[email protected]>
  • Loading branch information
nickweedon committed Jan 5, 2025
1 parent 8a3d2af commit 33a333b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,16 @@ Tool to disable heaters when homing or probing an axis.
# A comma separated list of heaters to disable during homing/probing
# moves. The default is to disable all heaters.
# Typical example: extruder, heater_bed
#threshold:
# If this is set then the printer will wait until the heaters have
# reached their target temperatures before continuing. If set then the
# number indicates the threshold below which the temperature of any
# heater must fall before needing to re-heat.
# This is useful for when performing bed mesh calinbration probing for
# probes that are sensitive to EMI, while still allowing the bed to
# maintain a constant temperature.
# Note that it is typically more convenient to set this via the
# SET_HOMING_HEATERS [gcode command](G-Codes.md#set_homing_heaters)
```

### [thermistor]
Expand Down
7 changes: 7 additions & 0 deletions docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,13 @@ above the supplied MINIMUM and/or at or below the supplied MAXIMUM.
[TARGET=<target_temperature>]`: Sets the target temperature for a
heater. If a target temperature is not supplied, the target is 0.

### [homing_heaters]

#### SET_HOMING_HEATERS [THRESHOLD=<temperature_threshold>]
`SET_HOMING_HEATERS [THRESHOLD=<temperature_threshold>]`: Setting this to any value at all causes homing procedures to wait until the heaters have reached
thier target temperatures AFTER probing has occurred.
This is helpful during bed mesh calibration in the event that the probe is sensitive to the EMI caused by the bed but the bed temperature must be maintained during probing. To disable this, simply run the `SET_HOMING_HEATERS` command while omitting the `THRESHOLD` parameter.

### [idle_timeout]

The idle_timeout module is automatically loaded.
Expand Down
28 changes: 28 additions & 0 deletions klippy/extras/homing_heaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def __init__(self, config):
self.disable_heaters = config.getlist("heaters", None)
self.flaky_steppers = config.getlist("steppers", None)
self.pheaters = self.printer.load_object(config, 'heaters')
self.threshold = config.getfloat("threshold", None)
self.target_save = {}
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command("SET_HOMING_HEATERS",
self.cmd_SET_HOMING_HEATERS,
desc=self.cmd_SET_HOMING_HEATERS_desc)

def handle_connect(self):
# heaters to disable
Expand Down Expand Up @@ -56,9 +61,32 @@ def handle_homing_move_begin(self, hmove):
def handle_homing_move_end(self, hmove):
if not self.check_eligible(hmove.get_mcu_endstops()):
return

# Switch all the heaters back on first
for heater_name in self.disable_heaters:
heater = self.pheaters.lookup_heater(heater_name)
heater.set_temp(self.target_save[heater_name])

if self.threshold is None:
return

# Now wait for them to re-heat if we need to
for heater_name in self.disable_heaters:
heater = self.pheaters.lookup_heater(heater_name)
heater_target = self.target_save[heater_name]
heater_threshold = heater_target - self.threshold
current_temp = heater.get_temp(
self.printer.get_reactor().monotonic())[0]
if current_temp < heater_threshold:
self.gcode.respond_raw(
"echo: Waiting for '%s' to reheat" % heater_name)
self.pheaters.set_temperature(heater, heater_target, True)

cmd_SET_HOMING_HEATERS_desc = "Set the reheat threshold for homing heaters"
def cmd_SET_HOMING_HEATERS(self, gcmd):
self.threshold = gcmd.get("THRESHOLD", None)
if self.threshold is not None:
self.threshold = float(self.threshold)

def load_config(config):
return HomingHeaters(config)

0 comments on commit 33a333b

Please sign in to comment.