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)
|
||||
, 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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ protected:
|
|||
virtual void PrepareMoveToPlannedSlot() = 0;
|
||||
|
||||
OperationResult InitMovement(config::Axis axis);
|
||||
|
||||
void PerformMove(config::Axis axis);
|
||||
};
|
||||
|
||||
} // namespace motion
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue