Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom threshold for PROBE_POINTS_INCREASING check on QGL and Z_TILT #189

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading