From 67b1b62a6b101f93e3918acc790c54b54fd40043 Mon Sep 17 00:00:00 2001 From: tommaso-b <119923627+tommaso-b@users.noreply.github.com> Date: Fri, 28 Mar 2025 20:48:08 +0100 Subject: [PATCH 1/3] Adding automatic Z limit adjustment for Z probing --- grbl/system.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/grbl/system.c b/grbl/system.c index 55e6c406..a96b564a 100644 --- a/grbl/system.c +++ b/grbl/system.c @@ -351,6 +351,24 @@ uint8_t system_check_travel_limits(float *target) return(false); } +// Z Probing simplification : if Z travel exceeds soft limits, adjust Z to max. allowed value as probing stop is anyhow expected +// function code derived from above soft limit check +uint8_t system_do_limit_Z_travel(float *target) +{ + #ifdef HOMING_FORCE_SET_ORIGIN + // When homing forced set origin is enabled, soft limits checks need to account for directionality. + // NOTE: max_travel is stored as negative + if (bit_istrue(settings.homing_dir_mask,bit(Z_AXIS))) { + if (target[Z_AXIS] < 0 || target[Z_AXIS] > -settings.max_travel[Z_AXIS]) { target[Z_AXIS] = -settings.max_travel[Z_AXIS]; return(true); } + } else { + if (target[Z_AXIS] > 0 || target[Z_AXIS] < settings.max_travel[Z_AXIS]) { target[Z_AXIS] = settings.max_travel[Z_AXIS]; return(true); } + } + #else + // NOTE: max_travel is stored as negative + if (target[Z_AXIS] > 0 || target[Z_AXIS] < settings.max_travel[Z_AXIS]) { target[Z_AXIS] = settings.max_travel[Z_AXIS]; return(true); } + #endif + return(false); +} // Special handlers for setting and clearing Grbl's real-time execution flags. void system_set_exec_state_flag(uint8_t mask) { From a6bb083a686e882e19c592add1c49101a3095b42 Mon Sep 17 00:00:00 2001 From: tommaso-b <119923627+tommaso-b@users.noreply.github.com> Date: Fri, 28 Mar 2025 20:53:33 +0100 Subject: [PATCH 2/3] system.h adding function prototype --- grbl/system.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grbl/system.h b/grbl/system.h index cfc92738..0e317b1e 100644 --- a/grbl/system.h +++ b/grbl/system.h @@ -198,6 +198,9 @@ void system_convert_array_steps_to_mpos(float *position, int32_t *steps); // Checks and reports if target array exceeds machine travel limits. uint8_t system_check_travel_limits(float *target); +// Z Probing simplification : if Z travel exceeds soft limits, adjust Z to max. allowed value as probing stop is anyhow expected +uint8_t system_do_limit_Z_travel(float *target); + // Special handlers for setting and clearing Grbl's real-time execution flags. void system_set_exec_state_flag(uint8_t mask); void system_clear_exec_state_flag(uint8_t mask); From 593074356a25bd04d34882712859043a9587ea04 Mon Sep 17 00:00:00 2001 From: tommaso-b <119923627+tommaso-b@users.noreply.github.com> Date: Fri, 28 Mar 2025 20:57:02 +0100 Subject: [PATCH 3/3] When Z probing, adapt Z to soft limits if Z out of range --- grbl/motion_control.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grbl/motion_control.c b/grbl/motion_control.c index 6e11e35c..9379b8be 100644 --- a/grbl/motion_control.c +++ b/grbl/motion_control.c @@ -277,6 +277,9 @@ uint8_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, uint8_t parser_ return(GC_PROBE_FAIL_INIT); // Nothing else to do but bail. } + // Z Probing simplification : if Z travel exceeds soft limits, adjust Z to max. allowed value as probing stop is anyhow expected + system_do_limit_Z_travel(target); + // Setup and queue probing motion. Auto cycle-start should not start the cycle. mc_line(target, pl_data);