Remove Enable/Disable TMC when reiniting Movable axes

The previous commits by @leptun were correct but there has been one call to Disable axis (and TMC) hidden in `InitMovement`.
Therefore `InitMovement` has been split into 2 separate functions - one is there to allow the original full axis reinit, but the other `InitMovementNoReinitAxis` now only prepares a move without reiniting the TMC driver.

This approach seems to have the benefit of fixing the Idler creep over time.

The disadvantage is the fact, that setting StallGuard threshold is no longer called. We may need to add a special piece of code to handle/apply SGTHRS change at runtime like before.
pull/224/head
D.R.racer 2022-10-19 10:58:46 +02:00 committed by DRracer
parent e2924c3506
commit dc487c36b6
4 changed files with 15 additions and 6 deletions

View File

@ -83,7 +83,7 @@ Idler::OperationResult Idler::Disengage() {
}
// disengaging
return InitMovement();
return InitMovementNoReinitAxis();
}
Idler::OperationResult Idler::PartiallyDisengage(uint8_t slot) {
@ -122,7 +122,7 @@ Idler::OperationResult Idler::PlanMoveInner(uint8_t slot, Operation plannedOp) {
return OperationResult::Accepted;
}
return InitMovement();
return InitMovementNoReinitAxis();
}
bool Idler::Step() {

View File

@ -26,15 +26,19 @@ void MovableBase::PlanHome() {
MovableBase::OperationResult MovableBase::InitMovement() {
mm::motion.PlanStallGuardThreshold(axis, mg::globals.StallGuardThreshold(axis));
if (motion.InitAxis(axis)) {
PrepareMoveToPlannedSlot();
state = Moving;
return OperationResult::Accepted;
return InitMovementNoReinitAxis();
} else {
state = TMCFailed;
return OperationResult::Failed;
}
}
MovableBase::OperationResult MovableBase::InitMovementNoReinitAxis() {
PrepareMoveToPlannedSlot();
state = Moving;
return OperationResult::Accepted;
}
void MovableBase::PerformMove() {
if (mm::motion.QueueEmpty(axis)) {
// move finished

View File

@ -95,8 +95,13 @@ protected:
virtual bool FinishHomingAndPlanMoveToParkPos() = 0;
virtual void FinishMove() = 0;
/// Initializes movement of a movable module.
/// Beware: this operation reinitializes the axis/TMC driver as well (may introduce axis creep as we have seen on the Idler)
OperationResult InitMovement();
/// Initializes movement of a movable module without reinitializing the axis/TMC driver
OperationResult InitMovementNoReinitAxis();
void PerformMove();
void PerformHomeForward();

View File

@ -86,7 +86,7 @@ Selector::OperationResult Selector::MoveToSlot(uint8_t slot) {
}
// do the move
return InitMovement();
return InitMovementNoReinitAxis();
}
bool Selector::Step() {