Skip to content

Commit

Permalink
Custom threshold for PROBE_POINTS_INCREASING check on QGL and Z_TILT (#…
Browse files Browse the repository at this point in the history
…189)

* Initial Implementation

* Added readme

* added ci tests

---------

Co-authored-by: Rogerio Goncalves <[email protected]>
  • Loading branch information
Zeanon and rogerlz authored Apr 11, 2024
1 parent d209dee commit fc4abbf
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 8 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```

```
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<value>] [<probe_parameter>=<value>]`: This
`Z_TILT_ADJUST [HORIZONTAL_MOVE_Z=<value>] [<probe_parameter>=<value>]
[INCREASING_THRESHOLD=<value>]`: 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=<value>]`: This command does multiple probe
Expand Down
8 changes: 7 additions & 1 deletion klippy/extras/z_tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion klippy/extras/z_tilt_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/klippy/z_tilt.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ points:
50,195
195,195
195,50
increasing_threshold: 0.001

[bed_tilt]
points:
Expand Down
4 changes: 2 additions & 2 deletions test/klippy/z_tilt.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,4 +25,4 @@ M400
GET_POSITION

# Run again in automatic mode
Z_TILT_ADJUST
Z_TILT_ADJUST INCREASING_THRESHOLD=0.0000001
1 change: 1 addition & 0 deletions test/klippy/z_tilt_ng.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extra_points:
50,50
50,195
195,195
increasing_threshold: 0.001

[extruder]
step_pin: PA4
Expand Down
4 changes: 2 additions & 2 deletions test/klippy/z_tilt_ng.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,4 +25,4 @@ M400
GET_POSITION

# Run again in automatic mode
Z_TILT_ADJUST
Z_TILT_ADJUST INCREASING_THRESHOLD=0.0000001

0 comments on commit fc4abbf

Please sign in to comment.