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.
This commit is contained in:
Sonny Jeon 2015-02-15 19:23:16 -07:00
parent 8c9fc7943e
commit d034dc2181
3 changed files with 10 additions and 18 deletions

View File

@ -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. 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! * 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. * Lead Developer [_2009 - 2011_]: Simen Svale Skogsrud (Norway). aka The Originator/Creator/Pioneer/Father of Grbl.

View File

@ -23,7 +23,7 @@
// Grbl versioning system // Grbl versioning system
#define GRBL_VERSION "0.9h" #define GRBL_VERSION "0.9h"
#define GRBL_VERSION_BUILD "20150210" #define GRBL_VERSION_BUILD "20150215"
// Define standard libraries used by Grbl. // Define standard libraries used by Grbl.
#include <avr/io.h> #include <avr/io.h>

View File

@ -124,7 +124,7 @@ void limits_go_home(uint8_t cycle_mask)
float target[N_AXIS]; float target[N_AXIS];
uint8_t limit_pin[N_AXIS], step_pin[N_AXIS]; uint8_t limit_pin[N_AXIS], step_pin[N_AXIS];
float max_travel = 0.0; float max_travel;
for (idx=0; idx<N_AXIS; idx++) { for (idx=0; idx<N_AXIS; idx++) {
// Initialize limit and step pin masks // Initialize limit and step pin masks
limit_pin[idx] = get_limit_pin_mask(idx); limit_pin[idx] = get_limit_pin_mask(idx);
@ -132,12 +132,7 @@ void limits_go_home(uint8_t cycle_mask)
#ifdef COREXY #ifdef COREXY
if ((idx==A_MOTOR)||(idx==B_MOTOR)) { step_pin[idx] = (get_step_pin_mask(X_AXIS)|get_step_pin_mask(Y_AXIS)); } if ((idx==A_MOTOR)||(idx==B_MOTOR)) { step_pin[idx] = (get_step_pin_mask(X_AXIS)|get_step_pin_mask(Y_AXIS)); }
#endif #endif
// Determine travel distance to the furthest homing switch based on user max travel settings.
// NOTE: settings.max_travel[] is stored as a negative value.
if (max_travel > 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_reset(); // Reset planner buffer to zero planner current position and to clear previous motions.
plan_sync_position(); // Sync planner position to current machine position. 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. // Set target location for active axes and setup computation for homing rate.
if (bit_istrue(cycle_mask,bit(idx))) { if (bit_istrue(cycle_mask,bit(idx))) {
n_active_axis++; n_active_axis++;
if (approach) { // Set target based on max_travel setting. Ensure homing switches engaged with search scalar.
// Set target direction based on cycle mask // NOTE: settings.max_travel[] is stored as a negative value.
if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] -= max_travel; } max_travel = (-HOMING_AXIS_SEARCH_SCALAR)*settings.max_travel[idx];
else { target[idx] += max_travel; } if (bit_istrue(settings.homing_dir_mask,bit(idx))) { max_travel = -max_travel; }
} else { if (!approach) { max_travel = -max_travel; }
// Set target direction based on cycle mask target[idx] += max_travel;
if (bit_istrue(settings.homing_dir_mask,bit(idx))) { target[idx] += max_travel; }
else { target[idx] -= max_travel; }
}
} }
// Apply axislock to the step port pins active in this cycle. // Apply axislock to the step port pins active in this cycle.