From fc4abbf680e884cacad065bb570bd4570886d725 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 11 Apr 2024 23:48:52 +0200 Subject: [PATCH] Custom threshold for PROBE_POINTS_INCREASING check on QGL and Z_TILT (#189) * Initial Implementation * Added readme * added ci tests --------- Co-authored-by: Rogerio Goncalves --- README.md | 2 ++ docs/Config_Reference.md | 8 ++++++++ docs/G-Codes.md | 4 +++- klippy/extras/z_tilt.py | 8 +++++++- klippy/extras/z_tilt_ng.py | 8 +++++++- test/klippy/z_tilt.cfg | 1 + test/klippy/z_tilt.test | 4 ++-- test/klippy/z_tilt_ng.cfg | 1 + test/klippy/z_tilt_ng.test | 4 ++-- 9 files changed, 33 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f77489abb..cb86c7508 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ If I want my printer to light itself on fire, I should be able to make my printe - [filament_switch|motion_sensor: runout distance, smart and runout gcode](https://github.com/DangerKlippers/danger-klipper/pull/158) +- [z_tilt|qgl: custom threshold for probe_points_increasing check](https://github.com/DangerKlippers/danger-klipper/pull/189) + - [save_config: save without restarting the firmware](https://github.com/DangerKlippers/danger-klipper/pull/191) - [configfile: recursive globs](https://github.com/DangerKlippers/danger-klipper/pull/200) / ([klipper#6375](https://github.com/Klipper3d/klipper/pull/6375)) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 5683dd79c..f5bcb880b 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -1319,6 +1319,9 @@ extended [G-Code command](G-Codes.md#z_tilt) becomes available. # more points than steppers then you will likely have a fixed # minimum value for the range of probed points which you can learn # by observing command output. +#increasing_threshold: 0.0000001 +# Sets the threshold that probe points can increase before z_tilt aborts. +# To disable the validation, set this parameter to a high value. ``` ``` @@ -1343,6 +1346,8 @@ extended [G-Code command](G-Codes.md#z_tilt) becomes available. # See [z_tilt] #retry_tolerance: 0 # See [z_tilt] +#increasing_threshold: 0.0000001 +# See [z_tilt] #extra_points: # A list in the same format as "points" above. This list contains # additional points to be probed during the two calibration commands @@ -1420,6 +1425,9 @@ Where x is the 0, 0 point on the bed #retry_tolerance: 0 # If retries are enabled then retry if largest and smallest probed # points differ more than retry_tolerance. +#increasing_threshold: 0.0000001 +# Sets the threshold that probe points can increase before qgl aborts. +# To disable the validation, set this parameter to a high value. ``` ### [skew_correction] diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 5fb72b10f..ec639b117 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -1799,11 +1799,13 @@ The following commands are available when the [z_tilt config section](Config_Reference.md#z_tilt) is enabled. #### Z_TILT_ADJUST -`Z_TILT_ADJUST [HORIZONTAL_MOVE_Z=] [=]`: This +`Z_TILT_ADJUST [HORIZONTAL_MOVE_Z=] [=] +[INCREASING_THRESHOLD=]`: This command will probe the points specified in the config and then make independent adjustments to each Z stepper to compensate for tilt. See the PROBE command for details on the optional probe parameters. The optional `HORIZONTAL_MOVE_Z` value overrides the `horizontal_move_z` option specified in the config file. +INCREASING_THRESHOLD sets the increasing_threshold parameter of z_tilt. The follwing commands are availabe when the parameter "extra_points" is configured in the z_tilt_ng section: - `Z_TILT_CALIBRATE [AVGLEN=]`: This command does multiple probe diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py index 948551f05..faf43f615 100644 --- a/klippy/extras/z_tilt.py +++ b/klippy/extras/z_tilt.py @@ -104,6 +104,9 @@ def __init__(self, config, error_msg_extra=""): self.default_retry_tolerance = config.getfloat( "retry_tolerance", 0.0, above=0.0 ) + self.default_increasing_threshold = config.getfloat( + "increasing_threshold", 0.0000001, above=0.0 + ) self.value_label = "Probed points range" self.error_msg_extra = error_msg_extra @@ -117,12 +120,15 @@ def start(self, gcmd): minval=0.0, maxval=1.0, ) + self.increasing_threshold = gcmd.get_float( + "INCREASING_THRESHOLD", self.default_increasing_threshold, above=0.0 + ) self.current_retry = 0 self.previous = None self.increasing = 0 def check_increase(self, error): - if self.previous and error > self.previous + 0.0000001: + if self.previous and error > self.previous + self.increasing_threshold: self.increasing += 1 elif self.increasing > 0: self.increasing -= 1 diff --git a/klippy/extras/z_tilt_ng.py b/klippy/extras/z_tilt_ng.py index f632aa856..0ab8aecdd 100644 --- a/klippy/extras/z_tilt_ng.py +++ b/klippy/extras/z_tilt_ng.py @@ -126,6 +126,9 @@ def __init__(self, config, error_msg_extra=""): self.default_retry_tolerance = config.getfloat( "retry_tolerance", 0.0, above=0.0 ) + self.default_increasing_threshold = config.getfloat( + "increasing_threshold", 0.0000001, above=0.0 + ) self.value_label = "Probed points range" self.error_msg_extra = error_msg_extra @@ -139,12 +142,15 @@ def start(self, gcmd): minval=0.0, maxval=1.0, ) + self.increasing_threshold = gcmd.get_float( + "INCREASING_THRESHOLD", self.default_increasing_threshold, above=0.0 + ) self.current_retry = 0 self.previous = None self.increasing = 0 def check_increase(self, error): - if self.previous and error > self.previous + 0.0000001: + if self.previous and error > self.previous + self.increasing_threshold: self.increasing += 1 elif self.increasing > 0: self.increasing -= 1 diff --git a/test/klippy/z_tilt.cfg b/test/klippy/z_tilt.cfg index 444b43c4b..405538522 100644 --- a/test/klippy/z_tilt.cfg +++ b/test/klippy/z_tilt.cfg @@ -73,6 +73,7 @@ points: 50,195 195,195 195,50 +increasing_threshold: 0.001 [bed_tilt] points: diff --git a/test/klippy/z_tilt.test b/test/klippy/z_tilt.test index ca6a8e10a..1324b328e 100644 --- a/test/klippy/z_tilt.test +++ b/test/klippy/z_tilt.test @@ -9,7 +9,7 @@ M400 GET_POSITION # Run Z_TILT_ADJUST in manual mode -Z_TILT_ADJUST METHOD=MANUAL +Z_TILT_ADJUST METHOD=MANUAL INCREASING_THRESHOLD=0.0000001 G1 Z2.909972 ACCEPT G1 Z2.924972 @@ -25,4 +25,4 @@ M400 GET_POSITION # Run again in automatic mode -Z_TILT_ADJUST +Z_TILT_ADJUST INCREASING_THRESHOLD=0.0000001 diff --git a/test/klippy/z_tilt_ng.cfg b/test/klippy/z_tilt_ng.cfg index 300d3089f..e20ed11c5 100644 --- a/test/klippy/z_tilt_ng.cfg +++ b/test/klippy/z_tilt_ng.cfg @@ -59,6 +59,7 @@ extra_points: 50,50 50,195 195,195 +increasing_threshold: 0.001 [extruder] step_pin: PA4 diff --git a/test/klippy/z_tilt_ng.test b/test/klippy/z_tilt_ng.test index 2649097ad..999ae0011 100644 --- a/test/klippy/z_tilt_ng.test +++ b/test/klippy/z_tilt_ng.test @@ -9,7 +9,7 @@ M400 GET_POSITION # Run Z_TILT_ADJUST in manual mode -Z_TILT_ADJUST METHOD=MANUAL +Z_TILT_ADJUST METHOD=MANUAL INCREASING_THRESHOLD=0.0000001 G1 Z2.909972 ACCEPT G1 Z2.924972 @@ -25,4 +25,4 @@ M400 GET_POSITION # Run again in automatic mode -Z_TILT_ADJUST +Z_TILT_ADJUST INCREASING_THRESHOLD=0.0000001