TMC SPI Endstops and Improved Sensorless Homing (#14044)

This commit is contained in:
teemuatlut
2019-08-05 06:22:58 +03:00
committed by Scott Lahteine
parent d493cafc4a
commit d4974ea719
9 changed files with 251 additions and 29 deletions

View File

@ -78,15 +78,19 @@
fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
#if ENABLED(SENSORLESS_HOMING)
sensorless_t stealth_states { false };
stealth_states.x = tmc_enable_stallguard(stepperX);
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
sensorless_t stealth_states {
tmc_enable_stallguard(stepperX)
, tmc_enable_stallguard(stepperY)
, false
, false
#if AXIS_HAS_STALLGUARD(X2)
|| tmc_enable_stallguard(stepperX2)
#endif
, false
#if AXIS_HAS_STALLGUARD(Y2)
|| tmc_enable_stallguard(stepperY2)
#endif
};
#endif
do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
@ -229,6 +233,22 @@ void GcodeSuite::G28(const bool always_home_all) {
workspace_plane = PLANE_XY;
#endif
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
slow_homing_t slow_homing { 0 };
slow_homing.acceleration.x = planner.settings.max_acceleration_mm_per_s2[X_AXIS];
slow_homing.acceleration.y = planner.settings.max_acceleration_mm_per_s2[Y_AXIS];
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
#if HAS_CLASSIC_JERK
slow_homing.jerk.x = planner.max_jerk[X_AXIS];
slow_homing.jerk.y = planner.max_jerk[Y_AXIS];
planner.max_jerk[X_AXIS] = 0;
planner.max_jerk[Y_AXIS] = 0;
#endif
planner.reset_acceleration_rates();
#endif
// Always home with tool 0 active
#if HOTENDS > 1
#if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
@ -393,6 +413,11 @@ void GcodeSuite::G28(const bool always_home_all) {
endstops.not_homing();
// Clear endstop state for polled stallGuard endstops
#if ENABLED(SPI_ENDSTOPS)
endstops.clear_endstop_state();
#endif
#if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
// move to a height where we can use the full xy-area
do_blocking_move_to_z(delta_clip_start_height);
@ -414,6 +439,17 @@ void GcodeSuite::G28(const bool always_home_all) {
tool_change(old_tool_index, NO_FETCH);
#endif
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
#if HAS_CLASSIC_JERK
planner.max_jerk[X_AXIS] = slow_homing.jerk.x;
planner.max_jerk[Y_AXIS] = slow_homing.jerk.y;
#endif
planner.reset_acceleration_rates();
#endif
ui.refresh();
report_current_position();