Add support for Triple-Z steppers/endstops
This commit is contained in:
committed by
Scott Lahteine
parent
bc06406d7d
commit
1a6f2b29b8
@ -107,8 +107,8 @@ Stepper stepper; // Singleton
|
||||
|
||||
// public:
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
bool Stepper::homing_dual_axis = false;
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
bool Stepper::separate_multi_axis = false;
|
||||
#endif
|
||||
|
||||
#if HAS_MOTOR_CURRENT_PWM
|
||||
@ -134,9 +134,12 @@ bool Stepper::abort_current_block;
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
bool Stepper::locked_Y_motor = false, Stepper::locked_Y2_motor = false;
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
bool Stepper::locked_Z_motor = false, Stepper::locked_Z2_motor = false;
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
bool Stepper::locked_Z3_motor = false;
|
||||
#endif
|
||||
|
||||
uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
|
||||
uint8_t Stepper::steps_per_isr;
|
||||
@ -202,23 +205,40 @@ volatile int32_t Stepper::endstops_trigsteps[XYZ];
|
||||
volatile int32_t Stepper::count_position[NUM_AXIS] = { 0 };
|
||||
int8_t Stepper::count_direction[NUM_AXIS] = { 0, 0, 0, 0 };
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
|
||||
if (homing_dual_axis) { \
|
||||
if (A##_HOME_DIR < 0) { \
|
||||
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
|
||||
} \
|
||||
else { \
|
||||
if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
A##_STEP_WRITE(V); \
|
||||
A##2_STEP_WRITE(V); \
|
||||
}
|
||||
#endif
|
||||
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
|
||||
if (separate_multi_axis) { \
|
||||
if (A##_HOME_DIR < 0) { \
|
||||
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
|
||||
} \
|
||||
else { \
|
||||
if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
A##_STEP_WRITE(V); \
|
||||
A##2_STEP_WRITE(V); \
|
||||
}
|
||||
|
||||
#define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \
|
||||
if (separate_multi_axis) { \
|
||||
if (A##_HOME_DIR < 0) { \
|
||||
if (!(TEST(endstops.state(), A##_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##2_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##3_MIN) && count_direction[_AXIS(A)] < 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \
|
||||
} \
|
||||
else { \
|
||||
if (!(TEST(endstops.state(), A##_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##2_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##2_motor) A##2_STEP_WRITE(V); \
|
||||
if (!(TEST(endstops.state(), A##3_MAX) && count_direction[_AXIS(A)] > 0) && !locked_##A##3_motor) A##3_STEP_WRITE(V); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
A##_STEP_WRITE(V); \
|
||||
A##2_STEP_WRITE(V); \
|
||||
A##3_STEP_WRITE(V); \
|
||||
}
|
||||
|
||||
#if ENABLED(X_DUAL_STEPPER_DRIVERS)
|
||||
#define X_APPLY_DIR(v,Q) do{ X_DIR_WRITE(v); X2_DIR_WRITE((v) != INVERT_X2_VS_X_DIR); }while(0)
|
||||
@ -261,7 +281,14 @@ int8_t Stepper::count_direction[NUM_AXIS] = { 0, 0, 0, 0 };
|
||||
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
|
||||
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
|
||||
#define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); Z3_DIR_WRITE(v); }while(0)
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#define Z_APPLY_STEP(v,Q) TRIPLE_ENDSTOP_APPLY_STEP(Z,v)
|
||||
#else
|
||||
#define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); }while(0)
|
||||
#endif
|
||||
#elif ENABLED(Z_DUAL_STEPPER_DRIVERS)
|
||||
#define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }while(0)
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
#define Z_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Z,v)
|
||||
@ -1933,9 +1960,12 @@ void Stepper::init() {
|
||||
#endif
|
||||
#if HAS_Z_DIR
|
||||
Z_DIR_INIT;
|
||||
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
|
||||
#if Z_MULTI_STEPPER_DRIVERS && HAS_Z2_DIR
|
||||
Z2_DIR_INIT;
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && HAS_Z3_DIR
|
||||
Z3_DIR_INIT;
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_E0_DIR
|
||||
E0_DIR_INIT;
|
||||
@ -1973,10 +2003,14 @@ void Stepper::init() {
|
||||
#if HAS_Z_ENABLE
|
||||
Z_ENABLE_INIT;
|
||||
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
|
||||
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
|
||||
#if Z_MULTI_STEPPER_DRIVERS && HAS_Z2_ENABLE
|
||||
Z2_ENABLE_INIT;
|
||||
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && HAS_Z3_ENABLE
|
||||
Z3_ENABLE_INIT;
|
||||
if (!Z_ENABLE_ON) Z3_ENABLE_WRITE(HIGH);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_E0_ENABLE
|
||||
E0_ENABLE_INIT;
|
||||
@ -2028,10 +2062,14 @@ void Stepper::init() {
|
||||
#endif
|
||||
|
||||
#if HAS_Z_STEP
|
||||
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
|
||||
#if Z_MULTI_STEPPER_DRIVERS
|
||||
Z2_STEP_INIT;
|
||||
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
|
||||
Z3_STEP_INIT;
|
||||
Z3_STEP_WRITE(INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
AXIS_INIT(Z, Z);
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user