home.c, dda.c: consider endstops on both axis ends when homing.

Previously, when backing off of X_MIN, X_MAX was also checked,
which of course was already open, so it signals endstop release
even while X_MIN is still closed. The issue exposed only when
endstops on both ends of an axis were defined, a more rare situation.

Essentially the fix simply makes a distinct endstop check case
for each side of each axis.

This even makes binary size 40 bytes smaller for the standard case.
This commit is contained in:
Markus Hitter 2014-12-27 19:55:04 +01:00
parent a0125dedfc
commit f577431aac
2 changed files with 36 additions and 36 deletions

42
dda.c
View File

@ -785,60 +785,60 @@ void dda_clock() {
// in principle (but rarely) happen if endstops are checked not as
// endstop search, but as part of normal operations.
if (dda->endstop_check && ! move_state.endstop_stop) {
#if defined X_MIN_PIN || defined X_MAX_PIN
if (dda->endstop_check & 0x1) {
#if defined X_MIN_PIN
#ifdef X_MIN_PIN
if (dda->endstop_check & 0x01) {
if (x_min() == dda->endstop_stop_cond)
move_state.debounce_count_xmin++;
else
move_state.debounce_count_xmin = 0;
endstop_trigger = move_state.debounce_count_xmin >= ENDSTOP_STEPS;
}
#endif
#if defined X_MAX_PIN
#ifdef X_MAX_PIN
if (dda->endstop_check & 0x02) {
if (x_max() == dda->endstop_stop_cond)
move_state.debounce_count_xmax++;
else
move_state.debounce_count_xmax = 0;
#endif
endstop_trigger = move_state.debounce_count_xmin >= ENDSTOP_STEPS ||
move_state.debounce_count_xmax >= ENDSTOP_STEPS;
endstop_trigger = move_state.debounce_count_xmax >= ENDSTOP_STEPS;
}
#endif
#if defined Y_MIN_PIN || defined Y_MAX_PIN
if (dda->endstop_check & 0x2) {
#if defined Y_MIN_PIN
#ifdef Y_MIN_PIN
if (dda->endstop_check & 0x04) {
if (y_min() == dda->endstop_stop_cond)
move_state.debounce_count_ymin++;
else
move_state.debounce_count_ymin = 0;
endstop_trigger = move_state.debounce_count_ymin >= ENDSTOP_STEPS;
}
#endif
#if defined Y_MAX_PIN
#ifdef Y_MAX_PIN
if (dda->endstop_check & 0x08) {
if (y_max() == dda->endstop_stop_cond)
move_state.debounce_count_ymax++;
else
move_state.debounce_count_ymax = 0;
#endif
endstop_trigger = move_state.debounce_count_ymin >= ENDSTOP_STEPS ||
move_state.debounce_count_ymax >= ENDSTOP_STEPS;
endstop_trigger = move_state.debounce_count_ymax >= ENDSTOP_STEPS;
}
#endif
#if defined Z_MIN_PIN || defined Z_MAX_PIN
if (dda->endstop_check & 0x4) {
#if defined Z_MIN_PIN
#ifdef Z_MIN_PIN
if (dda->endstop_check & 0x10) {
if (z_min() == dda->endstop_stop_cond)
move_state.debounce_count_zmin++;
else
move_state.debounce_count_zmin = 0;
endstop_trigger = move_state.debounce_count_zmin >= ENDSTOP_STEPS;
}
#endif
#if defined Z_MAX_PIN
#ifdef Z_MAX_PIN
if (dda->endstop_check & 0x20) {
if (z_max() == dda->endstop_stop_cond)
move_state.debounce_count_zmax++;
else
move_state.debounce_count_zmax = 0;
#endif
endstop_trigger = move_state.debounce_count_zmin >= ENDSTOP_STEPS ||
move_state.debounce_count_zmax >= ENDSTOP_STEPS;
endstop_trigger = move_state.debounce_count_zmax >= ENDSTOP_STEPS;
}
#endif

24
home.c
View File

@ -77,13 +77,13 @@ void home_x_negative() {
t.F = SEARCH_FAST_X;
else
t.F = SEARCH_FEEDRATE_X;
enqueue_home(&t, 0x1, 1);
enqueue_home(&t, 0x01, 1);
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
// back off slowly
t.axis[X] = +1000000;
t.F = SEARCH_FEEDRATE_X;
enqueue_home(&t, 0x1, 0);
enqueue_home(&t, 0x01, 0);
}
// set X home
@ -110,12 +110,12 @@ void home_x_positive() {
t.F = SEARCH_FAST_X;
else
t.F = SEARCH_FEEDRATE_X;
enqueue_home(&t, 0x1, 1);
enqueue_home(&t, 0x02, 1);
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
t.axis[X] = -1000000;
t.F = SEARCH_FEEDRATE_X;
enqueue_home(&t, 0x1, 0);
enqueue_home(&t, 0x02, 0);
}
// set X home
@ -136,12 +136,12 @@ void home_y_negative() {
t.F = SEARCH_FAST_Y;
else
t.F = SEARCH_FEEDRATE_Y;
enqueue_home(&t, 0x2, 1);
enqueue_home(&t, 0x04, 1);
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
t.axis[Y] = +1000000;
t.F = SEARCH_FEEDRATE_Y;
enqueue_home(&t, 0x2, 0);
enqueue_home(&t, 0x04, 0);
}
// set Y home
@ -168,12 +168,12 @@ void home_y_positive() {
t.F = SEARCH_FAST_Y;
else
t.F = SEARCH_FEEDRATE_Y;
enqueue_home(&t, 0x2, 1);
enqueue_home(&t, 0x08, 1);
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
t.axis[Y] = -1000000;
t.F = SEARCH_FEEDRATE_Y;
enqueue_home(&t, 0x2, 0);
enqueue_home(&t, 0x08, 0);
}
// set Y home
@ -194,12 +194,12 @@ void home_z_negative() {
t.F = SEARCH_FAST_Z;
else
t.F = SEARCH_FEEDRATE_Z;
enqueue_home(&t, 0x4, 1);
enqueue_home(&t, 0x10, 1);
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
t.axis[Z] = +1000000;
t.F = SEARCH_FEEDRATE_Z;
enqueue_home(&t, 0x4, 0);
enqueue_home(&t, 0x10, 0);
}
// set Z home
@ -226,12 +226,12 @@ void home_z_positive() {
t.F = SEARCH_FAST_Z;
else
t.F = SEARCH_FEEDRATE_Z;
enqueue_home(&t, 0x4, 1);
enqueue_home(&t, 0x20, 1);
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
t.axis[Z] = -1000000;
t.F = SEARCH_FEEDRATE_Z;
enqueue_home(&t, 0x4, 0);
enqueue_home(&t, 0x20, 0);
}
// set Z home