From 6e01ba3ce8593f6fb75e76b2e69b9c1c5142544e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 9 Nov 2025 17:33:29 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Probe=20cod?= =?UTF-8?q?e=20refinements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 3 +- Marlin/src/gcode/calibrate/G33.cpp | 6 +-- Marlin/src/inc/Conditionals-5-post.h | 3 ++ Marlin/src/inc/SanityCheck.h | 78 +++++++++++----------------- Marlin/src/module/motion.cpp | 4 +- Marlin/src/module/probe.cpp | 16 +++--- Marlin/src/module/probe.h | 34 +++++++----- 7 files changed, 71 insertions(+), 73 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e51d16d565..a327c406ef 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1053,7 +1053,8 @@ // Delta radius and diagonal rod adjustments //#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 } // (mm) //#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 } // (mm) -#endif + +#endif // DELTA // @section scara diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 1eabb30ffa..0a8dd459ca 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -380,9 +380,9 @@ static float auto_tune_a(const float dcr) { * With HAS_DELTA_SENSORLESS_PROBING: * Use these flags to calibrate stall sensitivity: * Example: G33 P1 Y Z - to calibrate X only - * X Don't activate stallguard on X - * Y Don't activate stallguard on Y - * Z Don't activate stallguard on Z + * X Don't activate StallGuard on X + * Y Don't activate StallGuard on Y + * Z Don't activate StallGuard on Z * S Save offset_sensorless_adj */ void GcodeSuite::G33() { diff --git a/Marlin/src/inc/Conditionals-5-post.h b/Marlin/src/inc/Conditionals-5-post.h index 4bed697726..77982c2c0b 100644 --- a/Marlin/src/inc/Conditionals-5-post.h +++ b/Marlin/src/inc/Conditionals-5-post.h @@ -3303,6 +3303,9 @@ #if ANY(ADVANCED_PAUSE_FEATURE, PROBING_HEATERS_OFF) #define HEATER_IDLE_HANDLER 1 #endif +#if ENABLED(DELTA) + #undef PROBING_STEPPERS_OFF +#endif #if HAS_BED_PROBE && (ANY(PROBING_HEATERS_OFF, PROBING_STEPPERS_OFF, PROBING_ESTEPPERS_OFF, PROBING_FANS_OFF) || DELAY_BEFORE_PROBING > 0) #define HAS_QUIET_PROBING 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f5c593fccd..c13c0ded82 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1277,53 +1277,22 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, BD_SENSOR, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE, BIQU_MICROPROBE_V1, BIQU_MICROPROBE_V2) #error "Please enable only one probe option. See the following errors:" - #if ENABLED(BLTOUCH) - #error "(BLTOUCH is enabled.)" - #elif HAS_Z_SERVO_PROBE - #error "(Z_SERVO_PROBE is enabled.)" - #endif - #if ENABLED(PROBE_MANUALLY) - #error "(PROBE_MANUALLY is enabled.)" - #endif - #if ENABLED(BD_SENSOR) - #error "(BD_SENSOR is enabled.)" - #endif - #if ENABLED(FIX_MOUNTED_PROBE) - #error "(FIX_MOUNTED_PROBE is enabled.)" - #endif - #if ENABLED(NOZZLE_AS_PROBE) - #error "(NOZZLE_AS_PROBE is enabled.)" - #endif - #if ENABLED(TOUCH_MI_PROBE) - #error "(TOUCH_MI_PROBE is enabled.)" - #endif - #if ENABLED(SOLENOID_PROBE) - #error "(SOLENOID_PROBE is enabled.)" - #endif - #if ENABLED(Z_PROBE_ALLEN_KEY) - #error "(Z_PROBE_ALLEN_KEY is enabled.)" - #endif - #if ENABLED(Z_PROBE_SLED) - #error "(Z_PROBE_SLED is enabled.)" - #endif - #if ENABLED(RACK_AND_PINION_PROBE) - #error "(RACK_AND_PINION_PROBE is enabled.)" - #endif - #if ENABLED(SENSORLESS_PROBING) - #error "(SENSORLESS_PROBING is enabled.)" - #endif - #if ENABLED(MAGLEV4) - #error "(MAGLEV4 is enabled.)" - #endif - #if ENABLED(MAG_MOUNTED_PROBE) - #error "(MAG_MOUNTED_PROBE is enabled.)" - #endif - #if ENABLED(BIQU_MICROPROBE_V1) - #error "(BIQU_MICROPROBE_V1 is enabled.)" - #endif - #if ENABLED(BIQU_MICROPROBE_V2) - #error "(BIQU_MICROPROBE_V2 is enabled.)" - #endif + static_assert(DISABLED(BLTOUCH), "(BLTOUCH is enabled.)"); + static_assert(ENABLED(BLTOUCH) || DISABLED(HAS_Z_SERVO_PROBE), "(Z_SERVO_PROBE is enabled.)"); + static_assert(DISABLED(PROBE_MANUALLY), "(PROBE_MANUALLY is enabled.)"); + static_assert(DISABLED(BD_SENSOR), "(BD_SENSOR is enabled.)"); + static_assert(DISABLED(FIX_MOUNTED_PROBE), "(FIX_MOUNTED_PROBE is enabled.)"); + static_assert(DISABLED(NOZZLE_AS_PROBE), "(NOZZLE_AS_PROBE is enabled.)"); + static_assert(DISABLED(TOUCH_MI_PROBE), "(TOUCH_MI_PROBE is enabled.)"); + static_assert(DISABLED(SOLENOID_PROBE), "(SOLENOID_PROBE is enabled.)"); + static_assert(DISABLED(Z_PROBE_ALLEN_KEY), "(Z_PROBE_ALLEN_KEY is enabled.)"); + static_assert(DISABLED(Z_PROBE_SLED), "(Z_PROBE_SLED is enabled.)"); + static_assert(DISABLED(RACK_AND_PINION_PROBE), "(RACK_AND_PINION_PROBE is enabled.)"); + static_assert(DISABLED(SENSORLESS_PROBING), "(SENSORLESS_PROBING is enabled.)"); + static_assert(DISABLED(MAGLEV4), "(MAGLEV4 is enabled.)"); + static_assert(DISABLED(MAG_MOUNTED_PROBE), "(MAG_MOUNTED_PROBE is enabled.)"); + static_assert(DISABLED(BIQU_MICROPROBE_V1), "(BIQU_MICROPROBE_V1 is enabled.)"); + static_assert(DISABLED(BIQU_MICROPROBE_V2), "(BIQU_MICROPROBE_V2 is enabled.)"); #endif #if HAS_BED_PROBE @@ -1500,7 +1469,6 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #elif !PIN_EXISTS(PROBE_ENABLE) #error "BIQU MicroProbe requires a PROBE_ENABLE_PIN." #endif - #if ENABLED(BIQU_MICROPROBE_V1) #if ENABLED(INVERTED_PROBE_STATE) #if Z_MIN_PROBE_ENDSTOP_HIT_STATE != LOW @@ -1518,6 +1486,13 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #error "BIQU_MICROPROBE_V1 requires Z_MIN_ENDSTOP_HIT_STATE HIGH." #endif #endif + #if NONE(ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUP_ZMIN_PROBE) + #if USE_Z_MIN_PROBE + #error "BIQU_MICROPROBE_V1 on Z_MIN_PROBE_PIN requires ENDSTOPPULLUP_ZMIN_PROBE, or ENDSTOPPULLUPS." + #else + #error "BIQU_MICROPROBE_V1 on Z_MIN_PIN requires ENDSTOPPULLUP_ZMIN, or ENDSTOPPULLUPS." + #endif + #endif #elif ENABLED(BIQU_MICROPROBE_V2) #if ENABLED(INVERTED_PROBE_STATE) #if Z_MIN_PROBE_ENDSTOP_HIT_STATE != HIGH @@ -1536,6 +1511,13 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #endif #endif #endif + #if NONE(ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUP_ZMIN_PROBE) + #if USE_Z_MIN_PROBE + #error "BIQU_MICROPROBE_V2 on Z_MIN_PROBE_PIN requires ENDSTOPPULLUP_ZMIN_PROBE, or ENDSTOPPULLUPS." + #else + #error "BIQU_MICROPROBE_V2 on Z_MIN_PIN requires ENDSTOPPULLUP_ZMIN, or ENDSTOPPULLUPS." + #endif + #endif #endif // BIQU_MICROPROBE_V1 || BIQU_MICROPROBE_V2 /** diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index cb99000451..cf524cbdb9 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -2207,7 +2207,7 @@ void prepare_line_to_destination() { thermalManager.wait_for_hotend_heating(active_extruder); #endif - TERN_(HAS_QUIET_PROBING, if (final_approach) probe.set_probing_paused(true)); + TERN_(HAS_QUIET_PROBING, if (final_approach) probe.set_devices_paused_for_probing(true)); } // Disable stealthChop if used. Enable diag1 pin on driver. @@ -2246,7 +2246,7 @@ void prepare_line_to_destination() { if (is_home_dir) { #if HOMING_Z_WITH_PROBE && HAS_QUIET_PROBING - if (axis == Z_AXIS && final_approach) probe.set_probing_paused(false); + if (axis == Z_AXIS && final_approach) probe.set_devices_paused_for_probing(false); #endif endstops.validate_homing_move(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 937b8ebeeb..ae688a864e 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -347,12 +347,16 @@ xyz_pos_t Probe::offset; // Initialized by settings.load #define DELAY_BEFORE_PROBING 25 #endif - void Probe::set_probing_paused(const bool dopause) { + /** + * Optionally turn off noisy components so we get a cleaner probe signal. + * Pause for at least 25ms when preparing to probe (dopause == true). + */ + void Probe::set_devices_paused_for_probing(const bool dopause) { TERN_(PROBING_HEATERS_OFF, thermalManager.pause_heaters(dopause)); TERN_(PROBING_FANS_OFF, thermalManager.set_fans_paused(dopause)); TERN_(PROBING_ESTEPPERS_OFF, if (dopause) stepper.disable_e_steppers()); - #if ENABLED(PROBING_STEPPERS_OFF) && DISABLED(DELTA) - static uint8_t old_trusted; + #if ENABLED(PROBING_STEPPERS_OFF) + static main_axes_bits_t old_trusted; if (dopause) { old_trusted = axes_trusted; stepper.disable_axis(X_AXIS); @@ -660,7 +664,7 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { endstops.enable(true); #endif // SENSORLESS_PROBING - TERN_(HAS_QUIET_PROBING, set_probing_paused(true)); + TERN_(HAS_QUIET_PROBING, set_devices_paused_for_probing(true)); // Move down until the probe is triggered do_blocking_move_to_z(z, fr_mm_s); @@ -668,7 +672,7 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { // Check to see if the probe was triggered const bool probe_triggered = ( #if HAS_DELTA_SENSORLESS_PROBING - endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)) + PROBE_TRIGGERED() #else TEST(endstops.trigger_state(), Z_MIN_PROBE) #endif @@ -679,7 +683,7 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { if (probe_triggered) refresh_largest_sensorless_adj(); #endif - TERN_(HAS_QUIET_PROBING, set_probing_paused(false)); + TERN_(HAS_QUIET_PROBING, set_devices_paused_for_probing(false)); // Re-enable stealthChop if used. Disable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 74904d35c5..d0f0ada34c 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -33,6 +33,10 @@ #include "../feature/bltouch.h" #endif +#if ANY(BD_SENSOR, HAS_DELTA_SENSORLESS_PROBING) + #include "endstops.h" +#endif + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" @@ -45,20 +49,24 @@ }; #endif -#if ENABLED(BD_SENSOR) - #include "endstops.h" - #define PROBE_READ() endstops.bdp_state -#elif USE_Z_MIN_PROBE - #define PROBE_READ() READ(Z_MIN_PROBE_PIN) +#if HAS_DELTA_SENSORLESS_PROBING + #define PROBE_READ() (endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX))) + #define PROBE_TRIGGERED() (PROBE_READ() != 0) #else - #define PROBE_READ() READ(Z_MIN_PIN) + #if ENABLED(BD_SENSOR) + #define PROBE_READ() endstops.bdp_state + #elif USE_Z_MIN_PROBE + #define PROBE_READ() READ(Z_MIN_PROBE_PIN) + #else + #define PROBE_READ() READ(Z_MIN_PIN) + #endif + #if USE_Z_MIN_PROBE + #define PROBE_HIT_STATE Z_MIN_PROBE_ENDSTOP_HIT_STATE + #else + #define PROBE_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE + #endif + #define PROBE_TRIGGERED() (PROBE_READ() == PROBE_HIT_STATE) #endif -#if USE_Z_MIN_PROBE - #define PROBE_HIT_STATE Z_MIN_PROBE_ENDSTOP_HIT_STATE -#else - #define PROBE_HIT_STATE Z_MIN_ENDSTOP_HIT_STATE -#endif -#define PROBE_TRIGGERED() (PROBE_READ() == PROBE_HIT_STATE) // In BLTOUCH HS mode, the probe travels in a deployed state. #define Z_TWEEN_SAFE_CLEARANCE SUM_TERN(BLTOUCH, Z_CLEARANCE_BETWEEN_PROBES, bltouch.z_extra_clearance()) @@ -347,7 +355,7 @@ public: #endif #if HAS_QUIET_PROBING - static void set_probing_paused(const bool p); + static void set_devices_paused_for_probing(const bool p); #endif #if ENABLED(PROBE_TARE)