Trinamic: Split stealthChop, improve driver monitoring, etc. (#12582)
This commit is contained in:
committed by
Scott Lahteine
parent
055cb2b956
commit
50b2fbd031
@ -1046,40 +1046,78 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
|
||||
}
|
||||
|
||||
#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*/) {
|
||||
sensorless_t start_sensorless_homing_per_axis(const AxisEnum axis) {
|
||||
sensorless_t stealth_states { false, false, false };
|
||||
|
||||
switch (axis) {
|
||||
default: break;
|
||||
#if X_SENSORLESS
|
||||
case X_AXIS:
|
||||
tmc_stallguard(stepperX, enable);
|
||||
stealth_states.x = tmc_enable_stallguard(stepperX);
|
||||
#if CORE_IS_XY && Y_SENSORLESS
|
||||
tmc_stallguard(stepperY, enable);
|
||||
stealth_states.y = tmc_enable_stallguard(stepperY);
|
||||
#elif CORE_IS_XZ && Z_SENSORLESS
|
||||
tmc_stallguard(stepperZ, enable);
|
||||
stealth_states.z = tmc_enable_stallguard(stepperZ);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#if Y_SENSORLESS
|
||||
case Y_AXIS:
|
||||
tmc_stallguard(stepperY, enable);
|
||||
stealth_states.y = tmc_enable_stallguard(stepperY);
|
||||
#if CORE_IS_XY && X_SENSORLESS
|
||||
tmc_stallguard(stepperX, enable);
|
||||
stealth_states.x = tmc_enable_stallguard(stepperX);
|
||||
#elif CORE_IS_YZ && Z_SENSORLESS
|
||||
tmc_stallguard(stepperZ, enable);
|
||||
stealth_states.z = tmc_enable_stallguard(stepperZ);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#if Z_SENSORLESS
|
||||
case Z_AXIS:
|
||||
tmc_stallguard(stepperZ, enable);
|
||||
stealth_states.z = tmc_enable_stallguard(stepperZ);
|
||||
#if CORE_IS_XZ && X_SENSORLESS
|
||||
tmc_stallguard(stepperX, enable);
|
||||
stealth_states.x = tmc_enable_stallguard(stepperX);
|
||||
#elif CORE_IS_YZ && Y_SENSORLESS
|
||||
tmc_stallguard(stepperY, enable);
|
||||
stealth_states.y = tmc_enable_stallguard(stepperY);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return stealth_states;
|
||||
}
|
||||
|
||||
void end_sensorless_homing_per_axis(const AxisEnum axis, sensorless_t enable_stealth) {
|
||||
switch (axis) {
|
||||
default: break;
|
||||
#if X_SENSORLESS
|
||||
case X_AXIS:
|
||||
tmc_disable_stallguard(stepperX, enable_stealth.x);
|
||||
#if CORE_IS_XY && Y_SENSORLESS
|
||||
tmc_disable_stallguard(stepperY, enable_stealth.y);
|
||||
#elif CORE_IS_XZ && Z_SENSORLESS
|
||||
tmc_disable_stallguard(stepperZ, enable_stealth.z);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#if Y_SENSORLESS
|
||||
case Y_AXIS:
|
||||
tmc_disable_stallguard(stepperY, enable_stealth.y);
|
||||
#if CORE_IS_XY && X_SENSORLESS
|
||||
tmc_disable_stallguard(stepperX, enable_stealth.x);
|
||||
#elif CORE_IS_YZ && Z_SENSORLESS
|
||||
tmc_disable_stallguard(stepperZ, enable_stealth.z);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#if Z_SENSORLESS
|
||||
case Z_AXIS:
|
||||
tmc_disable_stallguard(stepperZ, enable_stealth.z);
|
||||
#if CORE_IS_XZ && X_SENSORLESS
|
||||
tmc_disable_stallguard(stepperX, enable_stealth.x);
|
||||
#elif CORE_IS_YZ && Y_SENSORLESS
|
||||
tmc_disable_stallguard(stepperY, enable_stealth.y);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
@ -1126,6 +1164,10 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
|
||||
home_dir(axis);
|
||||
const bool is_home_dir = (axis_home_dir > 0) == (distance > 0);
|
||||
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
sensorless_t stealth_states;
|
||||
#endif
|
||||
|
||||
if (is_home_dir) {
|
||||
|
||||
#if HOMING_Z_WITH_PROBE && QUIET_PROBING
|
||||
@ -1134,7 +1176,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
|
||||
|
||||
// Disable stealthChop if used. Enable diag1 pin on driver.
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
sensorless_homing_per_axis(axis);
|
||||
stealth_states = start_sensorless_homing_per_axis(axis);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1175,7 +1217,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
|
||||
|
||||
// Re-enable stealthChop if used. Disable diag1 pin on driver.
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
sensorless_homing_per_axis(axis, false);
|
||||
end_sensorless_homing_per_axis(axis, stealth_states);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user