From eefc25be91615c7533bd95ea3d57ae8642759dad Mon Sep 17 00:00:00 2001 From: Scott R Carlson Date: Fri, 27 Dec 2013 15:09:00 -0500 Subject: [PATCH] Hard Limits configured for active high. Added the use of homing_dir_mask to homing_cycle --- config.h | 2 +- limits.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index 9df2677..1fce110 100644 --- a/config.h +++ b/config.h @@ -53,7 +53,7 @@ // 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- // 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 // the user to perform the homing cycle (or override the locks) before doing anything else. This is diff --git a/limits.c b/limits.c index a9a7e29..f91cf56 100644 --- a/limits.c +++ b/limits.c @@ -87,7 +87,7 @@ ISR(LIMIT_INT_vect) // 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. // 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; } 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[Z_AXIS]) { target[X_AXIS] = settings.max_travel[Z_AXIS]; } target[X_AXIS] *= 2.0; - if (pos_dir) { target[X_AXIS] = -target[X_AXIS]; } - target[Y_AXIS] = target[X_AXIS]; - target[Z_AXIS] = target[X_AXIS]; + uint8_t pos_dir = settings.homing_dir_mask; + if (pos_dir >= 128) { + 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. // Setup homing axis locks based on cycle mask.