Check for tmc2130 error flags

pull/216/head
Alex Voinea 2022-10-09 22:13:40 +02:00 committed by DRracer
parent 8b2de34e34
commit 739f4cd2a3
6 changed files with 19 additions and 2 deletions

View File

@ -143,7 +143,7 @@ public:
sg_filter_counter = sg_filter_threshold;
}
/// Should be called periodically from main loop. Maybe not all the time. Once every 10 ms is probably enough
/// Should be called periodically. Maybe not all the time. Once every 10 ms is probably enough
bool CheckForErrors(const MotorParams &params);
inline ErrorFlags GetErrorFlags() const {

View File

@ -142,7 +142,9 @@ bool Idler::Step() {
return true;
case TMCFailed:
dbg_logic_P(PSTR("Idler Failed"));
return true;
default:
IdleChecks();
return true;
}
}

View File

@ -36,7 +36,7 @@ MovableBase::OperationResult MovableBase::InitMovement() {
}
void MovableBase::PerformMove() {
if (!mm::motion.DriverForAxis(axis).GetErrorFlags().Good()) { // @@TODO check occasionally, i.e. not every time?
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
state = TMCFailed;
@ -86,5 +86,14 @@ void MovableBase::HomeFailed() {
state = HomingFailed;
}
void MovableBase::IdleChecks() {
// perform maintenance tasks while no motion is happening
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
state = TMCFailed;
}
}
} // namespace motion
} // namespace modules

View File

@ -103,6 +103,8 @@ protected:
void PerformHomeBack();
void HomeFailed();
void IdleChecks();
};
} // namespace motion

View File

@ -28,7 +28,9 @@ bool Pulley::Step() {
case Ready:
return true;
case TMCFailed:
return true;
default:
IdleChecks();
return true;
}
}

View File

@ -122,7 +122,9 @@ bool Selector::Step() {
return true;
case TMCFailed:
dbg_logic_P(PSTR("Selector Failed"));
return true;
default:
IdleChecks();
return true;
}
}