TMC2130 dual-stepper Sensorless Homing (#13061)

This commit is contained in:
mattfredwill 2019-02-02 08:09:01 +08:00 committed by Scott Lahteine
parent f6edd2c472
commit c3cb449990
5 changed files with 41 additions and 5 deletions

View File

@ -278,7 +278,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#if USE_SENSORLESS #if USE_SENSORLESS
// Track enabled status of stealthChop and only re-enable where applicable // Track enabled status of stealthChop and only re-enable where applicable
struct sensorless_t { struct sensorless_t {
bool x, y, z; bool x, y, z, x2, y2, z2, z3;
}; };
bool tmc_enable_stallguard(TMC2130Stepper &st); bool tmc_enable_stallguard(TMC2130Stepper &st);

View File

@ -71,9 +71,15 @@
fr_mm_s = MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0); fr_mm_s = MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
sensorless_t stealth_states { false, false, false }; sensorless_t stealth_states { false, false, false, false, false, false, false };
stealth_states.x = tmc_enable_stallguard(stepperX); stealth_states.x = tmc_enable_stallguard(stepperX);
stealth_states.y = tmc_enable_stallguard(stepperY); stealth_states.y = tmc_enable_stallguard(stepperY);
#if AXIS_HAS_STALLGUARD(X2)
stealth_states.x2 = tmc_enable_stallguard(stepperX2);
#endif
#if AXIS_HAS_STALLGUARD(Y2)
stealth_states.y2 = tmc_enable_stallguard(stepperY2);
#endif
#endif #endif
do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s); do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
@ -85,6 +91,12 @@
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
tmc_disable_stallguard(stepperX, stealth_states.x); tmc_disable_stallguard(stepperX, stealth_states.x);
tmc_disable_stallguard(stepperY, stealth_states.y); tmc_disable_stallguard(stepperY, stealth_states.y);
#if AXIS_HAS_STALLGUARD(X2)
tmc_disable_stallguard(stepperX2, stealth_states.x2);
#endif
#if AXIS_HAS_STALLGUARD(Y2)
tmc_disable_stallguard(stepperY2, stealth_states.y2);
#endif
#endif #endif
} }

View File

