parent
1623f315af
commit
97b362f2b7
|
|
@ -87,6 +87,7 @@ static constexpr U_mm defaultBowdenLength = 427.0_mm; /// ~427.0_mm /// Default
|
|||
static constexpr U_mm minimumBowdenLength = 341.0_mm; /// ~341.0_mm /// Minimum bowden length. @TODO Should be stored in EEPROM.
|
||||
static constexpr U_mm maximumBowdenLength = 792.0_mm; /// ~792.0_mm /// Maximum bowden length. @TODO Should be stored in EEPROM.
|
||||
static constexpr U_mm feedToFinda = cuttingEdgeToFindaMidpoint + filamentMinLoadedToMMU;
|
||||
static constexpr U_mm maximumFeedToFinda = feedToFinda + 20.0_mm; ///< allow for some safety margin to load to FINDA
|
||||
static constexpr U_mm pulleyHelperMove = 10.0_mm; /// Helper move for Load/Unload error states - when the MMU should slowly move the filament a bit
|
||||
static constexpr U_mm cutLength = 8.0_mm;
|
||||
static constexpr U_mm fsensorToNozzle = 20.0_mm; /// ~20mm from MK4's filament sensor through extruder gears into nozzle
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ bool CutFilament::StepInner() {
|
|||
case ProgressCode::SelectingFilamentSlot:
|
||||
if (mi::idler.Engaged() && ms::selector.Slot() == cutSlot) { // idler and selector finished their moves
|
||||
mg::globals.SetFilamentLoaded(cutSlot, mg::FilamentLoadState::AtPulley);
|
||||
feed.Reset(true);
|
||||
feed.Reset(true, true);
|
||||
state = ProgressCode::FeedingToFinda;
|
||||
}
|
||||
break;
|
||||
|
|
@ -94,7 +94,7 @@ bool CutFilament::StepInner() {
|
|||
state = ProgressCode::OK;
|
||||
error = ErrorCode::OK;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::on, ml::off);
|
||||
feed.Reset(true);
|
||||
feed.Reset(true, true);
|
||||
}
|
||||
break;
|
||||
case ProgressCode::OK:
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@
|
|||
#include "../debug.h"
|
||||
namespace logic {
|
||||
|
||||
void FeedToFinda::Reset(bool feedPhaseLimited) {
|
||||
void FeedToFinda::Reset(bool feedPhaseLimited, bool haltAtEnd) {
|
||||
dbg_logic_P(PSTR("\nFeed to FINDA\n\n"));
|
||||
state = EngagingIdler;
|
||||
this->feedPhaseLimited = feedPhaseLimited;
|
||||
this->haltAtEnd = haltAtEnd;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||
// We can't get any FINDA readings if the selector is at the wrong spot - move it accordingly if necessary
|
||||
|
|
@ -33,19 +34,20 @@ bool FeedToFinda::Step() {
|
|||
// if (mg::globals.FilamentLoaded() == mg::FilamentLoadState::NotLoaded) { // feed slowly filament to PTFE
|
||||
// mm::motion.PlanMove<mm::Pulley>(config::filamentMinLoadedToMMU, config::pulleySlowFeedrate);
|
||||
// }
|
||||
mm::motion.PlanMove<mm::Pulley>(config::feedToFinda, config::pulleyFeedrate);
|
||||
mm::motion.PlanMove<mm::Pulley>(config::maximumFeedToFinda, config::pulleySlowFeedrate);
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector);
|
||||
mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input
|
||||
}
|
||||
return false;
|
||||
case PushingFilament: {
|
||||
if (mf::finda.Pressed() || (feedPhaseLimited && mui::userInput.AnyEvent())) { // @@TODO probably also a command from the printer
|
||||
mm::motion.AbortPlannedMoves(); // stop pushing filament
|
||||
if (mf::finda.Pressed() || (feedPhaseLimited && mui::userInput.AnyEvent())) {
|
||||
mm::motion.AbortPlannedMoves(haltAtEnd); // stop pushing filament
|
||||
// FINDA triggered - that means it works and detected the filament tip
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector);
|
||||
dbg_logic_P(PSTR("Feed to Finda --> Idler disengaged"));
|
||||
dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley));
|
||||
state = OK;
|
||||
return true; // return immediately to allow for a seamless planning of another move (like feeding to bondtech)
|
||||
} else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on
|
||||
state = Failed;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::off, ml::blink0);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ struct FeedToFinda {
|
|||
/// * true feed phase is limited, doesn't react on button press
|
||||
/// * false feed phase is unlimited, can be interrupted by any button press after blanking time
|
||||
/// Beware: the function returns immediately without actually doing anything if the FINDA is "pressed", i.e. the filament is already at the FINDA
|
||||
void Reset(bool feedPhaseLimited);
|
||||
/// @param haltAtEnd true if the Pulley's motion shall be brought into a halt (which is what LoadFilament wants, but not ToolChange)
|
||||
void Reset(bool feedPhaseLimited, bool haltAtEnd);
|
||||
|
||||
/// @returns true if the state machine finished its job, false otherwise
|
||||
bool Step();
|
||||
|
|
@ -43,6 +44,7 @@ struct FeedToFinda {
|
|||
private:
|
||||
uint8_t state;
|
||||
bool feedPhaseLimited;
|
||||
bool haltAtEnd;
|
||||
};
|
||||
|
||||
} // namespace logic
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ void LoadFilament::Reset(uint8_t param) {
|
|||
void logic::LoadFilament::Reset2() {
|
||||
state = ProgressCode::FeedingToFinda;
|
||||
error = ErrorCode::RUNNING;
|
||||
feed.Reset(true);
|
||||
feed.Reset(true, true);
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void ToolChange::Reset(uint8_t param) {
|
|||
error = ErrorCode::RUNNING;
|
||||
dbg_logic_P(PSTR("Filament is not loaded --> load"));
|
||||
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector);
|
||||
feed.Reset(true);
|
||||
feed.Reset(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ bool ToolChange::StepInner() {
|
|||
state = ProgressCode::FeedingToFinda;
|
||||
error = ErrorCode::RUNNING;
|
||||
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::AtPulley);
|
||||
feed.Reset(true);
|
||||
feed.Reset(true, false);
|
||||
}
|
||||
break;
|
||||
case ProgressCode::FeedingToFinda:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
|||
main_loop();
|
||||
|
||||
// restart the automaton
|
||||
ff.Reset(false);
|
||||
ff.Reset(false, true);
|
||||
|
||||
REQUIRE(ff.State() == FeedToFinda::EngagingIdler);
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") {
|
|||
main_loop();
|
||||
|
||||
// restart the automaton - we want the limited version of the feed
|
||||
ff.Reset(true);
|
||||
ff.Reset(true, true);
|
||||
|
||||
REQUIRE(ff.State() == FeedToFinda::EngagingIdler);
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") {
|
|||
REQUIRE(WhileCondition(
|
||||
ff,
|
||||
[&](uint32_t) { return ff.State() == FeedToFinda::PushingFilament; },
|
||||
5000));
|
||||
10000));
|
||||
|
||||
// the FINDA didn't trigger, we should be in the Failed state
|
||||
REQUIRE(ff.State() == FeedToFinda::Failed);
|
||||
|
|
|
|||
Loading…
Reference in New Issue