|
|
|
@ -348,55 +348,19 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
|
|
|
|
|
// Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY)
|
|
|
|
|
if((out_bits & (1<<X_AXIS))!=0){
|
|
|
|
|
#ifdef DUAL_X_CARRIAGE
|
|
|
|
|
if (extruder_duplication_enabled){
|
|
|
|
|
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
|
|
|
|
WRITE(X2_DIR_PIN, INVERT_X_DIR);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if (current_block->active_extruder != 0)
|
|
|
|
|
WRITE(X2_DIR_PIN, INVERT_X_DIR);
|
|
|
|
|
else
|
|
|
|
|
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
|
|
|
|
#endif
|
|
|
|
|
count_direction[X_AXIS]=-1;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
#ifdef DUAL_X_CARRIAGE
|
|
|
|
|
if (extruder_duplication_enabled){
|
|
|
|
|
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
|
|
|
|
WRITE(X2_DIR_PIN, !INVERT_X_DIR);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if (current_block->active_extruder != 0)
|
|
|
|
|
WRITE(X2_DIR_PIN, !INVERT_X_DIR);
|
|
|
|
|
else
|
|
|
|
|
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
|
|
|
|
#endif
|
|
|
|
|
count_direction[X_AXIS]=1;
|
|
|
|
|
}
|
|
|
|
|
if((out_bits & (1<<Y_AXIS))!=0){
|
|
|
|
|
WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
|
|
|
|
|
|
|
|
|
#ifdef Y_DUAL_STEPPER_DRIVERS
|
|
|
|
|
WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
count_direction[Y_AXIS]=-1;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
|
|
|
|
|
|
|
|
|
#ifdef Y_DUAL_STEPPER_DRIVERS
|
|
|
|
|
WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
count_direction[Y_AXIS]=1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -407,15 +371,9 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) != 0)) { //-X occurs for -A and -B
|
|
|
|
|
#endif
|
|
|
|
|
CHECK_ENDSTOPS
|
|
|
|
|
{
|
|
|
|
|
#ifdef DUAL_X_CARRIAGE
|
|
|
|
|
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
|
|
|
|
|
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1)
|
|
|
|
|
|| (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
|
|
|
|
bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
|
|
|
|
|
bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_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;
|
|
|
|
@ -425,18 +383,11 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { // +direction
|
|
|
|
|
CHECK_ENDSTOPS
|
|
|
|
|
{
|
|
|
|
|
#ifdef DUAL_X_CARRIAGE
|
|
|
|
|
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
|
|
|
|
|
if ((current_block->active_extruder == 0 && X_HOME_DIR == 1)
|
|
|
|
|
|| (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
|
|
|
|
|
bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
|
|
|
|
|
bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
|
|
|
|
|
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
|
|
|
|
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
|
|
|
|
endstop_x_hit=true;
|
|
|
|
@ -446,7 +397,6 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef COREXY
|
|
|
|
|
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
|
|
|
|
@ -456,7 +406,7 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
CHECK_ENDSTOPS
|
|
|
|
|
{
|
|
|
|
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
|
|
|
|
|
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
|
|
|
|
|
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_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;
|
|
|
|
@ -470,7 +420,7 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
CHECK_ENDSTOPS
|
|
|
|
|
{
|
|
|
|
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
|
|
|
|
|
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
|
|
|
|
|
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_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;
|
|
|
|
@ -492,7 +442,7 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
CHECK_ENDSTOPS
|
|
|
|
|
{
|
|
|
|
|
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
|
|
|
|
|
bool z_min_endstop=(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
|
|
|
|
bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
|
|
|
|
|
if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
|
|
|
|
|
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
|
|
|
|
endstop_z_hit=true;
|
|
|
|
@ -513,7 +463,7 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
CHECK_ENDSTOPS
|
|
|
|
|
{
|
|
|
|
|
#if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
|
|
|
|
|
bool z_max_endstop=(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
|
|
|
|
|
bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
|
|
|
|
|
if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
|
|
|
|
|
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
|
|
|
|
endstop_z_hit=true;
|
|
|
|
@ -557,53 +507,18 @@ ISR(TIMER1_COMPA_vect)
|
|
|
|
|
|
|
|
|
|
counter_x += current_block->steps_x;
|
|
|
|
|
if (counter_x > 0) {
|
|
|
|
|
#ifdef DUAL_X_CARRIAGE
|
|
|
|
|
if (extruder_duplication_enabled){
|
|
|
|
|
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
|
|
|
|
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (current_block->active_extruder != 0)
|
|
|
|
|
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
|
|
|
|
|
else
|
|
|
|
|
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
counter_x -= current_block->step_event_count;
|
|
|
|
|
count_position[X_AXIS]+=count_direction[X_AXIS];
|
|
|
|
|
#ifdef DUAL_X_CARRIAGE
|
|
|
|
|
if (extruder_duplication_enabled){
|
|
|
|
|
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
|
|
|
|
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (current_block->active_extruder != 0)
|
|
|
|
|
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
|
|
|
|
|
else
|
|
|
|
|
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
counter_y += current_block->steps_y;
|
|
|
|
|
if (counter_y > 0) {
|
|
|
|
|
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
|
|
|
|
|
|
|
|
|
#ifdef Y_DUAL_STEPPER_DRIVERS
|
|
|
|
|
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
counter_y -= current_block->step_event_count;
|
|
|
|
|
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
|
|
|
|
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
|
|
|
|
|
|
|
|
|
#ifdef Y_DUAL_STEPPER_DRIVERS
|
|
|
|
|
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
counter_z += current_block->steps_z;
|
|
|
|
@ -770,15 +685,8 @@ void st_init()
|
|
|
|
|
#if defined(X_DIR_PIN) && X_DIR_PIN > -1
|
|
|
|
|
SET_OUTPUT(X_DIR_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
|
|
|
|
|
SET_OUTPUT(X2_DIR_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
|
|
|
|
|
SET_OUTPUT(Y_DIR_PIN);
|
|
|
|
|
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
|
|
|
|
|
SET_OUTPUT(Y2_DIR_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
|
|
|
|
|
SET_OUTPUT(Z_DIR_PIN);
|
|
|
|
@ -803,18 +711,9 @@ void st_init()
|
|
|
|
|
SET_OUTPUT(X_ENABLE_PIN);
|
|
|
|
|
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|
|
|
|
|
SET_OUTPUT(X2_ENABLE_PIN);
|
|
|
|
|
if(!X_ENABLE_ON) WRITE(X2_ENABLE_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
|
|
|
|
|
SET_OUTPUT(Y_ENABLE_PIN);
|
|
|
|
|
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
|
|
|
|
|
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
|
|
|
|
|
SET_OUTPUT(Y2_ENABLE_PIN);
|
|
|
|
|
if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
|
|
|
|
|
SET_OUTPUT(Z_ENABLE_PIN);
|
|
|
|
@ -889,18 +788,9 @@ void st_init()
|
|
|
|
|
WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
|
|
|
|
|
disable_x();
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
|
|
|
|
|
SET_OUTPUT(X2_STEP_PIN);
|
|
|
|
|
WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
|
|
|
|
|
disable_x();
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
|
|
|
|
|
SET_OUTPUT(Y_STEP_PIN);
|
|
|
|
|
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
|
|
|
|
|
SET_OUTPUT(Y2_STEP_PIN);
|
|
|
|
|
WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
disable_y();
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
|
|
|
|
|