Hard Limits configured for active high.

Added the use of homing_dir_mask to homing_cycle
This commit is contained in:
Scott R Carlson 2013-12-27 15:09:00 -05:00
parent 3054b2df77
commit eefc25be91
2 changed files with 27 additions and 5 deletions

View File

@ -53,7 +53,7 @@
// are reached. You will need to ensure that you have appropriate pull-down resistors on the // are reached. You will need to ensure that you have appropriate pull-down resistors on the
// limit switch input pins, or that your hardware drives the pins low when they are open (non- // limit switch input pins, or that your hardware drives the pins low when they are open (non-
// triggered). // triggered).
// #define LIMIT_SWITCHES_ACTIVE_HIGH #define LIMIT_SWITCHES_ACTIVE_HIGH
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces // If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
// the user to perform the homing cycle (or override the locks) before doing anything else. This is // the user to perform the homing cycle (or override the locks) before doing anything else. This is

View File

@ -87,7 +87,7 @@ ISR(LIMIT_INT_vect)
// algorithm is written here. This also lets users hack and tune this code freely for // algorithm is written here. This also lets users hack and tune this code freely for
// their own particular needs without affecting the rest of Grbl. // their own particular needs without affecting the rest of Grbl.
// NOTE: Only the abort runtime command can interrupt this process. // NOTE: Only the abort runtime command can interrupt this process.
static void homing_cycle(uint8_t cycle_mask, bool pos_dir, bool invert_pin, float homing_rate) static void homing_cycle(uint8_t cycle_mask, bool approach, bool invert_pin, float homing_rate)
{ {
if (sys.execute & EXEC_RESET) { return; } if (sys.execute & EXEC_RESET) { return; }
uint8_t limit_state; uint8_t limit_state;
@ -101,9 +101,31 @@ static void homing_cycle(uint8_t cycle_mask, bool pos_dir, bool invert_pin, floa
if (target[X_AXIS] < settings.max_travel[Y_AXIS]) { target[X_AXIS] = settings.max_travel[Y_AXIS]; } if (target[X_AXIS] < settings.max_travel[Y_AXIS]) { target[X_AXIS] = settings.max_travel[Y_AXIS]; }
if (target[X_AXIS] < settings.max_travel[Z_AXIS]) { target[X_AXIS] = settings.max_travel[Z_AXIS]; } if (target[X_AXIS] < settings.max_travel[Z_AXIS]) { target[X_AXIS] = settings.max_travel[Z_AXIS]; }
target[X_AXIS] *= 2.0; target[X_AXIS] *= 2.0;
if (pos_dir) { target[X_AXIS] = -target[X_AXIS]; } uint8_t pos_dir = settings.homing_dir_mask;
target[Y_AXIS] = target[X_AXIS]; if (pos_dir >= 128) {
target[Z_AXIS] = target[X_AXIS]; pos_dir = pos_dir - 128;
target[Z_AXIS] = target[X_AXIS];
}
else { target[Z_AXIS] = -target[X_AXIS]; }
if (!approach) { target[Z_AXIS] = target[Z_AXIS] * -1; }
if (pos_dir >= 64) {
pos_dir = pos_dir - 64;
target[Y_AXIS] = target[X_AXIS];
}
else { target[Y_AXIS] = -target[X_AXIS]; }
if (!approach) { target[Y_AXIS] = target[Y_AXIS] * -1; }
if (pos_dir >= 32) {
pos_dir = pos_dir -32;
target[X_AXIS] = target[X_AXIS];
}
else { target[X_AXIS] = -target[X_AXIS]; }
if (!approach) { target[X_AXIS] = target[X_AXIS] * -1; }
//if (pos_dir) { target[X_AXIS] = -target[X_AXIS]; }
//target[Y_AXIS] = target[X_AXIS];
//target[Z_AXIS] = target[X_AXIS];
homing_rate *= 1.7320; // [sqrt(N_AXIS)] Adjust so individual axes all move at homing rate. homing_rate *= 1.7320; // [sqrt(N_AXIS)] Adjust so individual axes all move at homing rate.
// Setup homing axis locks based on cycle mask. // Setup homing axis locks based on cycle mask.