Skip to content

Commit

Permalink
add configuration check for virtual endstops, add default for bed pro…
Browse files Browse the repository at this point in the history
…bing site from bed mesh
  • Loading branch information
TitusLabs committed May 17, 2021
1 parent 5e45237 commit 0a809f4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ together do **not** affect the first layer at all.

Here is a small video demonstration: [https://streamable.com/wclrmc](https://streamable.com/wclrmc)

> **NEW:** The probing repeatability is now increased dramatically by using the probing
> procedure instead of the homing procedure! But note, the offset will change slightly,
> if Z is homed again or temperatures changes - but this is as intended.
## New

- **v0.4**: The bed probing point can be omitted and the `relative_reference_index` of
the bed mesh is taken as default instead.
- **v0.3**: A new option to first probe down fast before recording the probing samples.
And all indirect properties from other sections can be customized now.
- **v0.2**: The probing repeatability is now increased dramatically by using the probing
procedure instead of the homing procedure! But note, the offset will change slightly,
if Z is homed again or temperatures changes - but this is as intended!

## Why this

Expand Down Expand Up @@ -113,11 +119,14 @@ probe_switch_x:
probe_switch_y:
# The X and Y coordinates (in mm) for clicking the probe's switch
# on the Z endstop.
probe_bed_x:
probe_bed_y:
probe_bed_x: default from relative_reference_index of bed_mesh
probe_bed_y: default from relative_reference_index of bed_mesh
# The X and Y coordinates (in mm) for probing on the print surface
# (e.g. the center point) These coordinates will be adapted by the
# probe's X and Y offsets.
# probe's X and Y offsets. The default is the relative_reference_index
# of the configured bed_mesh. It will raise an error if there is no
# probe_bed site and no bed_mesh with a relative_reference_index
# configured.
switch_offset:
# The trigger point offset of the used mag-probe switch.
# This needs to be fined out manually. More on this later
Expand Down Expand Up @@ -167,8 +176,10 @@ probing_first_fast: false
```

**CAUTION: If you use a bed mesh, the coordinates for probing on the print bed must be
exaclty the reference point of the mesh since this is the zero point - otherwise, you would
get into trouble!**
exactly the relative reference point of the mesh since this is the zero point! In this
case, you can ommit these properties and as default the relative reference point of the
mesh will be taken automatically (the `relative_reference_index` of the `bed_mesh` is
required for this)!**

The `switch_offset` is the already mentioned offset from the switch body (which is the
probed position) to the actual trigger point. A starting point can be taken from the
Expand Down
25 changes: 22 additions & 3 deletions z_calibration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from mcu import MCU_endstop

class ZCalibrationHelper:
def __init__(self, config):
Expand Down Expand Up @@ -36,8 +37,8 @@ def __init__(self, config):
None,
]
self.probe_bed_site = [
config.getfloat('probe_bed_x'),
config.getfloat('probe_bed_y'),
config.getfloat('probe_bed_x', None),
config.getfloat('probe_bed_y', None),
None,
]

Expand All @@ -59,9 +60,15 @@ def handle_connect(self):
# get z-endstop
for endstop, name in self.query_endstops.endstops:
if name == 'z':
# check for virtual endstops..
if not isinstance(endstop, MCU_endstop):
raise self.printer.config_error(
"No virtual endstops for z are supported for calibrate_z module!")
self.z_endstop = EndstopWrapper(self.config, endstop)
# get probing settings
probe = self.printer.lookup_object('probe')
probe = self.printer.lookup_object('probe', default=None)
if probe is None:
raise self.printer.config_error("A configured probe is needed for calibrate_z module!")
if self.probing_samples is None:
self.probing_samples = probe.sample_count
if self.probing_samples_tolerance is None:
Expand All @@ -74,6 +81,18 @@ def handle_connect(self):
self.probing_clearance = probe.z_offset * 2
if self.probing_samples_result is None:
self.probing_samples_result = probe.samples_result
# get the mesh's relative reference point
if self.probe_bed_site[0] is None or self.probe_bed_site[1] is None:
mesh = self.printer.lookup_object('bed_mesh', default=None)
if mesh is None or mesh.bmc.relative_reference_index is None:
raise self.printer.config_error(
"Either configure probe_bed_x and probe_bed_y or configure "
"a mesh with a relative_reference_index for calibrate_z module!")
rri = mesh.bmc.relative_reference_index
self.probe_bed_site[0] = mesh.bmc.points[rri][0]
self.probe_bed_site[1] = mesh.bmc.points[rri][1]
logging.debug("Z-CALIBRATION probe_bed_x=%.3f probe_bed_y=%.3f"
% (self.probe_bed_site[0], self.probe_bed_site[1]))

def handle_home_rails_end(self, homing_state, rails):
# get z homing position
Expand Down

0 comments on commit 0a809f4

Please sign in to comment.