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:
parent
a0125dedfc
commit
f577431aac
48
dda.c
48
dda.c
|
|
@ -785,60 +785,60 @@ void dda_clock() {
|
||||||
// in principle (but rarely) happen if endstops are checked not as
|
// in principle (but rarely) happen if endstops are checked not as
|
||||||
// endstop search, but as part of normal operations.
|
// endstop search, but as part of normal operations.
|
||||||
if (dda->endstop_check && ! move_state.endstop_stop) {
|
if (dda->endstop_check && ! move_state.endstop_stop) {
|
||||||
#if defined X_MIN_PIN || defined X_MAX_PIN
|
#ifdef X_MIN_PIN
|
||||||
if (dda->endstop_check & 0x1) {
|
if (dda->endstop_check & 0x01) {
|
||||||
#if defined X_MIN_PIN
|
|
||||||
if (x_min() == dda->endstop_stop_cond)
|
if (x_min() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_xmin++;
|
move_state.debounce_count_xmin++;
|
||||||
else
|
else
|
||||||
move_state.debounce_count_xmin = 0;
|
move_state.debounce_count_xmin = 0;
|
||||||
#endif
|
endstop_trigger = move_state.debounce_count_xmin >= ENDSTOP_STEPS;
|
||||||
#if defined X_MAX_PIN
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef X_MAX_PIN
|
||||||
|
if (dda->endstop_check & 0x02) {
|
||||||
if (x_max() == dda->endstop_stop_cond)
|
if (x_max() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_xmax++;
|
move_state.debounce_count_xmax++;
|
||||||
else
|
else
|
||||||
move_state.debounce_count_xmax = 0;
|
move_state.debounce_count_xmax = 0;
|
||||||
#endif
|
endstop_trigger = move_state.debounce_count_xmax >= ENDSTOP_STEPS;
|
||||||
endstop_trigger = move_state.debounce_count_xmin >= ENDSTOP_STEPS ||
|
|
||||||
move_state.debounce_count_xmax >= ENDSTOP_STEPS;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined Y_MIN_PIN || defined Y_MAX_PIN
|
#ifdef Y_MIN_PIN
|
||||||
if (dda->endstop_check & 0x2) {
|
if (dda->endstop_check & 0x04) {
|
||||||
#if defined Y_MIN_PIN
|
|
||||||
if (y_min() == dda->endstop_stop_cond)
|
if (y_min() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_ymin++;
|
move_state.debounce_count_ymin++;
|
||||||
else
|
else
|
||||||
move_state.debounce_count_ymin = 0;
|
move_state.debounce_count_ymin = 0;
|
||||||
#endif
|
endstop_trigger = move_state.debounce_count_ymin >= ENDSTOP_STEPS;
|
||||||
#if defined Y_MAX_PIN
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef Y_MAX_PIN
|
||||||
|
if (dda->endstop_check & 0x08) {
|
||||||
if (y_max() == dda->endstop_stop_cond)
|
if (y_max() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_ymax++;
|
move_state.debounce_count_ymax++;
|
||||||
else
|
else
|
||||||
move_state.debounce_count_ymax = 0;
|
move_state.debounce_count_ymax = 0;
|
||||||
#endif
|
endstop_trigger = move_state.debounce_count_ymax >= ENDSTOP_STEPS;
|
||||||
endstop_trigger = move_state.debounce_count_ymin >= ENDSTOP_STEPS ||
|
|
||||||
move_state.debounce_count_ymax >= ENDSTOP_STEPS;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined Z_MIN_PIN || defined Z_MAX_PIN
|
#ifdef Z_MIN_PIN
|
||||||
if (dda->endstop_check & 0x4) {
|
if (dda->endstop_check & 0x10) {
|
||||||
#if defined Z_MIN_PIN
|
|
||||||
if (z_min() == dda->endstop_stop_cond)
|
if (z_min() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_zmin++;
|
move_state.debounce_count_zmin++;
|
||||||
else
|
else
|
||||||
move_state.debounce_count_zmin = 0;
|
move_state.debounce_count_zmin = 0;
|
||||||
#endif
|
endstop_trigger = move_state.debounce_count_zmin >= ENDSTOP_STEPS;
|
||||||
#if defined Z_MAX_PIN
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef Z_MAX_PIN
|
||||||
|
if (dda->endstop_check & 0x20) {
|
||||||
if (z_max() == dda->endstop_stop_cond)
|
if (z_max() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_zmax++;
|
move_state.debounce_count_zmax++;
|
||||||
else
|
else
|
||||||
move_state.debounce_count_zmax = 0;
|
move_state.debounce_count_zmax = 0;
|
||||||
#endif
|
endstop_trigger = move_state.debounce_count_zmax >= ENDSTOP_STEPS;
|
||||||
endstop_trigger = move_state.debounce_count_zmin >= ENDSTOP_STEPS ||
|
|
||||||
move_state.debounce_count_zmax >= ENDSTOP_STEPS;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
24
home.c
24
home.c
|
|
@ -77,13 +77,13 @@ void home_x_negative() {
|
||||||
t.F = SEARCH_FAST_X;
|
t.F = SEARCH_FAST_X;
|
||||||
else
|
else
|
||||||
t.F = SEARCH_FEEDRATE_X;
|
t.F = SEARCH_FEEDRATE_X;
|
||||||
enqueue_home(&t, 0x1, 1);
|
enqueue_home(&t, 0x01, 1);
|
||||||
|
|
||||||
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
|
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
|
||||||
// back off slowly
|
// back off slowly
|
||||||
t.axis[X] = +1000000;
|
t.axis[X] = +1000000;
|
||||||
t.F = SEARCH_FEEDRATE_X;
|
t.F = SEARCH_FEEDRATE_X;
|
||||||
enqueue_home(&t, 0x1, 0);
|
enqueue_home(&t, 0x01, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set X home
|
// set X home
|
||||||
|
|
@ -110,12 +110,12 @@ void home_x_positive() {
|
||||||
t.F = SEARCH_FAST_X;
|
t.F = SEARCH_FAST_X;
|
||||||
else
|
else
|
||||||
t.F = SEARCH_FEEDRATE_X;
|
t.F = SEARCH_FEEDRATE_X;
|
||||||
enqueue_home(&t, 0x1, 1);
|
enqueue_home(&t, 0x02, 1);
|
||||||
|
|
||||||
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
|
if (SEARCH_FAST_X > SEARCH_FEEDRATE_X) {
|
||||||
t.axis[X] = -1000000;
|
t.axis[X] = -1000000;
|
||||||
t.F = SEARCH_FEEDRATE_X;
|
t.F = SEARCH_FEEDRATE_X;
|
||||||
enqueue_home(&t, 0x1, 0);
|
enqueue_home(&t, 0x02, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set X home
|
// set X home
|
||||||
|
|
@ -136,12 +136,12 @@ void home_y_negative() {
|
||||||
t.F = SEARCH_FAST_Y;
|
t.F = SEARCH_FAST_Y;
|
||||||
else
|
else
|
||||||
t.F = SEARCH_FEEDRATE_Y;
|
t.F = SEARCH_FEEDRATE_Y;
|
||||||
enqueue_home(&t, 0x2, 1);
|
enqueue_home(&t, 0x04, 1);
|
||||||
|
|
||||||
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
|
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
|
||||||
t.axis[Y] = +1000000;
|
t.axis[Y] = +1000000;
|
||||||
t.F = SEARCH_FEEDRATE_Y;
|
t.F = SEARCH_FEEDRATE_Y;
|
||||||
enqueue_home(&t, 0x2, 0);
|
enqueue_home(&t, 0x04, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set Y home
|
// set Y home
|
||||||
|
|
@ -168,12 +168,12 @@ void home_y_positive() {
|
||||||
t.F = SEARCH_FAST_Y;
|
t.F = SEARCH_FAST_Y;
|
||||||
else
|
else
|
||||||
t.F = SEARCH_FEEDRATE_Y;
|
t.F = SEARCH_FEEDRATE_Y;
|
||||||
enqueue_home(&t, 0x2, 1);
|
enqueue_home(&t, 0x08, 1);
|
||||||
|
|
||||||
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
|
if (SEARCH_FAST_Y > SEARCH_FEEDRATE_Y) {
|
||||||
t.axis[Y] = -1000000;
|
t.axis[Y] = -1000000;
|
||||||
t.F = SEARCH_FEEDRATE_Y;
|
t.F = SEARCH_FEEDRATE_Y;
|
||||||
enqueue_home(&t, 0x2, 0);
|
enqueue_home(&t, 0x08, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set Y home
|
// set Y home
|
||||||
|
|
@ -194,12 +194,12 @@ void home_z_negative() {
|
||||||
t.F = SEARCH_FAST_Z;
|
t.F = SEARCH_FAST_Z;
|
||||||
else
|
else
|
||||||
t.F = SEARCH_FEEDRATE_Z;
|
t.F = SEARCH_FEEDRATE_Z;
|
||||||
enqueue_home(&t, 0x4, 1);
|
enqueue_home(&t, 0x10, 1);
|
||||||
|
|
||||||
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
|
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
|
||||||
t.axis[Z] = +1000000;
|
t.axis[Z] = +1000000;
|
||||||
t.F = SEARCH_FEEDRATE_Z;
|
t.F = SEARCH_FEEDRATE_Z;
|
||||||
enqueue_home(&t, 0x4, 0);
|
enqueue_home(&t, 0x10, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set Z home
|
// set Z home
|
||||||
|
|
@ -226,12 +226,12 @@ void home_z_positive() {
|
||||||
t.F = SEARCH_FAST_Z;
|
t.F = SEARCH_FAST_Z;
|
||||||
else
|
else
|
||||||
t.F = SEARCH_FEEDRATE_Z;
|
t.F = SEARCH_FEEDRATE_Z;
|
||||||
enqueue_home(&t, 0x4, 1);
|
enqueue_home(&t, 0x20, 1);
|
||||||
|
|
||||||
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
|
if (SEARCH_FAST_Z > SEARCH_FEEDRATE_Z) {
|
||||||
t.axis[Z] = -1000000;
|
t.axis[Z] = -1000000;
|
||||||
t.F = SEARCH_FEEDRATE_Z;
|
t.F = SEARCH_FEEDRATE_Z;
|
||||||
enqueue_home(&t, 0x4, 0);
|
enqueue_home(&t, 0x20, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set Z home
|
// set Z home
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue