Fix Endstop check for CoreXY bots.

The X_Axis could not home to min while Y_Max endstop was trigged.
This commit is contained in:
alexborro 2015-03-02 13:36:58 -03:00
parent e428e8da75
commit 715104e477
2 changed files with 73 additions and 78 deletions

View File

@ -180,8 +180,8 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define disable_e3() /* nothing */ #define disable_e3() /* nothing */
#endif #endif
enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5}; enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5};
//X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
void FlushSerialRequestResend(); void FlushSerialRequestResend();
void ClearToSend(); void ClearToSend();

View File

@ -399,89 +399,84 @@ ISR(TIMER1_COMPA_vect)
count_direction[Y_AXIS]=1; count_direction[Y_AXIS]=1;
} }
// Set direction en check limit switches if(check_endstops) // check X and Y Endstops
#ifndef COREXY
if ((out_bits & (1<<X_AXIS)) != 0) // stepping along -X axis
#else
if ((out_bits & (1<<X_HEAD)) != 0) //AlexBorro: Head direction in -X axis for CoreXY bots.
#endif
{ {
CHECK_ENDSTOPS #ifndef COREXY
{ if ((out_bits & (1<<X_AXIS)) != 0) // stepping along -X axis (regular cartesians bot)
#ifdef DUAL_X_CARRIAGE #else
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS != (out_bits & (1<<Y_AXIS))>>Y_AXIS))) // AlexBorro: If DeltaX == -DeltaY, the movement is only in Y axis
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) if ((out_bits & (1<<X_HEAD)) != 0) //AlexBorro: Head direction in -X axis for CoreXY bots.
|| (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) #endif
#endif { // -direction
{ #ifdef DUAL_X_CARRIAGE
#if defined(X_MIN_PIN) && X_MIN_PIN > -1 // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) { #endif
endstops_trigsteps[X_AXIS] = count_position[X_AXIS]; {
endstop_x_hit=true; #if defined(X_MIN_PIN) && X_MIN_PIN > -1
step_events_completed = current_block->step_event_count; bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0))
{
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
endstop_x_hit=true;
step_events_completed = current_block->step_event_count;
}
old_x_min_endstop = x_min_endstop;
#endif
} }
old_x_min_endstop = x_min_endstop;
#endif
} }
} else
} { // +direction
else #ifdef DUAL_X_CARRIAGE
{ // +direction // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
CHECK_ENDSTOPS if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
{ #endif
#ifdef DUAL_X_CARRIAGE {
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder #if defined(X_MAX_PIN) && X_MAX_PIN > -1
if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
|| (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0))
#endif {
{ endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
#if defined(X_MAX_PIN) && X_MAX_PIN > -1 endstop_x_hit=true;
bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); step_events_completed = current_block->step_event_count;
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){ }
endstops_trigsteps[X_AXIS] = count_position[X_AXIS]; old_x_max_endstop = x_max_endstop;
endstop_x_hit=true; #endif
step_events_completed = current_block->step_event_count;
} }
old_x_max_endstop = x_max_endstop;
#endif
} }
}
}
#ifndef COREXY #ifndef COREXY
if ((out_bits & (1<<Y_AXIS)) != 0) // -direction if ((out_bits & (1<<Y_AXIS)) != 0) // -direction
#else #else
if ((out_bits & (1<<Y_HEAD)) != 0) //AlexBorro: Head direction in -Y axis for CoreXY bots. if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS == (out_bits & (1<<Y_AXIS))>>Y_AXIS))) // AlexBorro: If DeltaX == DeltaY, the movement is only in X axis
#endif if ((out_bits & (1<<Y_HEAD)) != 0) //AlexBorro: Head direction in -Y axis for CoreXY bots.
{
CHECK_ENDSTOPS
{
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
endstop_y_hit=true;
step_events_completed = current_block->step_event_count;
}
old_y_min_endstop = y_min_endstop;
#endif #endif
} { // -direction
} #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
else bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
{ // +direction if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0))
CHECK_ENDSTOPS {
{ endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1 endstop_y_hit=true;
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING); step_events_completed = current_block->step_event_count;
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){ }
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS]; old_y_min_endstop = y_min_endstop;
endstop_y_hit=true; #endif
step_events_completed = current_block->step_event_count; }
} else
old_y_max_endstop = y_max_endstop; { // +direction
#endif #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
} bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0))
{
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
endstop_y_hit=true;
step_events_completed = current_block->step_event_count;
}
old_y_max_endstop = y_max_endstop;
#endif
}
} }
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction