|
|
@ -342,11 +342,15 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
|
|
|
|
return timer;
|
|
|
|
return timer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// set the stepper direction of each axis
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Set the stepper direction of each axis
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY
|
|
|
|
|
|
|
|
* X_AXIS=A_AXIS and Z_AXIS=C_AXIS for COREXZ
|
|
|
|
|
|
|
|
*/
|
|
|
|
void set_stepper_direction() {
|
|
|
|
void set_stepper_direction() {
|
|
|
|
|
|
|
|
|
|
|
|
// Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY)
|
|
|
|
if (TEST(out_bits, X_AXIS)) { // A_AXIS
|
|
|
|
if (TEST(out_bits, X_AXIS)) {
|
|
|
|
|
|
|
|
X_APPLY_DIR(INVERT_X_DIR, 0);
|
|
|
|
X_APPLY_DIR(INVERT_X_DIR, 0);
|
|
|
|
count_direction[X_AXIS] = -1;
|
|
|
|
count_direction[X_AXIS] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -355,7 +359,7 @@ void set_stepper_direction() {
|
|
|
|
count_direction[X_AXIS] = 1;
|
|
|
|
count_direction[X_AXIS] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (TEST(out_bits, Y_AXIS)) {
|
|
|
|
if (TEST(out_bits, Y_AXIS)) { // B_AXIS
|
|
|
|
Y_APPLY_DIR(INVERT_Y_DIR, 0);
|
|
|
|
Y_APPLY_DIR(INVERT_Y_DIR, 0);
|
|
|
|
count_direction[Y_AXIS] = -1;
|
|
|
|
count_direction[Y_AXIS] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -364,7 +368,7 @@ void set_stepper_direction() {
|
|
|
|
count_direction[Y_AXIS] = 1;
|
|
|
|
count_direction[Y_AXIS] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (TEST(out_bits, Z_AXIS)) {
|
|
|
|
if (TEST(out_bits, Z_AXIS)) { // C_AXIS
|
|
|
|
Z_APPLY_DIR(INVERT_Z_DIR, 0);
|
|
|
|
Z_APPLY_DIR(INVERT_Z_DIR, 0);
|
|
|
|
count_direction[Z_AXIS] = -1;
|
|
|
|
count_direction[Z_AXIS] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -503,6 +507,11 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
// If DeltaX == -DeltaY, the movement is only in Y axis
|
|
|
|
// If DeltaX == -DeltaY, the movement is only in Y axis
|
|
|
|
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
|
|
|
|
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
|
|
|
|
if (TEST(out_bits, X_HEAD))
|
|
|
|
if (TEST(out_bits, X_HEAD))
|
|
|
|
|
|
|
|
#elif defined(COREXZ)
|
|
|
|
|
|
|
|
// Head direction in -X axis for CoreXZ bots.
|
|
|
|
|
|
|
|
// If DeltaX == -DeltaZ, the movement is only in Z axis
|
|
|
|
|
|
|
|
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, C_AXIS))) {
|
|
|
|
|
|
|
|
if (TEST(out_bits, X_HEAD))
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
|
|
|
|
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -528,8 +537,11 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef COREXY
|
|
|
|
#if defined(COREXY) || defined(COREXZ)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef COREXY
|
|
|
|
// Head direction in -Y axis for CoreXY bots.
|
|
|
|
// Head direction in -Y axis for CoreXY bots.
|
|
|
|
// If DeltaX == DeltaY, the movement is only in X axis
|
|
|
|
// If DeltaX == DeltaY, the movement is only in X axis
|
|
|
|
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS))) {
|
|
|
|
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS))) {
|
|
|
@ -547,10 +559,19 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
UPDATE_ENDSTOP(Y, MAX);
|
|
|
|
UPDATE_ENDSTOP(Y, MAX);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef COREXY
|
|
|
|
#if defined(COREXY) || defined(COREXZ)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (TEST(out_bits, Z_AXIS)) { // z -direction
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef COREXZ
|
|
|
|
|
|
|
|
// Head direction in -Z axis for CoreXZ bots.
|
|
|
|
|
|
|
|
// If DeltaX == DeltaZ, the movement is only in X axis
|
|
|
|
|
|
|
|
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, C_AXIS))) {
|
|
|
|
|
|
|
|
if (TEST(out_bits, Z_HEAD))
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
if (TEST(out_bits, Z_AXIS))
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{ // z -direction
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef Z_DUAL_ENDSTOPS
|
|
|
|
#ifdef Z_DUAL_ENDSTOPS
|
|
|
|