From 707b0cc64ae72bae30c6fdc1dde3e8d64383ecbb Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 8 Nov 2013 20:19:44 +0000 Subject: [PATCH] Added home direction logic The direction which an axis homes in is either "-1" for min or "1" for max --- GCodes.cpp | 6 +++--- Platform.cpp | 1 + Platform.h | 11 +++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/GCodes.cpp b/GCodes.cpp index f241a26..b69e92b 100644 --- a/GCodes.cpp +++ b/GCodes.cpp @@ -292,7 +292,7 @@ bool GCodes::DoHome() if(homeX) { action[X_AXIS] = true; - moveToDo[X_AXIS] = -2.0*platform->AxisLength(X_AXIS); + moveToDo[X_AXIS] = platform->HomeDirection(X_AXIS)*2.0*platform->AxisLength(X_AXIS); moveToDo[DRIVES] = platform->HomeFeedRate(X_AXIS); if(DoCannedCycleMove(moveToDo, action, true)) { @@ -305,7 +305,7 @@ bool GCodes::DoHome() if(homeY) { action[Y_AXIS] = true; - moveToDo[Y_AXIS] = -2.0*platform->AxisLength(Y_AXIS); + moveToDo[Y_AXIS] = platform->HomeDirection(Y_AXIS)*2.0*platform->AxisLength(Y_AXIS); moveToDo[DRIVES] = platform->HomeFeedRate(Y_AXIS); if(DoCannedCycleMove(moveToDo, action, true)) { @@ -331,7 +331,7 @@ bool GCodes::DoHome() return false; }else { - moveToDo[Z_AXIS] = -2.0*platform->AxisLength(Z_AXIS); + moveToDo[Z_AXIS] = platform->HomeDirection(Z_AXIS)*2.0*platform->AxisLength(Z_AXIS); if(DoCannedCycleMove(moveToDo, action, true)) homeZFinalMove = true; return false; diff --git a/Platform.cpp b/Platform.cpp index 6809839..9f4d0f8 100644 --- a/Platform.cpp +++ b/Platform.cpp @@ -86,6 +86,7 @@ void Platform::Init() disableDrives = DISABLE_DRIVES; lowStopPins = LOW_STOP_PINS; highStopPins = HIGH_STOP_PINS; + homeDirection = HOME_DIRECTION; maxFeedrates = MAX_FEEDRATES; accelerations = ACCELERATIONS; driveStepsPerUnit = DRIVE_STEPS_PER_UNIT; diff --git a/Platform.h b/Platform.h index 57d5ab2..2b0e30f 100644 --- a/Platform.h +++ b/Platform.h @@ -79,6 +79,7 @@ Licence: GPL #define DISABLE_DRIVES {false, false, true, false} // Set true to disable a drive when it becomes idle #define LOW_STOP_PINS {11, 28, 60, 31} #define HIGH_STOP_PINS {-1, -1, -1, -1} +#define HOME_DIRECTION {1,1,1,1} // 1 for Max/High, -1 for Min/ Low TODO replace with logic based on low/high pin allocations #define ENDSTOP_HIT 1 // when a stop == this it is hit #define POT_WIPES {0, 1, 2, 3} // Indices for motor current digipots (if any) #define SENSE_RESISTOR 0.1 // Stepper motor current sense resistor @@ -150,7 +151,7 @@ Licence: GPL /****************************************************************************************************/ // Networking - +//FIXME does not currently override the default in \libraries\EMAC\conf_eth.h // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: //#define MAC { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; @@ -448,7 +449,7 @@ class Platform float HomeFeedRate(int8_t drive); EndStopHit Stopped(int8_t drive); float AxisLength(int8_t drive); - + int8_t HomeDirection(int8_t drive); float ZProbeStopHeight(); void SetZProbeStopHeight(float z); long ZProbe(); @@ -497,6 +498,7 @@ class Platform bool driveEnabled[DRIVES]; int8_t lowStopPins[DRIVES]; int8_t highStopPins[DRIVES]; + int8_t homeDirection[DRIVES]; float maxFeedrates[DRIVES]; float accelerations[DRIVES]; float driveStepsPerUnit[DRIVES]; @@ -715,6 +717,11 @@ inline float Platform::AxisLength(int8_t drive) return axisLengths[drive]; } +inline int8_t Platform::HomeDirection(int8_t drive) +{ + return homeDirection[drive]; +} + inline float Platform::MaxFeedrate(int8_t drive) { return maxFeedrates[drive];