From 407d2e0f61d28698edcde5146c6c56858983b137 Mon Sep 17 00:00:00 2001 From: Kurt Haenen Date: Tue, 16 Mar 2021 21:38:27 +0100 Subject: [PATCH 1/7] Add Z_SERVO_INTERMEDIATE_STOW qnd measuring angle for servo probe Option for a probe that is mechanically deployed by moving to a certain angle but then to allow measuring needs the servo to move back to make some room for the probe to move up without forcing the servo. --- Marlin/Configuration.h | 36 ++++++++++++++++----------- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/module/probe.cpp | 19 +++++++++++++- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 339dae7702d1..4198568158b0 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -715,7 +715,7 @@ #define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. +#define Z_MIN_PROBE_ENDSTOP_INVERTING true // Set to true to invert the logic of the probe. /** * Stepper Drivers @@ -898,10 +898,10 @@ * The probe replaces the Z-MIN endstop and is used for Z homing. * (Automatically enables USE_PROBE_FOR_Z_HOMING.) */ -#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN +//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN // Force the use of the probe for Z-axis homing -//#define USE_PROBE_FOR_Z_HOMING +#define USE_PROBE_FOR_Z_HOMING /** * Z_MIN_PROBE_PIN @@ -950,8 +950,10 @@ /** * Z Servo Probe, such as an endstop switch on a rotating arm. */ -//#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector. -//#define Z_SERVO_ANGLES { 70, 0 } // Z Servo Deploy and Stow angles +#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector. +#define Z_SERVO_ANGLES { 85, 0 } // Z Servo Deploy and Stow angles +#define Z_SERVO_MEASURE_ANGLE 45 // Z Servo Angle after deploy (to allow measuring) +#define Z_SERVO_INTERMEDIATE_STOW // Stow the probe between points /** * The BLTouch probe uses a Hall effect sensor and emulates a servo. @@ -1048,11 +1050,15 @@ * | [-] | * O-- FRONT --+ */ -#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 } +#define NOZZLE_TO_PROBE_OFFSET { -7, -5, 0 } // Most probes should stay away from the edges of the bed, but // with NOZZLE_AS_PROBE this can be negative for a wider probing area. -#define PROBING_MARGIN 10 +#define PROBING_MARGIN 0 +#define PROBING_MARGIN_LEFT 10 +#define PROBING_MARGIN_RIGHT 10 +#define PROBING_MARGIN_BACK 15 +#define PROBING_MARGIN_FRONT 15 // X and Y axis travel speed (mm/min) between probes #define XY_PROBE_FEEDRATE (133*60) @@ -1116,10 +1122,10 @@ * Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle. * But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle. */ -#define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow +#define Z_CLEARANCE_DEPLOY_PROBE 5 // Z Clearance for Deploy/Stow #define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points #define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes -//#define Z_AFTER_PROBING 5 // Z position after probing is done +#define Z_AFTER_PROBING 10 // Z position after probing is done #define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping @@ -1128,7 +1134,7 @@ #define Z_PROBE_OFFSET_RANGE_MAX 20 // Enable the M48 repeatability test to test probe accuracy -//#define Z_MIN_PROBE_REPEATABILITY_TEST +#define Z_MIN_PROBE_REPEATABILITY_TEST // Before deploy/stow pause for user confirmation //#define PAUSE_BEFORE_DEPLOY_STOW @@ -1211,10 +1217,10 @@ */ //#define Z_IDLE_HEIGHT Z_HOME_POS -//#define Z_HOMING_HEIGHT 4 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ... +#define Z_HOMING_HEIGHT 4 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ... // Be sure to have this much clearance over your Z_MAX_POS to prevent grinding. -//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z +#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z // Direction of endstops when homing; 1=MAX, -1=MIN // :[-1,1] @@ -1380,7 +1386,7 @@ */ //#define AUTO_BED_LEVELING_3POINT //#define AUTO_BED_LEVELING_LINEAR -//#define AUTO_BED_LEVELING_BILINEAR +#define AUTO_BED_LEVELING_BILINEAR //#define AUTO_BED_LEVELING_UBL //#define MESH_BED_LEVELING @@ -1389,7 +1395,7 @@ * these options to restore the prior leveling state or to always enable * leveling immediately after G28. */ -//#define RESTORE_LEVELING_AFTER_G28 +#define RESTORE_LEVELING_AFTER_G28 //#define ENABLE_LEVELING_AFTER_G28 /** @@ -1573,7 +1579,7 @@ // - Move the Z probe (or nozzle) to a defined XY point before Z Homing. // - Prevent Z homing when the Z probe is outside bed area. // -//#define Z_SAFE_HOMING +#define Z_SAFE_HOMING #if ENABLED(Z_SAFE_HOMING) #define Z_SAFE_HOMING_X_POINT X_CENTER // X point for Z homing diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index e642c1ccf256..73936010e043 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -420,7 +420,7 @@ G29_TYPE GcodeSuite::G29() { // Deploy certain probes before starting probing #if HAS_BED_PROBE - if (ENABLED(BLTOUCH)) + if (ANY(BLTOUCH,Z_SERVO_INTERMEDIATE_STOW)) do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); else if (probe.deploy()) { set_bed_leveling_enabled(abl_should_enable); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 28c89e7a00ee..c995602dac4e 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -319,7 +319,17 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #elif HAS_Z_SERVO_PROBE - MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + #ifdef Z_SERVO_MEASURE_ANGLE + if (deploy) { + // First deploy, then move servo back to measure angle ... + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0]); + MOVE_SERVO(Z_PROBE_SERVO_NR, Z_SERVO_MEASURE_ANGLE); + } else { + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1]); + } + #else + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + #endif #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) @@ -487,6 +497,9 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { #endif if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action + #ifdef Z_SERVO_MEASURE_ANGLE + probe_specific_action(true); // Always re-deploy if we have a separate measure state + #endif // Disable stealthChop if used. Enable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) @@ -528,6 +541,10 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger return true; + #if ENABLED(Z_SERVO_INTERMEDIATE_STOW) + probe_specific_action(false); // Always stow + #endif + // Clear endstop flags endstops.hit_on_purpose(); From 135c2de03f5d1eaadda66b8641491c1037a1ab96 Mon Sep 17 00:00:00 2001 From: Kurt Haenen Date: Tue, 16 Mar 2021 21:38:27 +0100 Subject: [PATCH 2/7] Add Z_SERVO_INTERMEDIATE_STOW and measuring angle for servo probe Option for a probe that is mechanically deployed by moving to a certain angle but then to allow measuring needs the servo to move back to make some room for the probe to move up without forcing the servo. --- Marlin/Configuration.h | 11 +++++++++-- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/module/probe.cpp | 19 ++++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c9c83f9bb624..ac7976ed0bf1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -950,9 +950,16 @@ /** * Z Servo Probe, such as an endstop switch on a rotating arm. + * + * The Z_SERVO_MEASURE_ANGLE is only useful if your servo needs to + * move to a "free" position to allow measuring. + * With Z_SERVO_INTERMEDIATE_STOW you can have the probe stowed + * between different points of a G29. */ -//#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector. -//#define Z_SERVO_ANGLES { 70, 0 } // Z Servo Deploy and Stow angles +//#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector. +//#define Z_SERVO_ANGLES { 70, 0 } // Z Servo Deploy and Stow angles +//#define Z_SERVO_MEASURE_ANGLE 45 // Z Servo Angle after deploy (to allow measuring) +//#define Z_SERVO_INTERMEDIATE_STOW // Stow the probe between points /** * The BLTouch probe uses a Hall effect sensor and emulates a servo. diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a746b86108eb..caabd55927ed 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -420,7 +420,7 @@ G29_TYPE GcodeSuite::G29() { // Deploy certain probes before starting probing #if HAS_BED_PROBE - if (ENABLED(BLTOUCH)) + if (ANY(BLTOUCH,Z_SERVO_INTERMEDIATE_STOW)) do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); else if (probe.deploy()) { set_bed_leveling_enabled(abl_should_enable); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 28c89e7a00ee..cddd8508b321 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -319,7 +319,17 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #elif HAS_Z_SERVO_PROBE - MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + #ifdef Z_SERVO_MEASURE_ANGLE + if (deploy) { + // First deploy, then move servo back to measure angle ... + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0]); + MOVE_SERVO(Z_PROBE_SERVO_NR, Z_SERVO_MEASURE_ANGLE); + } else { + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1]); + } + #else + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + #endif #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) @@ -487,6 +497,9 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { #endif if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action + #if ANY(Z_SERVO_MEASURE_ANGLE, Z_SERVO_INTERMEDIATE_STOW) + probe_specific_action(true); // Always re-deploy in this case + #endif // Disable stealthChop if used. Enable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) @@ -528,6 +541,10 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger return true; + #if ENABLED(Z_SERVO_INTERMEDIATE_STOW) + probe_specific_action(false); // Always stow + #endif + // Clear endstop flags endstops.hit_on_purpose(); From c4d2c9df1230b5ca954660fe0ab3be33bd9af519 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 31 Mar 2021 02:45:42 -0500 Subject: [PATCH 3/7] Update G29.cpp --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index caabd55927ed..3d34f638ea85 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -420,7 +420,7 @@ G29_TYPE GcodeSuite::G29() { // Deploy certain probes before starting probing #if HAS_BED_PROBE - if (ANY(BLTOUCH,Z_SERVO_INTERMEDIATE_STOW)) + if (EITHER(BLTOUCH, Z_SERVO_INTERMEDIATE_STOW)) do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); else if (probe.deploy()) { set_bed_leveling_enabled(abl_should_enable); From 30d36ef83b2651f0991cddad6dac164d40e93d1a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 31 Mar 2021 02:48:16 -0500 Subject: [PATCH 4/7] Update probe.cpp --- Marlin/src/module/probe.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index cddd8508b321..2b9602205699 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -319,16 +319,11 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #elif HAS_Z_SERVO_PROBE + MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + #ifdef Z_SERVO_MEASURE_ANGLE - if (deploy) { - // First deploy, then move servo back to measure angle ... - MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0]); - MOVE_SERVO(Z_PROBE_SERVO_NR, Z_SERVO_MEASURE_ANGLE); - } else { - MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1]); - } - #else - MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + // After deploy move back to the measure angle... + if (deploy) MOVE_SERVO(Z_PROBE_SERVO_NR, Z_SERVO_MEASURE_ANGLE); #endif #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) From bb7e5ceff5acbc1f1cf61fa730688da41411c722 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 31 Mar 2021 02:49:06 -0500 Subject: [PATCH 5/7] Update probe.cpp --- Marlin/src/module/probe.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 2b9602205699..030a64474e72 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -492,7 +492,8 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { #endif if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action - #if ANY(Z_SERVO_MEASURE_ANGLE, Z_SERVO_INTERMEDIATE_STOW) + + #if EITHER(Z_SERVO_MEASURE_ANGLE, Z_SERVO_INTERMEDIATE_STOW) probe_specific_action(true); // Always re-deploy in this case #endif From 735e40690531d765f0d57966771ab4328b9825ef Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 20 Apr 2022 04:40:27 -0500 Subject: [PATCH 6/7] fix Z_SERVO_MEASURE_ANGLE --- Marlin/src/module/probe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index e07c0e749ae7..757b64e9fbcb 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -532,7 +532,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { return true; // Deploy in LOW SPEED MODE on every probe action #endif - #if EITHER(Z_SERVO_MEASURE_ANGLE, Z_SERVO_INTERMEDIATE_STOW) + #if ENABLED(Z_SERVO_INTERMEDIATE_STOW) || defined(Z_SERVO_MEASURE_ANGLE) probe_specific_action(true); // Always re-deploy in this case #endif From 8092cf1c23bf8150ae2708417c9ffdae29b61ae7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Mar 2023 00:07:43 -0600 Subject: [PATCH 7/7] adjust --- Marlin/Configuration.h | 9 ++------- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/module/probe.cpp | 5 +++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6de5a816eb65..77f190890149 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1387,16 +1387,11 @@ /** * Z Servo Probe, such as an endstop switch on a rotating arm. - * - * The Z_SERVO_MEASURE_ANGLE is only useful if your servo needs to - * move to a "free" position to allow measuring. - * With Z_SERVO_INTERMEDIATE_STOW you can have the probe stowed - * between different points of a G29. */ //#define Z_PROBE_SERVO_NR 0 // Defaults to SERVO 0 connector. //#define Z_SERVO_ANGLES { 70, 0 } // Z Servo Deploy and Stow angles -//#define Z_SERVO_MEASURE_ANGLE 45 // Z Servo Angle after deploy (to allow measuring) -//#define Z_SERVO_INTERMEDIATE_STOW // Stow the probe between points +//#define Z_SERVO_MEASURE_ANGLE 45 // Use if the servo must move to a "free" position for measuring after deploy. +//#define Z_SERVO_INTERMEDIATE_STOW // Stow the probe between points. /** * The BLTouch probe uses a Hall effect sensor and emulates a servo. diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 4a638e087f9b..114fa55520c3 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -491,7 +491,7 @@ G29_TYPE GcodeSuite::G29() { if (!no_action) set_bed_leveling_enabled(false); // Deploy certain probes before starting probing - #if EITHER(BLTOUCH, Z_SERVO_INTERMEDIATE_STOW) + #if ENABLED(BLTOUCH) || BOTH(HAS_Z_SERVO_PROBE, Z_SERVO_INTERMEDIATE_STOW) do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); #elif HAS_BED_PROBE if (probe.deploy()) { // (returns true on deploy failure) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 5a1ae7f34916..7daafd113981 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -587,12 +587,13 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if BOTH(HAS_TEMP_HOTEND, WAIT_FOR_HOTEND) thermalManager.wait_for_hotend_heating(active_extruder); #endif + #if ENABLED(BLTOUCH) if (!bltouch.high_speed_mode && bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action #endif - #if ENABLED(Z_SERVO_INTERMEDIATE_STOW) || defined(Z_SERVO_MEASURE_ANGLE) + #if HAS_Z_SERVO_PROBE && (ENABLED(Z_SERVO_INTERMEDIATE_STOW) || defined(Z_SERVO_MEASURE_ANGLE)) probe_specific_action(true); // Always re-deploy in this case #endif @@ -645,7 +646,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { return true; // Stow in LOW SPEED MODE on every trigger #endif - #if ENABLED(Z_SERVO_INTERMEDIATE_STOW) + #if BOTH(HAS_Z_SERVO_PROBE, Z_SERVO_INTERMEDIATE_STOW) probe_specific_action(false); // Always stow #endif