Skip to content
Browse files

Merge branch '3G-5D-Shield' into 3G-5D-Shield-3.0

Conflicts:
	v2/src/Motherboard/Steppers.cc
	v2/src/Motherboard/boards/rrmbv12/Configuration.hh
	v2/src/Motherboard/boards/rrmbv12/Motherboard.cc
	v2/src/Motherboard/boards/rrmbv12/StepperInterface.cc
  • Loading branch information...
1 parent a884097 commit 8d5c7dbf39914ac6cf9def9981a11d11e0a673a8 @giseburt giseburt committed Oct 1, 2011
View
2 v2/src/Motherboard/boards/mb24/Motherboard.cc
@@ -99,7 +99,7 @@ void Motherboard::reset() {
// Init steppers
// NB: for now, we are turning on Z hold for these boards!
- steppers::setHoldZ(true);
+ //steppers::setHoldZ(true);
for (int i = 0; i < STEPPER_COUNT; i++) {
stepper[i].init(i);
}
View
18 v2/src/Motherboard/boards/rrmbv12/Configuration.hh
@@ -65,7 +65,7 @@
// --- Axis configuration ---
// Define the number of stepper axes supported by the board. The axes are
// denoted by X, Y, Z, A and B.
-#define STEPPER_COUNT 3
+#define STEPPER_COUNT 4
// --- Stepper and endstop configuration ---
// Pins should be defined for each axis present on the board. They are denoted
@@ -76,6 +76,9 @@
// if they are based on the H21LOI, they are not.
#define DEFAULT_INVERTED_ENDSTOPS 1
+// If both ends of the endstops will trigger the same pin, set this to one
+#define SINGLE_SWITCH_ENDSTOPS 1
+
// The X stepper step pin (active on rising edge)
#define X_STEP_PIN Pin(PortD,7)
// The X direction pin (forward on logic high)
@@ -85,7 +88,7 @@
// The X minimum endstop pin (active high)
#define X_MIN_PIN Pin(PortC,4)
// The X maximum endstop pin (active high)
-#define X_MAX_PIN Pin(PortC,5)
+#define X_MAX_PIN Pin(PortC,4) // was 5
// The Y stepper step pin (active on rising edge)
#define Y_STEP_PIN Pin(PortC,7)
@@ -96,7 +99,7 @@
// The Y minimum endstop pin (active high)
#define Y_MIN_PIN Pin(PortA,6)
// The Y maximum endstop pin (active high)
-#define Y_MAX_PIN Pin(PortA,5)
+#define Y_MAX_PIN Pin(PortA,6) // was 5
// The Z stepper step pin (active on rising edge)
#define Z_STEP_PIN Pin(PortA,4)
@@ -107,7 +110,14 @@
// The Z minimum endstop pin (active high)
#define Z_MIN_PIN Pin(PortA,1)
// The Z maximum endstop pin (active high)
-#define Z_MAX_PIN Pin(PortA,0)
+#define Z_MAX_PIN Pin(PortA,1) // was 0
+
+// The A stepper step pin (active on rising edge)
+#define A_STEP_PIN Pin(PortC,5)
+// The A direction pin (forward on logic high)
+#define A_DIR_PIN Pin(PortA,5)
+// The A stepper enable pin (active low)
+#define A_ENABLE_PIN Pin(PortA,0)
// --- Debugging configuration ---
// The pin which controls the debug LED (active high)
View
8 v2/src/Motherboard/boards/rrmbv12/Motherboard.cc
@@ -61,16 +61,16 @@ Motherboard::Motherboard(const Pin& psu_pin) :
stepper[3] = StepperInterface(A_DIR_PIN,
A_STEP_PIN,
A_ENABLE_PIN,
- A_MAX_PIN,
- A_MIN_PIN,
+ Pin(),
+ Pin(),
eeprom::AXIS_INVERSION);
#endif
#if STEPPER_COUNT > 4
stepper[4] = StepperInterface(B_DIR_PIN,
B_STEP_PIN,
B_ENABLE_PIN,
- B_MAX_PIN,
- B_MIN_PIN,
+ Pin(),
+ Pin(),
eeprom::AXIS_INVERSION);
#endif
}
View
58 v2/src/shared/StepperAxis.cc
@@ -48,18 +48,41 @@ void StepperAxis::reset() {
target = 0;
counter = 0;
delta = 0;
+ endstop_play = ENDSTOP_DEFAULT_PLAY;
+ endstop_status = ESS_UNKNOWN;
}
void StepperAxis::doInterrupt(const int32_t intervals) {
counter += delta;
if (counter >= 0) {
interface->setDirection(direction);
counter -= intervals;
+ bool hit_endstop = direction ? interface->isAtMaximum() : interface->isAtMinimum();
+#if defined(SINGLE_SWITCH_ENDSTOPS) && (SINGLE_SWITCH_ENDSTOPS == 1)
+ if (hit_endstop) {
+ // Did we *just* hit the endstop?
+ if (endstop_status == ESS_TRAVELING || endstop_status == ESS_UNKNOWN) {
+ if (endstop_status != ESS_UNKNOWN)
+ endstop_status = direction ? ESS_AT_MAXIMUM : ESS_AT_MINIMUM;
+ hit_endstop = false; // pretend this never happened... :-)
+
+ // OR, are we traveling away from the endstop we just hit and still have play...
+ } else if (endstop_play > 0 && (endstop_status != (direction ? ESS_AT_MAXIMUM : ESS_AT_MINIMUM))) {
+ --endstop_play;
+ hit_endstop = false; // pretend this never happened... :-)
+ }
+ // otherwise we hit the endstop
+
+ // but if we didn't hit an endstop, clear the status
+ } else {
+ endstop_status = ESS_TRAVELING;
+ }
+#endif //SINGLE_SWITCH_ENDSTOPS
if (direction) {
- if (!interface->isAtMaximum()) interface->step(true);
+ if (!hit_endstop) interface->step(true);
position++;
} else {
- if (!interface->isAtMinimum()) interface->step(true);
+ if (!hit_endstop) interface->step(true);
position--;
}
interface->step(false);
@@ -73,15 +96,42 @@ bool StepperAxis::doHoming(const int32_t intervals) {
if (counter >= 0) {
interface->setDirection(direction);
counter -= intervals;
+ bool hit_endstop = direction ? interface->isAtMaximum() : interface->isAtMinimum();
+#if defined(SINGLE_SWITCH_ENDSTOPS) && (SINGLE_SWITCH_ENDSTOPS == 1)
+// For homing we act a little different .. we assume we are there if we start out hitting the endstop
+ if (hit_endstop) {
+ // Did we *just* hit the endstop?
+ if (endstop_status == ESS_UNKNOWN) {
+ // we "hit" the endstop, so we'll record this direction as the one we hit
+ endstop_status = direction ? ESS_AT_MAXIMUM : ESS_AT_MINIMUM;
+ } else if (endstop_status == ESS_TRAVELING) {
+ endstop_play = ENDSTOP_DEFAULT_PLAY;
+ if (endstop_status != ESS_UNKNOWN)
+ endstop_status = direction ? ESS_AT_MAXIMUM : ESS_AT_MINIMUM;
+ hit_endstop = false; // pretend this never happened... :-)
+
+ // OR, are we traveling away from the endstop we just hit and still have play...
+ } else if (endstop_play > 0 && (endstop_status != (direction ? ESS_AT_MAXIMUM : ESS_AT_MINIMUM))) {
+ --endstop_play;
+ hit_endstop = false; // pretend this never happened... :-)
+ }
+ // otherwise we hit the endstop
+
+ // but if we didn't hit an endstop, clear the status
+ } else {
+ endstop_status = ESS_TRAVELING;
+ }
+#endif //SINGLE_SWITCH_ENDSTOPS
+
if (direction) {
- if (!interface->isAtMaximum()) {
+ if (!hit_endstop) {
interface->step(true);
} else {
return false;
}
position++;
} else {
- if (!interface->isAtMinimum()) {
+ if (!hit_endstop) {
interface->step(true);
} else {
return false;
View
17 v2/src/shared/StepperAxis.hh
@@ -2,6 +2,11 @@
#define STEPPERAXIS_HH
#include "StepperInterface.hh"
+#include "Configuration.hh"
+
+// If we started with an endstop triggered, then we don't know where we are
+// So we can go this many steps either way until we find out...
+#define ENDSTOP_DEFAULT_PLAY 10000
/// The stepper axis module implmeents a driver for a single stepper axis. It is designed
/// to be accessed via the Steppers namespace, and uses a StepperInterface to talk to the
@@ -20,6 +25,18 @@ public:
///< zero, a step is taken.
volatile int32_t delta; ///< Amount to increment counter per tick
volatile bool direction; ///< True for positive, false for negative
+#if defined(SINGLE_SWITCH_ENDSTOPS) && (SINGLE_SWITCH_ENDSTOPS == 1)
+ volatile int32_t endstop_play; ///< Amount to move while endstop triggered, to see which way to move
+
+ enum endstop_status_t {///< State of the endstop
+ ESS_UNKNOWN,
+ ESS_TRAVELING,
+ ESS_AT_MAXIMUM,
+ ESS_AT_MINIMUM
+ };
+
+ volatile endstop_status_t endstop_status;
+#endif //SINGLE_SWITCH_ENDSTOPS
public:
/// Construct a stepper axis with a null interface

0 comments on commit 8d5c7db

Please sign in to comment.
Something went wrong with that request. Please try again.