Avoid homing Idler and Selector at the same time

This PR is an experimental code to delay homing of the Selector after the Idler homes properly.

Unit tests are expected to fail at this moment...
pull/195/head
D.R.racer 2022-07-29 17:54:17 +02:00 committed by DRracer
parent 857b028baf
commit 7002e3b0c7
3 changed files with 15 additions and 3 deletions

View File

@ -15,9 +15,9 @@ void MovableBase::PlanHome() {
mm::motion.StallGuardReset(axis); mm::motion.StallGuardReset(axis);
// plan move at least as long as the axis can go from one side to the other // plan move at least as long as the axis can go from one side to the other
PlanHomingMoveForward(); state = HomeForward; // beware - the derived class may change the state if necessary
state = HomeForward;
currentSlot = -1; // important - other state machines may be waiting for a valid Slot() which is not yet correct while homing in progress currentSlot = -1; // important - other state machines may be waiting for a valid Slot() which is not yet correct while homing in progress
PlanHomingMoveForward();
} }
MovableBase::OperationResult MovableBase::InitMovement() { MovableBase::OperationResult MovableBase::InitMovement() {

View File

@ -14,6 +14,7 @@ public:
enum { enum {
Ready = 0, // intentionally set as zero in order to allow zeroing the Idler structure upon startup -> avoid explicit initialization code Ready = 0, // intentionally set as zero in order to allow zeroing the Idler structure upon startup -> avoid explicit initialization code
Moving, Moving,
PlannedHome,
HomeForward, HomeForward,
HomeBack, HomeBack,
TMCFailed, TMCFailed,

View File

@ -7,6 +7,7 @@
#include "permanent_storage.h" #include "permanent_storage.h"
#include "../debug.h" #include "../debug.h"
#include "globals.h" #include "globals.h"
#include "idler.h" // @@TODO this is not nice - introduces dependency between the idler and selector - presumably electrical reasons :(
namespace modules { namespace modules {
namespace selector { namespace selector {
@ -19,7 +20,7 @@ void Selector::PrepareMoveToPlannedSlot() {
} }
void Selector::PlanHomingMoveForward() { void Selector::PlanHomingMoveForward() {
mm::motion.PlanMove<mm::Selector>(mm::unitToAxisUnit<mm::S_pos_t>(-config::selectorLimits.lenght * 2), mm::unitToAxisUnit<mm::S_speed_t>(config::selectorFeedrate)); state = PlannedHome;
dbg_logic_P(PSTR("Plan Homing Selector Forward")); dbg_logic_P(PSTR("Plan Homing Selector Forward"));
} }
@ -93,6 +94,16 @@ bool Selector::Step() {
PerformMove(); PerformMove();
//dbg_logic_P(PSTR("Moving Selector")); //dbg_logic_P(PSTR("Moving Selector"));
return false; return false;
case PlannedHome:
// A testing workaround for presumed electrical reasons why the Idler and Selector cannot perform reliable homing together.
// Let's wait for the Idler to finish homing before homing the selector.
// This will surely break the unit tests, but that's not the point at this stage.
if (mi::idler.HomingValid()) {
// idler is ok, we can start homing the selector
state = HomeForward;
mm::motion.PlanMove<mm::Selector>(mm::unitToAxisUnit<mm::S_pos_t>(-config::selectorLimits.lenght * 2), mm::unitToAxisUnit<mm::S_speed_t>(config::selectorFeedrate));
}
return false;
case HomeForward: case HomeForward:
dbg_logic_P(PSTR("Homing Selector Forward")); dbg_logic_P(PSTR("Homing Selector Forward"));
PerformHomeForward(); PerformHomeForward();