Add checking of TMC2130 error states for Idler and Selector

we shall think about the Pulley as well, it looks like it should get its
own class just like Idler and Selector as it behaves very similarly in terms
of stepping and error checking
pull/112/head
D.R.racer 2021-08-27 09:29:10 +02:00 committed by DRracer
parent ffe5bc2807
commit 712b67beb4
5 changed files with 15 additions and 8 deletions

View File

@ -45,6 +45,7 @@ struct __attribute__((packed)) ErrorFlags {
, s2g(0)
, otpw(0)
, ot(0) {}
inline bool Good() const { return reset_flag == 0 && uv_cp == 0 && s2g == 0 && otpw == 0 && ot == 0; }
};
/// TMC2130 interface - instances of this class are hidden in modules::motion::Motion::AxisData

View File

@ -51,10 +51,7 @@ bool Idler::Home() {
bool Idler::Step() {
switch (state) {
case Moving:
if (mm::motion.QueueEmpty(mm::Idler)) {
// move finished
state = Ready;
}
PerformMove(mm::Idler);
return false;
case Ready:
currentlyEngaged = plannedEngage;

View File

@ -15,5 +15,15 @@ MovableBase::OperationResult MovableBase::InitMovement(config::Axis axis) {
}
}
void MovableBase::PerformMove(config::Axis axis) {
if (!mm::motion.DriverForAxis(axis).GetErrorFlags().Good()) {
// TMC2130 entered some error state, the planned move couldn't have been finished - result of operation is Failed
state = Failed;
} else if (mm::motion.QueueEmpty(axis)) {
// move finished
state = Ready;
}
}
} // namespace motion
} // namespace modules

View File

@ -50,6 +50,8 @@ protected:
virtual void PrepareMoveToPlannedSlot() = 0;
OperationResult InitMovement(config::Axis axis);
void PerformMove(config::Axis axis);
};
} // namespace motion

View File

@ -36,10 +36,7 @@ bool Selector::Home() {
bool Selector::Step() {
switch (state) {
case Moving:
if (mm::motion.QueueEmpty(mm::Selector)) {
// move finished
state = Ready;
}
PerformMove(mm::Selector);
return false;
case Ready:
currentSlot = plannedSlot;