Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Apr 3, 2024
1 parent b9654d6 commit 07e3830
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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, z_tilt_ng and qgl: threshold for probe_points_increasing check](https://github.com/DangerKlippers/danger-klipper/pull/189)

If you're feeling adventurous, take a peek at the extra features in the bleeding-edge branch [feature documentation](docs/Bleeding_Edge.md)
and [feature configuration reference](docs/Config_Reference_Bleeding_Edge.md):

Expand Down
17 changes: 8 additions & 9 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,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 @@ -1332,6 +1335,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 @@ -1409,6 +1414,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 Expand Up @@ -4764,17 +4772,13 @@ more information.
# detected. See docs/Command_Templates.md for G-Code format. If
# pause_on_runout is set to True this G-Code will run after the
# PAUSE is complete. The default is not to run any G-Code commands.
#immediate_runout_gcode:
# A list of G-Code commands to execute immediately after a filament
# runout is detected and runout_distance is greater than 0.
# See docs/Command_Templates.md for G-Code format.
#insert_gcode:
# A list of G-Code commands to execute after a filament insert is
# detected. See docs/Command_Templates.md for G-Code format. The
# default is not to run any G-Code commands, which disables insert
# detection.
#runout_distance: 0.0
# Defines how much filament can still be pulled after the
# switch sensor triggered (e.g. you have a 60cm reverse bowden between your
# extruder and your sensor, you would then set runout_distance to something
# like 590 to leave a small safety margin and now the print will not
Expand All @@ -4792,8 +4796,6 @@ more information.
#switch_pin:
# The pin on which the switch is connected. This parameter must be
# provided.
#smart:
# If set to true the sensor will use the virtual_sd_card module to determine
# whether the printer is printing which is more reliable but will not work
# when streaming a print over usb or similar.
```
Expand Down Expand Up @@ -4822,7 +4824,6 @@ switch_pin:
#insert_gcode:
#event_delay:
#pause_delay:
#smart:
# See the "filament_switch_sensor" section for a description of the
# above parameters.
```
Expand Down Expand Up @@ -4901,8 +4902,6 @@ adc2:
# above parameters.
```

### [belay]

Belay extruder sync sensors (one may define any number of sections
with a "belay" prefix).

Expand Down
7 changes: 6 additions & 1 deletion docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ RESET resets the state of the sensor and sets it to filament detected. <br>
DETECTION_LENGTH sets the detection_length, if the new detection length is
different from the old one, a reset will be triggered. <br>
SMART sets the smart parameter.
`SET_FILAMENT_SENSOR SENSOR=<sensor_name> ENABLE=[0|1]`: Sets the
filament sensor on/off. If ENABLE is set to 0, the filament sensor
will be disabled, if set to 1 it is enabled.

### [firmware_retraction]

Expand Down Expand Up @@ -1594,11 +1597,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
9 changes: 8 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.get_float(
"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 Expand Up @@ -187,6 +193,7 @@ def probe_finalize(self, offsets, positions):
z_offset = offsets[2]
logging.info("Calculating bed tilt with: %s", positions)
params = {"x_adjust": 0.0, "y_adjust": 0.0, "z_adjust": z_offset}

# Perform coordinate descent
def adjusted_height(pos, params):
x, y, z = pos
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.get_float(
"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

0 comments on commit 07e3830

Please sign in to comment.