From 707b0cc64ae72bae30c6fdc1dde3e8d64383ecbb Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 8 Nov 2013 20:19:44 +0000 Subject: [PATCH 1/4] 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]; From 07d7433e5da70084e6e1f6e7c1eda1f172f33721 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 9 Nov 2013 10:52:12 +0000 Subject: [PATCH 2/4] Z Probe Enable Allows the Z probe to be enabled or disabled. when disabled Z homes in the same way a X and Y. When Z probe is disabled it errors on M31, M32 --- .gitignore | 1 + GCodes.cpp | 17 ++++++++++++++++- Platform.cpp | 3 ++- Platform.h | 18 ++++++++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2c5e144..13c80b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.d *.o +.* Release/* *~ *orig diff --git a/GCodes.cpp b/GCodes.cpp index b69e92b..aadfa7c 100644 --- a/GCodes.cpp +++ b/GCodes.cpp @@ -319,7 +319,7 @@ bool GCodes::DoHome() { action[Z_AXIS] = true; moveToDo[DRIVES] = platform->HomeFeedRate(Z_AXIS); - if(homeZFinalMove) + if(platform->IsZProbeEnabled() && homeZFinalMove) { moveToDo[Z_AXIS] = 0.0; if(DoCannedCycleMove(moveToDo, action, false)) @@ -334,6 +334,11 @@ bool GCodes::DoHome() moveToDo[Z_AXIS] = platform->HomeDirection(Z_AXIS)*2.0*platform->AxisLength(Z_AXIS); if(DoCannedCycleMove(moveToDo, action, true)) homeZFinalMove = true; + if(!platform->IsZProbeEnabled()) + { + homeZ = false; + return NoHome(); + } return false; } } @@ -650,6 +655,11 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) break; case 31: + if(!platform->IsZProbeEnabled()) + { + platform->Message(HOST_MESSAGE, "Z Probe not supported\n"); + break; + } if(gb->Seen(gCodeLetters[Z_AXIS])) { platform->SetZProbeStopHeight(gb->GetFValue()); @@ -665,6 +675,11 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) break; case 32: // Probe Z at multiple positions and generate the bed transform + if(!platform->IsZProbeEnabled()) + { + platform->Message(HOST_MESSAGE, "Z Probe not supported\n"); + break; + } result = DoMultipleZProbe(); break; diff --git a/Platform.cpp b/Platform.cpp index 9f4d0f8..9d933b5 100644 --- a/Platform.cpp +++ b/Platform.cpp @@ -96,6 +96,7 @@ void Platform::Init() maxStepperDigipotVoltage = MAX_STEPPER_DIGIPOT_VOLTAGE; // zProbeGradient = Z_PROBE_GRADIENT; // zProbeConstant = Z_PROBE_CONSTANT; + zProbeEnable = Z_PROBE_ENABLE; zProbePin = Z_PROBE_PIN; zProbeCount = 0; zProbeSum = 0; @@ -323,7 +324,7 @@ inline void Platform::PollZHeight() EndStopHit Platform::Stopped(int8_t drive) { - if(drive == Z_AXIS) + if(zProbeEnable && drive == Z_AXIS) { if(ZProbe() > zProbeADValue) return lowHit; diff --git a/Platform.h b/Platform.h index 2b0e30f..1dfd893 100644 --- a/Platform.h +++ b/Platform.h @@ -84,6 +84,7 @@ Licence: GPL #define POT_WIPES {0, 1, 2, 3} // Indices for motor current digipots (if any) #define SENSE_RESISTOR 0.1 // Stepper motor current sense resistor #define MAX_STEPPER_DIGIPOT_VOLTAGE ( 3.3*2.5/(2.7+2.5) ) // Stepper motor current reference voltage +#define Z_PROBE_ENABLE false #define Z_PROBE_AD_VALUE 400 #define Z_PROBE_STOP_HEIGHT 0.7 // mm #define Z_PROBE_PIN 0 // Analogue pin number @@ -454,7 +455,8 @@ class Platform void SetZProbeStopHeight(float z); long ZProbe(); void SetZProbe(int iZ); - + void EnableZProbe(bool enableZ); + bool IsZProbeEnabled(); // Heat and temperature float GetTemperature(int8_t heater); // Result is in degrees celsius @@ -515,7 +517,7 @@ class Platform long zProbeSum; int zProbeADValue; float zProbeStopHeight; - + bool zProbeEnable; // AXES void PollZHeight(); @@ -751,9 +753,21 @@ inline void Platform::SetZProbeStopHeight(float z) inline void Platform::SetZProbe(int iZ) { + if(!zProbeEnable) + zProbeEnable=true; zProbeADValue = iZ; } +inline void Platform::EnableZProbe(bool enableZ) +{ + zProbeEnable=enableZ; +} + +inline bool Platform::IsZProbeEnabled() +{ + return zProbeEnable; +} + //******************************************************************************************************** From 8718503738733e6627e50ff9d9aedfc18488e4e5 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 9 Nov 2013 15:45:54 +0000 Subject: [PATCH 3/4] Added M31 to toggle Z probe state M31 with nothing reports the status, M31 S0 = disable, M31 S1 = enable --- GCodes.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GCodes.cpp b/GCodes.cpp index aadfa7c..45448bb 100644 --- a/GCodes.cpp +++ b/GCodes.cpp @@ -744,6 +744,14 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) fileBeingPrinted = NULL; break; + case 31: //toggle the Z probe enable, M31 with nothing reports the status, M31 S0 = disable, M31 S1 = enable + if(gb->Seen('S')) + platform->EnableZProbe((bool)gb->GetIValue()); + if(platform->IsZProbeEnabled()) + platform->Message(HOST_MESSAGE, "Z Probe enabled \n"); + else + platform->Message(HOST_MESSAGE, "Z Probe disabled \n"); + break; case 82: if(drivesRelative) for(uint8_t i = AXES; i < DRIVES; i++) From 81df66e43841e3ff82f565eb8201f1eff35255cd Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 6 Apr 2014 23:41:15 +0100 Subject: [PATCH 4/4] M112 now works Linked emergency stop routine to M112 --- GCodes.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GCodes.cpp b/GCodes.cpp index 1b744b9..eb1207e 100644 --- a/GCodes.cpp +++ b/GCodes.cpp @@ -1512,6 +1512,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb) break; case 112: // Emergency stop - acted upon in Webserver + reprap.EmergencyStop(); break; case 114: // Deprecated