Check for tmc2130 error flags

pull/212/head
Alex Voinea 2022-10-09 22:13:40 +02:00
parent a61c741a66
commit 5d33c38ba8
6 changed files with 19 additions and 2 deletions

View File

@ -143,7 +143,7 @@ public:
sg_filter_counter = sg_filter_threshold; 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); bool CheckForErrors(const MotorParams &params);
inline ErrorFlags GetErrorFlags() const { inline ErrorFlags GetErrorFlags() const {

View File

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

View File

@ -36,7 +36,7 @@ MovableBase::OperationResult MovableBase::InitMovement() {
} }
void MovableBase::PerformMove() { 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 // 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 tmcErrorFlags = mm::motion.DriverForAxis(axis).GetErrorFlags(); // save the failed state
state = TMCFailed; state = TMCFailed;
@ -86,5 +86,14 @@ void MovableBase::HomeFailed() {
state = HomingFailed; 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 motion
} // namespace modules } // namespace modules

View File

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

View File

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

View File

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