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 checkingpull/112/head
parent
ffe5bc2807
commit
712b67beb4
|
|
@ -45,6 +45,7 @@ struct __attribute__((packed)) ErrorFlags {
|
||||||
, s2g(0)
|
, s2g(0)
|
||||||
, otpw(0)
|
, otpw(0)
|
||||||
, ot(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
|
/// TMC2130 interface - instances of this class are hidden in modules::motion::Motion::AxisData
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,7 @@ bool Idler::Home() {
|
||||||
bool Idler::Step() {
|
bool Idler::Step() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Moving:
|
case Moving:
|
||||||
if (mm::motion.QueueEmpty(mm::Idler)) {
|
PerformMove(mm::Idler);
|
||||||
// move finished
|
|
||||||
state = Ready;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case Ready:
|
case Ready:
|
||||||
currentlyEngaged = plannedEngage;
|
currentlyEngaged = plannedEngage;
|
||||||
|
|
|
||||||
|
|
@ -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 motion
|
||||||
} // namespace modules
|
} // namespace modules
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ protected:
|
||||||
virtual void PrepareMoveToPlannedSlot() = 0;
|
virtual void PrepareMoveToPlannedSlot() = 0;
|
||||||
|
|
||||||
OperationResult InitMovement(config::Axis axis);
|
OperationResult InitMovement(config::Axis axis);
|
||||||
|
|
||||||
|
void PerformMove(config::Axis axis);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace motion
|
} // namespace motion
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,7 @@ bool Selector::Home() {
|
||||||
bool Selector::Step() {
|
bool Selector::Step() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Moving:
|
case Moving:
|
||||||
if (mm::motion.QueueEmpty(mm::Selector)) {
|
PerformMove(mm::Selector);
|
||||||
// move finished
|
|
||||||
state = Ready;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case Ready:
|
case Ready:
|
||||||
currentSlot = plannedSlot;
|
currentSlot = plannedSlot;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue