From d034dc21817059a0ec2e679207ebf532212932d9 Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Sun, 15 Feb 2015 19:23:16 -0700 Subject: [PATCH] Improved homing limit search handling. - Instead of a single overall max travel for a search distance for the homing limit switches. The homing cycle now applies the max travel of each axis to the search target. Generally makes more sense this way and saved more than a 100bytes of flash too. --- README.md | 4 ++-- grbl/grbl.h | 2 +- grbl/limits.c | 22 +++++++--------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e03cc0f..3e69e23 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ It accepts standards-compliant g-code and has been tested with the output of sev Grbl includes full acceleration management with look ahead. That means the controller will look up to 18 motions into the future and plan its velocities ahead to deliver smooth acceleration and jerk-free cornering. -* [Licensing](https://github.com/grbl/grbl/wiki/Licensing): Grbl v0.9 is free software, released under the GPLv3 license. Obsolete versions of Grbl, v0.8 and prior, are released under the permissive MIT-license. This will ensure Grbl will always be an open-source project while making the code permissive for others. +* [Licensing](https://github.com/grbl/grbl/wiki/Licensing): Grbl is free software, released under the GPLv3 license. * For more information and help, check out our **[Wiki pages!](https://github.com/grbl/grbl/wiki)** If you find that the information is out-dated, please to help us keep it updated by editing it or notifying our community! Thanks! -* Lead Developer [_2011 - Current_]: Sonny Jeon, Ph.D. (USA) +* Lead Developer [_2011 - Current_]: Sungeun(Sonny) K. Jeon, Ph.D. (USA) aka @chamnit * Lead Developer [_2009 - 2011_]: Simen Svale Skogsrud (Norway). aka The Originator/Creator/Pioneer/Father of Grbl. diff --git a/grbl/grbl.h b/grbl/grbl.h index 42e2fcf..08e7dd7 100644 --- a/grbl/grbl.h +++ b/grbl/grbl.h @@ -23,7 +23,7 @@ // Grbl versioning system #define GRBL_VERSION "0.9h" -#define GRBL_VERSION_BUILD "20150210" +#define GRBL_VERSION_BUILD "20150215" // Define standard libraries used by Grbl. #include diff --git a/grbl/limits.c b/grbl/limits.c index 57de228..6f00b06 100644 --- a/grbl/limits.c +++ b/grbl/limits.c @@ -124,7 +124,7 @@ void limits_go_home(uint8_t cycle_mask) float target[N_AXIS]; uint8_t limit_pin[N_AXIS], step_pin[N_AXIS]; - float max_travel = 0.0; + float max_travel; for (idx=0; idx settings.max_travel[idx]) { max_travel = settings.max_travel[idx]; } } - max_travel *= -HOMING_AXIS_SEARCH_SCALAR; // Ensure homing switches engaged by over-estimating max travel. plan_reset(); // Reset planner buffer to zero planner current position and to clear previous motions. plan_sync_position(); // Sync planner position to current machine position. @@ -156,15 +151,12 @@ void limits_go_home(uint8_t cycle_mask) // Set target location for active axes and setup computation for homing rate. if (bit_istrue(cycle_mask,bit(idx))) { n_active_axis++; - if (approach) { - // Set target direction based on cycle mask - if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] -= max_travel; } - else { target[idx] += max_travel; } - } else { - // Set target direction based on cycle mask - if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] += max_travel; } - else { target[idx] -= max_travel; } - } + // Set target based on max_travel setting. Ensure homing switches engaged with search scalar. + // NOTE: settings.max_travel[] is stored as a negative value. + max_travel = (-HOMING_AXIS_SEARCH_SCALAR)*settings.max_travel[idx]; + if (bit_istrue(settings.homing_dir_mask,bit(idx))) { max_travel = -max_travel; } + if (!approach) { max_travel = -max_travel; } + target[idx] += max_travel; } // Apply axislock to the step port pins active in this cycle.