Fix chopping negative move values in PlanLongMove

+ use PlanLongMove in UnloadToFinda
+ fix comment in unit test
pull/135/head
D.R.racer 2021-11-03 07:40:04 +01:00 committed by DRracer
parent c3aec0bf92
commit fa4e687fdc
3 changed files with 18 additions and 8 deletions

View File

@ -36,7 +36,7 @@ bool UnloadToFinda::Step() {
if (mi::idler.Engaged()) { if (mi::idler.Engaged()) {
state = WaitingForFINDA; state = WaitingForFINDA;
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector); mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector);
mm::motion.PlanMove<mm::Pulley>(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU, config::pulleyFeedrate); // @@TODO constants mm::motion.PlanLongMove<mm::Pulley>(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU, config::pulleyFeedrate);
} }
return false; return false;
case WaitingForFINDA: case WaitingForFINDA:

View File

@ -170,12 +170,22 @@ public:
constexpr void PlanLongMove(config::Unit<long double, B, Lenght> delta, constexpr void PlanLongMove(config::Unit<long double, B, Lenght> delta,
config::Unit<long double, B, Speed> feed_rate, config::Unit<long double, B, Speed> end_rate = { 0 }) { config::Unit<long double, B, Speed> feed_rate, config::Unit<long double, B, Speed> end_rate = { 0 }) {
auto steps = unitToAxisUnit<AxisUnit<pos_t, A, Lenght>>(delta); auto steps = unitToAxisUnit<AxisUnit<pos_t, A, Lenght>>(delta);
while (steps.v > 32767) { if (steps.v < 0) {
PlanMove<A>( while (steps.v > 32767) {
{ 32767 }, PlanMove<A>(
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate), { 32767 },
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate)); // keep the end feedrate the same to continue with the next segment unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate),
steps.v -= 32767; unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate)); // keep the end feedrate the same to continue with the next segment
steps.v -= 32767;
}
} else {
while (steps.v < -32767) {
PlanMove<A>(
{ -32767 },
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate),
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate)); // keep the end feedrate the same to continue with the next segment
steps.v += 32767;
}
} }
PlanMove<A>( // last segment PlanMove<A>( // last segment
steps, steps,

View File

@ -39,7 +39,7 @@ void FeedingToBondtech(logic::ToolChange &tc, uint8_t toSlot) {
REQUIRE(WhileCondition( REQUIRE(WhileCondition(
tc, tc,
[&](int step) -> bool { [&](int step) -> bool {
if(step == 2000){ // on 5000th step make filament sensor trigger if(step == 2000){ // on 2000th step make filament sensor trigger
mfs::fsensor.ProcessMessage(true); mfs::fsensor.ProcessMessage(true);
} }
return tc.TopLevelState() == ProgressCode::FeedingToBondtech; }, return tc.TopLevelState() == ProgressCode::FeedingToBondtech; },