From dc566d654f1cdf8d88c40c0361644d99db110820 Mon Sep 17 00:00:00 2001 From: ZetaPhoenix Date: Fri, 14 Sep 2012 21:48:49 -0700 Subject: [PATCH 1/2] fixes #246 Added statements to set the limit switch positions to the maximum travel if homing in the positive direction as well as bed center at (0,0) if defined. --- Marlin/Configuration.h | 54 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0ec06316f..a9ef23ce3 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -203,10 +203,56 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS) #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS) -// The position of the homing switches. Use MAX_LENGTH * -0.5 if the center should be 0, 0, 0 -#define X_HOME_POS 0 -#define Y_HOME_POS 0 -#define Z_HOME_POS 0 +// The position of the homing switches +// Auto switch code by ZetaPhoenix +//#define MANUAL_HOME_POSITIONS //If defined, manualy programed locations will be loaded +//#define BED_CENTER_AT_0_0 + +#ifdef MANUAL_HOME_POSITION //Manual limit switch locations + #define X_HOME_POS 0 + #define Y_HOME_POS 0 + #define Z_HOME_POS 0 + +//Set min/max homing switch positions based upon direction and min/max travel limits +#else + //X axis + #if X_HOME_DIR == -1 + #ifdef BED_CENTER_AT_0_0 + #define X_HOME_POS X_MAX_LENGTH * -0.5 + #else + #define X_HOME_POS X_MIN_POS + #endif //BED_CENTER_AT_0_0 + #else + #ifdef BED_CENTER_AT_0_0 + #define X_HOME_POS X_MAX_LENGTH * 0.5 + #else + #define X_HOME_POS X_MAX_POS + #endif //BED_CENTER_AT_0_0 + #endif //X_HOME_DIR == -1 + + //Y axis + #if Y_HOME_DIR == -1 + #ifdef BED_CENTER_AT_0_0 + #define Y_HOME_POS Y_MAX_LENGTH * -0.5 + #else + #define Y_HOME_POS Y_MIN_POS + #endif //BED_CENTER_AT_0_0 + #else + #ifdef BED_CENTER_AT_0_0 + #define Y_HOME_POS Y_MAX_LENGTH * 0.5 + #else + #define Y_HOME_POS Y_MAX_POS + #endif //BED_CENTER_AT_0_0 + #endif //Y_HOME_DIR == -1 + + // Z axis + #if Z_HOME_DIR == -1 //BED_CENTER_AT_0_0 not used + #define Z_HOME_POS Z_MIN_POS + #else + #define Z_HOME_POS Z_MAX_POS + #endif //Z_HOME_DIR == -1 +#endif //End auto min/max positions + //// MOVEMENT SETTINGS #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E From c6caa45ae25196dfe658d1cdb2189a9a9ff9f574 Mon Sep 17 00:00:00 2001 From: ZetaPhoenix Date: Sat, 15 Sep 2012 15:25:49 -0700 Subject: [PATCH 2/2] Limit Switch locations based on MIN/MAX limits and homing direction fixes #246 Added statements to set the limit switch positions to the maximum travel if homing in the positive direction as well as bed center at (0,0) if defined. Relocated code based on feedback. --- Marlin/Configuration.h | 54 +++++--------------------------------- Marlin/Configuration_adv.h | 48 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index a9ef23ce3..00ccaa082 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -204,55 +204,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS) // The position of the homing switches -// Auto switch code by ZetaPhoenix -//#define MANUAL_HOME_POSITIONS //If defined, manualy programed locations will be loaded -//#define BED_CENTER_AT_0_0 - -#ifdef MANUAL_HOME_POSITION //Manual limit switch locations - #define X_HOME_POS 0 - #define Y_HOME_POS 0 - #define Z_HOME_POS 0 - -//Set min/max homing switch positions based upon direction and min/max travel limits -#else - //X axis - #if X_HOME_DIR == -1 - #ifdef BED_CENTER_AT_0_0 - #define X_HOME_POS X_MAX_LENGTH * -0.5 - #else - #define X_HOME_POS X_MIN_POS - #endif //BED_CENTER_AT_0_0 - #else - #ifdef BED_CENTER_AT_0_0 - #define X_HOME_POS X_MAX_LENGTH * 0.5 - #else - #define X_HOME_POS X_MAX_POS - #endif //BED_CENTER_AT_0_0 - #endif //X_HOME_DIR == -1 - - //Y axis - #if Y_HOME_DIR == -1 - #ifdef BED_CENTER_AT_0_0 - #define Y_HOME_POS Y_MAX_LENGTH * -0.5 - #else - #define Y_HOME_POS Y_MIN_POS - #endif //BED_CENTER_AT_0_0 - #else - #ifdef BED_CENTER_AT_0_0 - #define Y_HOME_POS Y_MAX_LENGTH * 0.5 - #else - #define Y_HOME_POS Y_MAX_POS - #endif //BED_CENTER_AT_0_0 - #endif //Y_HOME_DIR == -1 - - // Z axis - #if Z_HOME_DIR == -1 //BED_CENTER_AT_0_0 not used - #define Z_HOME_POS Z_MIN_POS - #else - #define Z_HOME_POS Z_MAX_POS - #endif //Z_HOME_DIR == -1 -#endif //End auto min/max positions +//#define MANUAL_HOME_POSITIONS // If defined, manualy programed locations will be used +//#define BED_CENTER_AT_0_0 // If defined the center of the bed is defined as (0,0) +//Manual homing switch locations: +#define MANUAL_X_HOME_POS 0 +#define MANUAL_Y_HOME_POS 0 +#define MANUAL_Z_HOME_POS 0 //// MOVEMENT SETTINGS #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0182c9375..a356c919e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -76,6 +76,54 @@ #define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing + +//// AUTOSET LOCATIONS OF LIMIT SWITCHES +//// Added by ZetaPhoenix 09-15-2012 +#ifdef MANUAL_HOME_POSITION //Use manual limit switch locations + #define X_HOME_POS MANUAL_X_HOME_POS + #define Y_HOME_POS MANUAL_Y_HOME_POS + #define Z_HOME_POS MANUAL_Z_HOME_POS +#else //Set min/max homing switch positions based upon homing direction and min/max travel limits + //X axis + #if X_HOME_DIR == -1 + #ifdef BED_CENTER_AT_0_0 + #define X_HOME_POS X_MAX_LENGTH * -0.5 + #else + #define X_HOME_POS X_MIN_POS + #endif //BED_CENTER_AT_0_0 + #else + #ifdef BED_CENTER_AT_0_0 + #define X_HOME_POS X_MAX_LENGTH * 0.5 + #else + #define X_HOME_POS X_MAX_POS + #endif //BED_CENTER_AT_0_0 + #endif //X_HOME_DIR == -1 + + //Y axis + #if Y_HOME_DIR == -1 + #ifdef BED_CENTER_AT_0_0 + #define Y_HOME_POS Y_MAX_LENGTH * -0.5 + #else + #define Y_HOME_POS Y_MIN_POS + #endif //BED_CENTER_AT_0_0 + #else + #ifdef BED_CENTER_AT_0_0 + #define Y_HOME_POS Y_MAX_LENGTH * 0.5 + #else + #define Y_HOME_POS Y_MAX_POS + #endif //BED_CENTER_AT_0_0 + #endif //Y_HOME_DIR == -1 + + // Z axis + #if Z_HOME_DIR == -1 //BED_CENTER_AT_0_0 not used + #define Z_HOME_POS Z_MIN_POS + #else + #define Z_HOME_POS Z_MAX_POS + #endif //Z_HOME_DIR == -1 +#endif //End auto min/max positions +//END AUTOSET LOCATIONS OF LIMIT SWITCHES -ZP + + //#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats. // A single Z stepper driver is usually used to drive 2 stepper motors.