Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.98k stars 5.17k forks source link

temperature_probe: probe thermal drift compensation #6602

Open Arksine opened 1 month ago

Arksine commented 1 month ago

This adds a temperature_probe module that supports configuring a temperature sensor for use with inductive probes. This module implements the smoothing algorithm present in heaters and provides a temperature drift calibration procedure. The module is intended to be generic, it can be used with any kind of inductive probe, where the calibration logic is farmed out to the probe specific implementation. Also included in this PR is an implementation for the probe_eddy_current module.

The calibration procedure works by using the bed to heat the probe and requesting a manual probe before each sample. This is intended to filter out thermal expansion. Samples are taken at a specified temperature interval, by default this is set to every 2C. The best calibration is achieved by taking samples across the widest temperature range possible. After a manual probe, the probe_eddy_current module will take samples every .5mm, up to 4mm. These samples are used to create a series of 2nd degree polynomials at each height.

Compensation uses the current frequency and coil temperature the find the upper and lower polynomials, then performs linear interpolation to calculate the correct frequency at the target temperature (ie: the temperature of the coil during PROBE_EDDY_CURENT_CALIBRATE).

Attached is a plot of the "stock" height calculate vs the corrected height for a probe that has a good temperature calibration. This plot was measured by using the bed to heat the probe and performing a probe every 30 seconds, after which the height reported by the probe is collected. PROBE_EDDY_CURRENT_CALIBRATE was performed with the probe around 35C.

eddy-mounted-drift-correction

For comparison, I also collected data at a 1kHz sample rate. In addition, this data was collected with PROBE_EDDY_CURRENT_CALIBRATE close to 60C:

eddy-mounted-drift-correction-1khzrate

What stands out most in the above data is that the linear regression of the z-height is closer to the z_offset of .5.

This PR is built on #6558, so we likely need to address any outstanding issues with that PR first. Specific commits for this PR start at 108985cdc8af6c7cd315120b19b9fa06a9af2351. The last two commits are minor fixes to probe_eddy_current, one fixing a stale attribute name and one slightly bumping the delay time after a probe to avoid "Unable to obtain probe_eddy_current sensor readings" errors. If necessary I can drop these commits from this PR.

github-actions[bot] commented 3 weeks ago

Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html

There are some steps that you can take now:

  1. Perform a self-review of your Pull Request by following the steps at: https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review If you have completed a self-review, be sure to state the results of that self-review explicitly in the Pull Request comments. A reviewer is more likely to participate if the bulk of a review has already been completed.
  2. Consider opening a topic on the Klipper Discourse server to discuss this work. The Discourse server is a good place to discuss development ideas and to engage users interested in testing. Reviewers are more likely to prioritize Pull Requests with an active community of users.
  3. Consider helping out reviewers by reviewing other Klipper Pull Requests. Taking the time to perform a careful and detailed review of others work is appreciated. Regular contributors are more likely to prioritize the contributions of other regular contributors.

Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available.

Best regards, ~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.

Arksine commented 6 days ago

For those wondering about the status of this branch, I'm currently working on rebasing and resolving conflicts against the master branch. My goal is to push an updated version this weekend (by June 22).

smwoodward commented 6 days ago

For those wondering about the status of this branch, I'm currently working on rebasing and resolving conflicts against the master branch. My goal is to push an updated version this weekend (by June 22).

Are we able to move off the BTT branch of klipper?