diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1f22c6d7a501..4169f58b223e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -954,6 +954,11 @@ * Settings for all BLTouch and clone probes: */ + // Safety: Check that the probe deployment can be detected before homing. + // Cross-checks the endstop state when deployed/stowed and throws + // an error if they don't differ. + //#define BLTOUCH_VALIDATE_ON_HOMING + // Safety: The probe needs time to recognize the command. // Minimum command delay (ms). Enable and increase if needed. //#define BLTOUCH_DELAY 500 diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 02f76c139243..6663da927cb8 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -196,4 +196,19 @@ void BLTouch::mode_conv_proc(const bool M5V) { od_5v_mode = M5V; } +#if ENABLED(BLTOUCH_VALIDATE_ON_HOMING) + /** + * Validate that the BLTouch deploys/stows and reports its state correctly. + */ + bool BLTouch::validate() { + _stow(); + const bool start_status = status(); + _deploy(); + const bool deploy_status = status(); + _stow(); + const bool stow_status = status(); + return start_status == stow_status && deploy_status != stow_status; + } +#endif + #endif // BLTOUCH diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 0f9f2e68ba31..1eb9c03f55ba 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -78,6 +78,10 @@ class BLTouch { static float z_extra_clearance() { return TERN0(HAS_BLTOUCH_HS_MODE, high_speed_mode ? BLTOUCH_HS_EXTRA_CLEARANCE : 0); } + #if ENABLED(BLTOUCH_VALIDATE_ON_HOMING) + static bool validate(); + #endif + // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } static bool stow() { return stow_proc(); } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 55698c942bd4..2fd8114e4fd2 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -506,15 +506,21 @@ void GcodeSuite::G28() { stepper.set_separate_multi_axis(false); #endif - #if ENABLED(Z_SAFE_HOMING) - if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); - #else - homeaxis(Z_AXIS); - #endif - - #if ANY(Z_HOME_TO_MIN, ALLOW_Z_AFTER_HOMING) - finalRaiseZ = true; - #endif + if (TERN1(BLTOUCH_VALIDATE_ON_HOMING, bltouch.validate())) { + #if ENABLED(Z_SAFE_HOMING) + if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); + #else + homeaxis(Z_AXIS); + #endif + + #if ANY(Z_HOME_TO_MIN, ALLOW_Z_AFTER_HOMING) + finalRaiseZ = true; + #endif + } + else { + LCD_MESSAGE(MSG_BLTOUCH_VALIDATE_FAILED); + SERIAL_ECHO_MSG(STR_ERR_PROBING_FAILED); + } } #endif diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 553d9013a243..8433304f17ca 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -580,6 +580,7 @@ namespace LanguageNarrow_en { LSTR MSG_BLTOUCH_MODE_STORE_OD = _UxGT("Set BLTouch to OD"); LSTR MSG_BLTOUCH_MODE_ECHO = _UxGT("Report Drain"); LSTR MSG_BLTOUCH_MODE_CHANGE = _UxGT("DANGER: Bad settings can cause damage! Proceed anyway?"); + LSTR MSG_BLTOUCH_VALIDATE_FAILED = _UxGT("BLTouch Invalid!"); LSTR MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); LSTR MSG_TOUCHMI_INIT = _UxGT("Init TouchMI"); LSTR MSG_TOUCHMI_ZTEST = _UxGT("Z Offset Test");