G34 Auto-align multi-stepper Z axis (#11302)
This commit is contained in:
committed by
Scott Lahteine
parent
f9b80e7217
commit
5536228359
@ -1209,6 +1209,34 @@ void set_axis_is_at_home(const AxisEnum axis) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an axis' to be unhomed.
|
||||
*/
|
||||
void set_axis_is_not_at_home(const AxisEnum axis) {
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
SERIAL_ECHOPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis]);
|
||||
SERIAL_CHAR(')');
|
||||
SERIAL_EOL();
|
||||
}
|
||||
#endif
|
||||
|
||||
CBI(axis_known_position, axis);
|
||||
CBI(axis_homed, axis);
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
SERIAL_ECHOPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis]);
|
||||
SERIAL_CHAR(')');
|
||||
SERIAL_EOL();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
I2CPEM.unhomed(axis);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Home an individual "raw axis" to its endstop.
|
||||
* This applies to XYZ on Cartesian and Core robots, and
|
||||
@ -1260,17 +1288,7 @@ void homeaxis(const AxisEnum axis) {
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
case Y_AXIS:
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
case Z_AXIS:
|
||||
#endif
|
||||
stepper.set_separate_multi_axis(true);
|
||||
default: break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
switch (axis) {
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
case Z_AXIS:
|
||||
#endif
|
||||
stepper.set_separate_multi_axis(true);
|
||||
|
@ -197,6 +197,8 @@ void clean_up_after_endstop_or_probe_move();
|
||||
|
||||
void set_axis_is_at_home(const AxisEnum axis);
|
||||
|
||||
void set_axis_is_not_at_home(const AxisEnum axis);
|
||||
|
||||
void homeaxis(const AxisEnum axis);
|
||||
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
|
@ -115,7 +115,7 @@ Stepper stepper; // Singleton
|
||||
|
||||
// public:
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS || ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
bool Stepper::separate_multi_axis = false;
|
||||
#endif
|
||||
|
||||
@ -142,10 +142,10 @@ bool Stepper::abort_current_block;
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
bool Stepper::locked_Y_motor = false, Stepper::locked_Y2_motor = false;
|
||||
#endif
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
#if Z_MULTI_ENDSTOPS || ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
bool Stepper::locked_Z_motor = false, Stepper::locked_Z2_motor = false;
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS) || (ENABLED(Z_STEPPER_AUTO_ALIGN) && ENABLED(Z_TRIPLE_STEPPER_DRIVERS))
|
||||
bool Stepper::locked_Z3_motor = false;
|
||||
#endif
|
||||
|
||||
@ -211,7 +211,7 @@ 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 };
|
||||
|
||||
#define DUAL_ENDSTOP_APPLY_STEP(A,V) \
|
||||
#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); \
|
||||
@ -227,7 +227,17 @@ int8_t Stepper::count_direction[NUM_AXIS] = { 0, 0, 0, 0 };
|
||||
A##2_STEP_WRITE(V); \
|
||||
}
|
||||
|
||||
#define TRIPLE_ENDSTOP_APPLY_STEP(A,V) \
|
||||
#define DUAL_SEPARATE_APPLY_STEP(A,V) \
|
||||
if (separate_multi_axis) { \
|
||||
if (!locked_##A##_motor) A##_STEP_WRITE(V); \
|
||||
if (!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); \
|
||||
@ -298,6 +308,8 @@ int8_t Stepper::count_direction[NUM_AXIS] = { 0, 0, 0, 0 };
|
||||
#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)
|
||||
#elif ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
#define Z_APPLY_STEP(v,Q) DUAL_SEPARATE_APPLY_STEP(Z,v)
|
||||
#else
|
||||
#define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); }while(0)
|
||||
#endif
|
||||
|
@ -244,7 +244,7 @@ class Stepper {
|
||||
|
||||
public:
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS || ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
static bool separate_multi_axis;
|
||||
#endif
|
||||
|
||||
@ -277,10 +277,10 @@ class Stepper {
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
static bool locked_Y_motor, locked_Y2_motor;
|
||||
#endif
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
#if Z_MULTI_ENDSTOPS || ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
static bool locked_Z_motor, locked_Z2_motor;
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS) || (ENABLED(Z_STEPPER_AUTO_ALIGN) && ENABLED(Z_TRIPLE_STEPPER_DRIVERS))
|
||||
static bool locked_Z3_motor;
|
||||
#endif
|
||||
|
||||
@ -421,7 +421,7 @@ class Stepper {
|
||||
static void microstep_readings();
|
||||
#endif
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS || ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
FORCE_INLINE static void set_separate_multi_axis(const bool state) { separate_multi_axis = state; }
|
||||
#endif
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
@ -432,11 +432,11 @@ class Stepper {
|
||||
FORCE_INLINE static void set_y_lock(const bool state) { locked_Y_motor = state; }
|
||||
FORCE_INLINE static void set_y2_lock(const bool state) { locked_Y2_motor = state; }
|
||||
#endif
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
#if Z_MULTI_ENDSTOPS || (ENABLED(Z_STEPPER_AUTO_ALIGN) && Z_MULTI_STEPPER_DRIVERS)
|
||||
FORCE_INLINE static void set_z_lock(const bool state) { locked_Z_motor = state; }
|
||||
FORCE_INLINE static void set_z2_lock(const bool state) { locked_Z2_motor = state; }
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS) || (ENABLED(Z_STEPPER_AUTO_ALIGN) && ENABLED(Z_TRIPLE_STEPPER_DRIVERS))
|
||||
FORCE_INLINE static void set_z3_lock(const bool state) { locked_Z3_motor = state; }
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user