Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xD34D committed Sep 5, 2024
2 parents 82de58a + 08a1c9f commit 1a6c66a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docs/Eddy_Probe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
Expand Down
13 changes: 9 additions & 4 deletions klippy/extras/temperature_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/stm32/stm32g4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
;
Expand Down
2 changes: 1 addition & 1 deletion src/stm32/stm32l4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
;
Expand Down

0 comments on commit 1a6c66a

Please sign in to comment.