Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a validation check for the BLTouch #25021

Closed
wants to merge 12 commits into from
5 changes: 5 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,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. Requires Z_SAFE_HOMING.
//#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
Expand Down
17 changes: 17 additions & 0 deletions Marlin/src/feature/bltouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,21 @@ 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() {
bool start_status, deploy_status, stow_status;
_stow();
start_status = status();
_deploy();
deploy_status = status();
_stow();
stow_status = status();

return ((start_status == stow_status) && (deploy_status != stow_status));
}
#endif

#endif // BLTOUCH
4 changes: 4 additions & 0 deletions Marlin/src/feature/bltouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class BLTouch {

static float z_extra_clearance() { return high_speed_mode ? 7 : 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(); }
Expand Down
9 changes: 7 additions & 2 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@

TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle

do_blocking_move_to_xy(destination);
homeaxis(Z_AXIS);
if(TERN1(BLTOUCH_VALIDATE_ON_HOMING, bltouch.validate())) {
do_blocking_move_to_xy(destination);
homeaxis(Z_AXIS);
} else {
LCD_MESSAGE(MSG_BLTOUCH_VALIDATE_FAILED);
SERIAL_ECHO_MSG(STR_ERR_PROBING_FAILED);
}
}
else {
LCD_MESSAGE(MSG_ZPROBE_OUT);
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -4282,6 +4282,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#endif
#endif

#if ENABLED(BLTOUCH_VALIDATE_ON_HOMING) && DISABLED(Z_SAFE_HOMING)
#error "BLTOUCH_VALIDATE_ON_HOMING requires Z_SAFE_HOMING."
slowbro marked this conversation as resolved.
Show resolved Hide resolved
#endif

// Misc. Cleanup
#undef _TEST_PWM
#undef _NUM_AXES_STR
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ namespace Language_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 validation failed!");
LSTR MSG_TOUCHMI_PROBE = _UxGT("TouchMI");
LSTR MSG_TOUCHMI_INIT = _UxGT("Init TouchMI");
LSTR MSG_TOUCHMI_ZTEST = _UxGT("Z Offset Test");
Expand Down