Fix SENSORLESS_HOMING for Core Kinematics (#9871)

This commit is contained in:
Scott Lahteine 2018-03-01 01:49:41 -06:00 committed by GitHub
parent 803c3169ad
commit f7b44ac2a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 50 deletions

View File

@ -650,8 +650,13 @@
#define E4_IS_TRINAMIC (ENABLED(E4_IS_TMC2130) || ENABLED(E4_IS_TMC2208))
// Disable Z axis sensorless homing if a probe is used to home the Z axis
#if ENABLED(SENSORLESS_HOMING) && HOMING_Z_WITH_PROBE
#undef Z_HOMING_SENSITIVITY
#if ENABLED(SENSORLESS_HOMING)
#define X_SENSORLESS (ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY))
#define Y_SENSORLESS (ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY))
#define Z_SENSORLESS (ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY))
#if HOMING_Z_WITH_PROBE
#undef Z_HOMING_SENSITIVITY
#endif
#endif
// Endstops and bed probe

View File

@ -2852,6 +2852,48 @@ static void clean_up_after_endstop_or_probe_move() {
#endif // AUTO_BED_LEVELING_BILINEAR
#if ENABLED(SENSORLESS_HOMING)
/**
* Set sensorless homing if the axis has it, accounting for Core Kinematics.
*/
void sensorless_homing_per_axis(const AxisEnum axis, const bool enable=true) {
switch (axis) {
#if X_SENSORLESS
case X_AXIS:
tmc_sensorless_homing(stepperX, enable);
#if CORE_IS_XY && Y_SENSORLESS
tmc_sensorless_homing(stepperY, enable);
#elif CORE_IS_XZ && Z_SENSORLESS
tmc_sensorless_homing(stepperZ, enable);
#endif
break;
#endif
#if Y_SENSORLESS
case Y_AXIS:
tmc_sensorless_homing(stepperY, enable);
#if CORE_IS_XY && X_SENSORLESS
tmc_sensorless_homing(stepperX, enable);
#elif CORE_IS_YZ && Z_SENSORLESS
tmc_sensorless_homing(stepperZ, enable);
#endif
break;
#endif
#if Z_SENSORLESS
case Z_AXIS:
tmc_sensorless_homing(stepperZ, enable);
#if CORE_IS_XZ && X_SENSORLESS
tmc_sensorless_homing(stepperX, enable);
#elif CORE_IS_YZ && Y_SENSORLESS
tmc_sensorless_homing(stepperY, enable);
#endif
break;
#endif
}
}
#endif // SENSORLESS_HOMING
/**
* Home an individual linear axis
*/
@ -2878,15 +2920,7 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
// Disable stealthChop if used. Enable diag1 pin on driver.
#if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
if (axis == X_AXIS) tmc_sensorless_homing(stepperX);
#endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
if (axis == Y_AXIS) tmc_sensorless_homing(stepperY);
#endif
#if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)
if (axis == Z_AXIS) tmc_sensorless_homing(stepperZ);
#endif
sensorless_homing_per_axis(axis);
#endif
// Tell the planner the axis is at 0
@ -2917,15 +2951,7 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
// Re-enable stealthChop if used. Disable diag1 pin on driver.
#if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
if (axis == X_AXIS) tmc_sensorless_homing(stepperX, false);
#endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
if (axis == Y_AXIS) tmc_sensorless_homing(stepperY, false);
#endif
#if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)
if (axis == Z_AXIS) tmc_sensorless_homing(stepperZ, false);
#endif
sensorless_homing_per_axis(axis, false);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -3619,12 +3645,8 @@ inline void gcode_G4() {
fr_mm_s = min(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
#if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperX);
#endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperY);
#endif
sensorless_homing_per_axis(X_AXIS);
sensorless_homing_per_axis(Y_AXIS);
#endif
do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
@ -3632,12 +3654,8 @@ inline void gcode_G4() {
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
#if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperX, false);
#endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperY, false);
#endif
sensorless_homing_per_axis(X_AXIS, false);
sensorless_homing_per_axis(Y_AXIS, false);
safe_delay(500); // Short delay needed to settle
#endif
}
@ -3803,15 +3821,9 @@ inline void gcode_G4() {
// Disable stealthChop if used. Enable diag1 pin on driver.
#if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperX);
#endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperY);
#endif
#if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperZ);
#endif
sensorless_homing_per_axis(A_AXIS);
sensorless_homing_per_axis(B_AXIS);
sensorless_homing_per_axis(C_AXIS);
#endif
// Move all carriages together linearly until an endstop is hit.
@ -3822,15 +3834,9 @@ inline void gcode_G4() {
// Re-enable stealthChop if used. Disable diag1 pin on driver.
#if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperX, false);
#endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperY, false);
#endif
#if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)
tmc_sensorless_homing(stepperZ, false);
#endif
sensorless_homing_per_axis(A_AXIS, false);
sensorless_homing_per_axis(B_AXIS, false);
sensorless_homing_per_axis(C_AXIS, false);
#endif
// If an endstop was not hit, then damage can occur if homing is continued.

View File

@ -1525,6 +1525,15 @@ static_assert(1 >= 0
#error "SENSORLESS_HOMING on DELTA currently requires STEALTHCHOP."
#endif
// Sensorless homing is required for both combined steppers in an H-bot
#if CORE_IS_XY && X_SENSORLESS != Y_SENSORLESS
#error "CoreXY requires both X and Y to use sensorless homing if either does."
#elif CORE_IS_XZ && X_SENSORLESS != Z_SENSORLESS
#error "CoreXZ requires both X and Z to use sensorless homing if either does."
#elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS
#error "CoreYZ requires both Y and Z to use sensorless homing if either does."
#endif
#elif ENABLED(SENSORLESS_HOMING)
#error "SENSORLESS_HOMING requires TMC2130 stepper drivers."