diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index f19f0ebc1729..e4c70937583f 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2458,6 +2458,10 @@ postfix for both sections. # "calibration_extruder_temp" option is set. Its recommended to heat # the extruder some distance from the bed to minimize its impact on # the probe coil temperature. The default is 50. +#max_validation_temp: 60. +# The maximum temperature used to validate the calibration. It is +# recommended to set this to a value between 100 and 120 for enclosed +# printers. The default is 60. ``` ## Temperature sensors diff --git a/docs/Eddy_Probe.md b/docs/Eddy_Probe.md index 5fa7fc4d30b7..3c36a613c181 100644 --- a/docs/Eddy_Probe.md +++ b/docs/Eddy_Probe.md @@ -78,7 +78,9 @@ for further details on how to configure a `temperature_probe`. It is advised to configure the `calibration_position`, `calibration_extruder_temp`, `extruder_heating_z`, and `calibration_bed_temp` options, as doing so will automate some of the -steps outlined below. +steps outlined below. If the printer to be calibrated is enclosed, it +is strongly recommended to set the `max_validation_temp` option to a value +between 100 and 120. Eddy probe manufacturers may offer a stock drift calibration that can be manually added to `drift_calibration` option of the `[probe_eddy_current]` diff --git a/klippy/extras/temperature_probe.py b/klippy/extras/temperature_probe.py index ae285ce36291..05eac34ef984 100644 --- a/klippy/extras/temperature_probe.py +++ b/klippy/extras/temperature_probe.py @@ -490,6 +490,7 @@ def __init__(self, config, sensor): self.cal_temp = config.getfloat("calibration_temp", 0.) self.drift_calibration = None self.calibration_samples = None + self.max_valid_temp = config.getfloat("max_validation_temp", 60.) self.dc_min_temp = config.getfloat("drift_calibration_min_temp", 0.) dc = config.getlists( "drift_calibration", None, seps=(',', '\n'), parser=float @@ -503,7 +504,8 @@ def __init__(self, config, sensor): ) self.drift_calibration = [Polynomial2d(*coefs) for coefs in dc] cal = self.drift_calibration - self._check_calibration(cal, self.dc_min_temp, config.error) + start_temp, end_temp = self.dc_min_temp, self.max_valid_temp + self._check_calibration(cal, start_temp, end_temp, config.error) low_poly = self.drift_calibration[-1] self.min_freq = min([low_poly(temp) for temp in range(121)]) cal_str = "\n".join([repr(p) for p in cal]) @@ -638,13 +640,15 @@ def finish_calibration(self, success): "calbration error, not enough samples" ) min_temp, _ = cal_samples[0][0] + max_temp, _ = cal_samples[-1][0] polynomials = [] for i, coords in enumerate(cal_samples): height = .05 + i * .5 poly = Polynomial2d.fit(coords) polynomials.append(poly) logging.info("Polynomial at Z=%.2f: %s" % (height, repr(poly))) - self._check_calibration(polynomials, min_temp) + end_vld_temp = max(self.max_valid_temp, max_temp) + self._check_calibration(polynomials, min_temp, end_vld_temp) coef_cfg = "\n" + "\n".join([str(p) for p in polynomials]) configfile = self.printer.lookup_object('configfile') configfile.set(self.name, "drift_calibration", coef_cfg) @@ -656,10 +660,11 @@ def finish_calibration(self, success): % (self.name, len(polynomials)) ) - def _check_calibration(self, calibration, start_temp, error=None): + def _check_calibration(self, calibration, start_temp, end_temp, error=None): error = error or self.printer.command_error start = int(start_temp) - for temp in range(start, 121, 1): + end = int(end_temp) + 1 + for temp in range(start, end, 1): last_freq = calibration[0](temp) for i, poly in enumerate(calibration[1:]): next_freq = poly(temp) diff --git a/src/stm32/stm32g4.c b/src/stm32/stm32g4.c index 1eed3ec188d6..5255cb19a490 100644 --- a/src/stm32/stm32g4.c +++ b/src/stm32/stm32g4.c @@ -104,7 +104,7 @@ enable_clock_stm32g4(void) RCC->CR |= RCC_CR_PLLON; // Enable 48Mhz USB clock using clock recovery - if (CONFIG_USBSERIAL) { + if (CONFIG_USB) { RCC->CRRCR |= RCC_CRRCR_HSI48ON; while (!(RCC->CRRCR & RCC_CRRCR_HSI48RDY)) ; diff --git a/src/stm32/stm32l4.c b/src/stm32/stm32l4.c index 7db15fff0ba2..ae099d6bc6a5 100644 --- a/src/stm32/stm32l4.c +++ b/src/stm32/stm32l4.c @@ -96,7 +96,7 @@ enable_clock_stm32l4(void) RCC->CR |= RCC_CR_PLLON; // Enable 48Mhz USB clock using clock recovery - if (CONFIG_USBSERIAL) { + if (CONFIG_USB) { RCC->CRRCR |= RCC_CRRCR_HSI48ON; while (!(RCC->CRRCR & RCC_CRRCR_HSI48RDY)) ;