From b0d9e9e78a12c99c37993fa211517388768c0bc0 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Sun, 23 Oct 2022 07:27:20 +0200 Subject: [PATCH] Fix for issue #209, incorrect handling of homing of more than one auto squared axis in each pass. Error 55 will now be returned. --- README.md | 7 ++++--- changelog.md | 10 +++++++++- errors.c | 1 + errors.h | 1 + grbl.h | 2 +- machine_limits.c | 14 +++++--------- machine_limits.h | 4 ++-- motion_control.c | 18 +++++++++++------- 8 files changed, 34 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index da67bb7..deb9a43 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,14 @@ It has been written to complement grblHAL and has features such as proper keyboa --- -Latest build date is 20221021, see the [changelog](changelog.md) for details. +Latest build date is 20221023, see the [changelog](changelog.md) for details. __NOTE:__ A settings reset will be performed on an update for versions earlier than 20211122. Backup and restore of settings is recommended. __IMPORTANT!__ A new setting has been introduced for ganged axes motors in version 20211121. I have only bench tested this for a couple of drivers, correct function should be verified after updating by those who have more than three motors configured. More details in the [changelog](changelog.md). --- + Updated for latest core changes. __NOTE:__ Arduino drivers has now been converted to Arduino libraries, [installation and compilation procedure](https://github.com/grblHAL/core/wiki/Compiling-GrblHAL) has been changed! @@ -40,7 +41,7 @@ It is able to maintain up to 300kHz3 of stable, jitter free control p It accepts standards-compliant g-code and has been tested with the output of several CAM tools with no problems. Arcs, circles and helical motion are fully supported, as well as, all other primary g-code commands. Macro functions, variables, and some canned cycles are not supported, but we think GUIs can do a much better job at translating them into straight g-code anyhow. -Grbl includes full acceleration management with look ahead. That means the controller will look up motions into the future and plan its velocities ahead to deliver smooth acceleration and jerk-free cornering. +grblHAL includes full acceleration management with look ahead. That means the controller will look up motions into the future and plan its velocities ahead to deliver smooth acceleration and jerk-free cornering. This is a port/rewrite of [grbl 1.1f](https://github.com/gnea/grbl) and should be compatible with GCode senders compliant with the specifications for that version. It should be possible to change default compile-time configurations if problems arise, eg. the default serial buffer sizes has been increased in some of the [drivers](https://github.com/grblHAL/drivers) provided. @@ -86,4 +87,4 @@ List of Supported G-Codes: Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes. --- -2022-10-21 +2022-10-23 diff --git a/changelog.md b/changelog.md index 8934e05..1ad9030 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ ## grblHAL changelog +Build 20221023 + +Core: + +* Fix for issue #209, incorrect handling of homing of more than one auto squared axis in each pass. Error 55 will now be returned. + +--- + Build 20221022 Core: @@ -10,7 +18,7 @@ Core: Drivers: -Many: Fixes for incorrect code related to new spindle type property introduced in build 20221018. Updated [Web Builder](http://svn.io-engineering.com:8080/) data. +* Many: Fixes for incorrect code related to new spindle type property introduced in build 20221018. Updated [Web Builder](http://svn.io-engineering.com:8080/) data. --- diff --git a/errors.c b/errors.c index efc658d..da48af8 100644 --- a/errors.c +++ b/errors.c @@ -82,6 +82,7 @@ PROGMEM static const status_detail_t status_detail[] = { { Status_SettingValueOutOfRange, "Setting value is out of range." }, { Status_SettingDisabled, "Setting is not available, possibly due to limited driver support." }, { Status_GcodeInvalidRetractPosition, "Retract position is less than drill depth." }, + { Status_IllegalHomingConfiguration, "Attempt to home two auto squared axes at the same time." }, #if NGC_EXPRESSIONS_ENABLE { Status_ExpressionUknownOp, "Unknown operation found in expression." }, { Status_ExpressionDivideByZero, "Divide by zero in expression attempted." }, diff --git a/errors.h b/errors.h index 15e67d1..e4777fd 100644 --- a/errors.h +++ b/errors.h @@ -84,6 +84,7 @@ typedef enum { Status_SettingValueOutOfRange = 52, Status_SettingDisabled = 53, Status_GcodeInvalidRetractPosition = 54, + Status_IllegalHomingConfiguration = 55, // Some error codes as defined in bdring's ESP32 port Status_SDMountError = 60, diff --git a/grbl.h b/grbl.h index e86e710..689b9c8 100644 --- a/grbl.h +++ b/grbl.h @@ -34,7 +34,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20221022 +#define GRBL_BUILD 20221023 #define GRBL_URL "https://github.com/grblHAL" diff --git a/machine_limits.c b/machine_limits.c index 3108e78..8428cbd 100644 --- a/machine_limits.c +++ b/machine_limits.c @@ -489,10 +489,8 @@ static bool limits_homing_cycle (axes_signals_t cycle, axes_signals_t auto_squar // Perform homing cycle(s) according to configuration. // NOTE: only one auto squared axis can be homed at a time. -bool limits_go_home (axes_signals_t cycle) +status_code_t limits_go_home (axes_signals_t cycle) { - bool homed = false; - axes_signals_t auto_square = {0}, auto_squared = {0}; if(hal.stepper.get_ganged) @@ -503,24 +501,22 @@ bool limits_go_home (axes_signals_t cycle) if(auto_squared.mask) { if(!hal.stepper.disable_motors) - return false; // Bad driver! + return Status_IllegalHomingConfiguration; // Bad driver! - should not happen. auto_square.x = On; while(!(auto_squared.mask & auto_square.mask)) auto_square.mask <<= 1; if(auto_squared.mask != auto_square.mask) - return false; // Attempt at squaring more than one auto squared axis at the same time. + return Status_IllegalHomingConfiguration; // Attempt at squaring more than one auto squared axis at the same time. if((auto_squared.mask & homing_signals_select(hal.homing.get_state(), (axes_signals_t){0}, SquaringMode_Both).mask) && !limits_pull_off(auto_square, settings.homing.pulloff * HOMING_AXIS_LOCATE_SCALAR)) - return false; // Auto squaring with limit switch asserted is not allowed. + return Status_LimitsEngaged; // Auto squaring with limit switch asserted is not allowed. } tc_clear_tlo_reference(cycle); - homed = limits_homing_cycle(cycle, auto_square); - - return homed; + return limits_homing_cycle(cycle, auto_square) ? Status_OK : Status_Unhandled; } // Performs a soft limit check. Called from mc_line() only. Assumes the machine has been homed, diff --git a/machine_limits.h b/machine_limits.h index 7719372..4e183c4 100644 --- a/machine_limits.h +++ b/machine_limits.h @@ -27,10 +27,10 @@ #include "nuts_bolts.h" // Perform one portion of the homing cycle based on the input settings. -bool limits_go_home(axes_signals_t cycle); +status_code_t limits_go_home (axes_signals_t cycle); // Check for soft limit violations -void limits_soft_check(float *target); +void limits_soft_check( float *target); // Check if homing is required. bool limits_homing_required (void); diff --git a/motion_control.c b/motion_control.c index cb1e73a..d42c8f0 100644 --- a/motion_control.c +++ b/motion_control.c @@ -817,6 +817,7 @@ void mc_dwell (float seconds) status_code_t mc_homing_cycle (axes_signals_t cycle) { bool home_all = cycle.mask == 0; + status_code_t homed_status = Status_OK; memset(&sys.last_event.limits, 0, sizeof(limit_signals_t)); @@ -887,7 +888,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle) // Perform homing routine. NOTE: Special motion case. Only system reset works. if (!home_all) // Perform homing cycle based on mask. - limits_go_home(cycle); + homed_status = !limits_go_home(cycle); else { uint_fast8_t idx = 0; @@ -897,7 +898,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle) do { if(settings.homing.cycle[idx].mask) { cycle.mask = settings.homing.cycle[idx].mask; - if(!limits_go_home(cycle)) + if((homed_status = limits_go_home(cycle)) != Status_OK) break; } } while(++idx < N_AXIS); @@ -914,6 +915,9 @@ status_code_t mc_homing_cycle (axes_signals_t cycle) if(!protocol_execute_realtime()) // Check for reset and set system abort. return Status_Unhandled; // Did not complete. Alarm state set by mc_alarm. + if(homed_status != Status_OK) + return homed_status; + if(home_all && settings.homing.flags.manual) { cycle.mask = AXES_BITMASK & ~sys.homing.mask; @@ -934,14 +938,14 @@ status_code_t mc_homing_cycle (axes_signals_t cycle) sys.report.homed = On; - status_code_t status = settings.limits.flags.hard_enabled && settings.limits.flags.check_at_init && limit_signals_merge(hal.limits.get_state()).value - ? Status_LimitsEngaged - : Status_OK; + homed_status = settings.limits.flags.hard_enabled && settings.limits.flags.check_at_init && limit_signals_merge(hal.limits.get_state()).value + ? Status_LimitsEngaged + : Status_OK; - if(status == Status_OK && grbl.on_homing_completed) + if(homed_status == Status_OK && grbl.on_homing_completed) grbl.on_homing_completed(); - return status; + return homed_status; } // Perform tool length probe cycle. Requires probe switch.