While troubleshooting a weird glitch where I always got an height error of ~0.4mm when using the inductive sensor to set Z=0 with G30 and a fixed trigger offset (can be read here: https://forum.duet3d.com/topic/18239/bl-touch-and-distance-printing-nozzle ), I "accidentaly" found a way to completely automate Z-homing with Z-probe offset adjustment. 😀
It basically boils down to only 2 simple steps:
set Z=0 via the endswitch (G1 H1 + G92 Z0) calibrate the probe trigger distance with G30 S-3 at Z=0I've mounted the Z-endswitch directly next to the printbed at the far right corner. The Z-probe is still above the bed, so i only have to move a few mm to clear the endswitch and calibrate the trigger distance.
The only caveat of this method: The bed height has to correspond exactly to the trigger height of the endswitch. This can be easily adjusted by setting Z=0 on the endswitch, then moving over the bed and manually move to Z=0 and adjusting the bed so the nozzle touches the surface at Z=0 height.
To use the Z-endstop the axis has to be configured to use a switch, not the probe, but the probe is still defined via M558 and a trigger value but no offset is set:
config.g [...] M574 Z1 S1 P"!zstop" M558 P1 C"!zprobe.in" H20 A5 F600 T18000 ; set Z probe type to unmodulated and the dive height + speeds G31 P500 ; set Z probe trigger value. trigger distance is set during Z homingThe complete Z-homing procedure looks like follows:
; homez.g M561 ; cancel all bed mesh compensations M558 P1 C"!zprobe.in" H15 F300 ; increase dive height to prevent crashing into a tilted bed ; probe and adjust the bed tilt G90 G30 P0 X50 Y165 Z-99999 ; probe near a leadscrew G30 P1 X350 Y165 Z-99999 S2 ; probe near a leadscrew M558 P1 C"!zprobe.in" H5 ; reduce dive height after adjusting the bed ; move over endswitch to set Z=0 G1 X341 Y310 F18000 G1 H1 Z-350 F600 ; move quickly to Z axis endstop and stop there (first pass) G1 Z5 F1200 ; move up a few mm G1 H1 Z-6 F300 ; move slowly to Z axis endstop once more (second pass) G92 Z0 ; set Z=0 G1 Z15 F1200 ; lift printhead ; calibrate probe trigger distance G1 X341 Y313 F18000 ; move directly next to the switch to calibrate the probe G30 S-3 ; set probe trigger height G1 Z15 F1200 ; lift printhead G1 X0 Y330 Z20 F18000 ; move printhead to the backFor now this gives pretty consistent results and mesh compensation is working reliably. Even with deliberately introduced errors, the nozzle is just touching the bed when moving to Z=0 at any position.