@ -222,7 +222,7 @@ void home_delta() {
// Disable stealthChop if used. Enable diag1 pin on driver. // Disable stealthChop if used. Enable diag1 pin on driver.
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
sensorless_t stealth_states { false, false, false }; sensorless_t stealth_states { false, false, false, false, false, false, false };
stealth_states.x = tmc_enable_stallguard(stepperX); stealth_states.x = tmc_enable_stallguard(stepperX);
stealth_states.y = tmc_enable_stallguard(stepperY); stealth_states.y = tmc_enable_stallguard(stepperY);
stealth_states.z = tmc_enable_stallguard(stepperZ); stealth_states.z = tmc_enable_stallguard(stepperZ);

View File

@ -1050,13 +1050,16 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
* Set sensorless homing if the axis has it, accounting for Core Kinematics. * Set sensorless homing if the axis has it, accounting for Core Kinematics.
*/ */
sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) { sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) {
sensorless_t stealth_states { false, false, false }; sensorless_t stealth_states { false, false, false, false, false, false, false };
switch (axis) { switch (axis) {
default: break; default: break;
#if X_SENSORLESS #if X_SENSORLESS
case X_AXIS: case X_AXIS:
stealth_states.x = tmc_enable_stallguard(stepperX); stealth_states.x = tmc_enable_stallguard(stepperX);
#if AXIS_HAS_STALLGUARD(X2)
stealth_states.x2 = tmc_enable_stallguard(stepperX2);
#endif
#if CORE_IS_XY && Y_SENSORLESS #if CORE_IS_XY && Y_SENSORLESS
stealth_states.y = tmc_enable_stallguard(stepperY); stealth_states.y = tmc_enable_stallguard(stepperY);
#elif CORE_IS_XZ && Z_SENSORLESS #elif CORE_IS_XZ && Z_SENSORLESS
@ -1067,6 +1070,9 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
#if Y_SENSORLESS #if Y_SENSORLESS
case Y_AXIS: case Y_AXIS:
stealth_states.y = tmc_enable_stallguard(stepperY); stealth_states.y = tmc_enable_stallguard(stepperY);
#if AXIS_HAS_STALLGUARD(Y2)
stealth_states.y2 = tmc_enable_stallguard(stepperY2);
#endif
#if CORE_IS_XY && X_SENSORLESS #if CORE_IS_XY && X_SENSORLESS
stealth_states.x = tmc_enable_stallguard(stepperX); stealth_states.x = tmc_enable_stallguard(stepperX);
#elif CORE_IS_YZ && Z_SENSORLESS #elif CORE_IS_YZ && Z_SENSORLESS
@ -1077,6 +1083,12 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
#if Z_SENSORLESS #if Z_SENSORLESS
case Z_AXIS: case Z_AXIS:
stealth_states.z = tmc_enable_stallguard(stepperZ); stealth_states.z = tmc_enable_stallguard(stepperZ);
#if AXIS_HAS_STALLGUARD(Z2)
stealth_states.z2 = tmc_enable_stallguard(stepperZ2);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
stealth_states.z3 = tmc_enable_stallguard(stepperZ3);
#endif
#if CORE_IS_XZ && X_SENSORLESS #if CORE_IS_XZ && X_SENSORLESS
stealth_states.x = tmc_enable_stallguard(stepperX); stealth_states.x = tmc_enable_stallguard(stepperX);
#elif CORE_IS_YZ && Y_SENSORLESS #elif CORE_IS_YZ && Y_SENSORLESS
@ -1094,6 +1106,9 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
#if X_SENSORLESS #if X_SENSORLESS
case X_AXIS: case X_AXIS:
tmc_disable_stallguard(stepperX, enable_stealth.x); tmc_disable_stallguard(stepperX, enable_stealth.x);
#if AXIS_HAS_STALLGUARD(X2)
tmc_disable_stallguard(stepperX2, enable_stealth.x2);
#endif
#if CORE_IS_XY && Y_SENSORLESS #if CORE_IS_XY && Y_SENSORLESS
tmc_disable_stallguard(stepperY, enable_stealth.y); tmc_disable_stallguard(stepperY, enable_stealth.y);
#elif CORE_IS_XZ && Z_SENSORLESS #elif CORE_IS_XZ && Z_SENSORLESS
@ -1104,6 +1119,9 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
#if Y_SENSORLESS #if Y_SENSORLESS
case Y_AXIS: case Y_AXIS:
tmc_disable_stallguard(stepperY, enable_stealth.y); tmc_disable_stallguard(stepperY, enable_stealth.y);
#if AXIS_HAS_STALLGUARD(Y2)
tmc_disable_stallguard(stepperY2, enable_stealth.y2);
#endif
#if CORE_IS_XY && X_SENSORLESS #if CORE_IS_XY && X_SENSORLESS
tmc_disable_stallguard(stepperX, enable_stealth.x); tmc_disable_stallguard(stepperX, enable_stealth.x);
#elif CORE_IS_YZ && Z_SENSORLESS #elif CORE_IS_YZ && Z_SENSORLESS
@ -1114,6 +1132,12 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
#if Z_SENSORLESS #if Z_SENSORLESS
case Z_AXIS: case Z_AXIS:
tmc_disable_stallguard(stepperZ, enable_stealth.z); tmc_disable_stallguard(stepperZ, enable_stealth.z);
#if AXIS_HAS_STALLGUARD(Z2)
tmc_disable_stallguard(stepperZ2, enable_stealth.z2);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
tmc_disable_stallguard(stepperZ3, enable_stealth.z3);
#endif
#if CORE_IS_XZ && X_SENSORLESS #if CORE_IS_XZ && X_SENSORLESS
tmc_disable_stallguard(stepperX, enable_stealth.x); tmc_disable_stallguard(stepperX, enable_stealth.x);
#elif CORE_IS_YZ && Y_SENSORLESS #elif CORE_IS_YZ && Y_SENSORLESS

View File

@ -551,7 +551,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
// Disable stealthChop if used. Enable diag1 pin on driver. // Disable stealthChop if used. Enable diag1 pin on driver.
#if ENABLED(SENSORLESS_PROBING) #if ENABLED(SENSORLESS_PROBING)
sensorless_t stealth_states { false, false, false }; sensorless_t stealth_states { false, false, false, false, false, false, false };
#if ENABLED(DELTA) #if ENABLED(DELTA)
stealth_states.x = tmc_enable_stallguard(stepperX); stealth_states.x = tmc_enable_stallguard(stepperX);
stealth_states.y = tmc_enable_stallguard(stepperY); stealth_states.y = tmc_enable_stallguard(stepperY);