Always check for tmc errors

pull/216/head
Alex Voinea 2022-10-10 12:14:11 +02:00 committed by DRracer
parent ecb1696a12
commit 55e8caa054
5 changed files with 15 additions and 15 deletions

View File

@ -121,6 +121,10 @@ Idler::OperationResult Idler::PlanMoveInner(uint8_t slot, Operation plannedOp) {
}
bool Idler::Step() {
if (state != TMCFailed) {
CheckTMC();
}
switch (state) {
case Moving:
// dbg_logic_P(PSTR("Moving Idler"));
@ -142,9 +146,7 @@ bool Idler::Step() {
return true;
case TMCFailed:
dbg_logic_P(PSTR("Idler Failed"));
return true;
default:
IdleChecks();
return true;
}
}

View File

@ -36,12 +36,7 @@ MovableBase::OperationResult MovableBase::InitMovement() {
}
void MovableBase::PerformMove() {
if (mm::motion.DriverForAxis(axis).CheckForErrors(axisParams[axis].params)) {
// TMC2130 entered some error state, the planned move couldn't have been finished - result of operation is Failed
tmcErrorFlags = mm::motion.DriverForAxis(axis).GetErrorFlags(); // save the failed state
mm::motion.AbortPlannedMoves(axis, true);
state = TMCFailed;
} else if (mm::motion.QueueEmpty(axis)) {
if (mm::motion.QueueEmpty(axis)) {
// move finished
currentSlot = plannedSlot;
FinishMove();
@ -87,8 +82,7 @@ void MovableBase::HomeFailed() {
state = HomingFailed;
}
void MovableBase::IdleChecks() {
// perform maintenance tasks while no motion is happening
void MovableBase::CheckTMC() {
if (mm::motion.DriverForAxis(axis).CheckForErrors(axisParams[axis].params)) {
// TMC2130 entered some error state, the planned move couldn't have been finished - result of operation is Failed
tmcErrorFlags = mm::motion.DriverForAxis(axis).GetErrorFlags(); // save the failed state

View File

@ -104,7 +104,7 @@ protected:
void HomeFailed();
void IdleChecks();
void CheckTMC();
};
} // namespace motion

View File

@ -17,6 +17,10 @@ bool Pulley::FinishHomingAndPlanMoveToParkPos() {
}
bool Pulley::Step() {
if (state != TMCFailed) {
CheckTMC();
}
switch (state) {
case Moving:
PerformMove();
@ -28,9 +32,7 @@ bool Pulley::Step() {
case Ready:
return true;
case TMCFailed:
return true;
default:
IdleChecks();
return true;
}
}

View File

@ -90,6 +90,10 @@ Selector::OperationResult Selector::MoveToSlot(uint8_t slot) {
}
bool Selector::Step() {
if (state != TMCFailed) {
CheckTMC();
}
switch (state) {
case Moving:
PerformMove();
@ -122,9 +126,7 @@ bool Selector::Step() {
return true;
case TMCFailed:
dbg_logic_P(PSTR("Selector Failed"));
return true;
default:
IdleChecks();
return true;
}
}