Workaround planning moves longer than 32K steps
parent
7f9fc78cf6
commit
5f1e3e018e
|
|
@ -9,10 +9,10 @@
|
||||||
/// Enable DEBUG_LOGIC to compile debugging and error messages (beware of code base size ;) ) for the logic layer
|
/// Enable DEBUG_LOGIC to compile debugging and error messages (beware of code base size ;) ) for the logic layer
|
||||||
//#define DEBUG_LOGIC
|
//#define DEBUG_LOGIC
|
||||||
|
|
||||||
/// Enable DEBUG_LOGIC to compile debugging and error messages (beware of code base size ;) ) for the logic layer
|
/// Enable DEBUG_MODULES to compile debugging and error messages (beware of code base size ;) ) for the modules layer
|
||||||
//#define DEBUG_MODULES
|
//#define DEBUG_MODULES
|
||||||
|
|
||||||
/// Enable DEBUG_HAL to compile debugging and error messages (beware of code base size ;) ) for the logic layer
|
/// Enable DEBUG_HAL to compile debugging and error messages (beware of code base size ;) ) for the HAL layer
|
||||||
//#define DEBUG_HAL
|
//#define DEBUG_HAL
|
||||||
|
|
||||||
/// Wrangler for assorted compile-time configuration and constants.
|
/// Wrangler for assorted compile-time configuration and constants.
|
||||||
|
|
@ -53,7 +53,8 @@ static constexpr uint16_t maxStepFrequency = 40000;
|
||||||
static constexpr uint16_t minStepRate = 120;
|
static constexpr uint16_t minStepRate = 120;
|
||||||
|
|
||||||
/// Size for the motion planner block buffer size
|
/// Size for the motion planner block buffer size
|
||||||
static constexpr uint8_t blockBufferSize = 2;
|
/// Beware of too low setting (esp. because of Motion::PlanLongMove)
|
||||||
|
static constexpr uint8_t blockBufferSize = 4;
|
||||||
|
|
||||||
/// Step timer frequency divider (F = F_CPU / divider)
|
/// Step timer frequency divider (F = F_CPU / divider)
|
||||||
static constexpr uint8_t stepTimerFrequencyDivider = 8;
|
static constexpr uint8_t stepTimerFrequencyDivider = 8;
|
||||||
|
|
@ -83,7 +84,7 @@ static constexpr U_mm couplerToBowden = 3.5_mm; /// 3.5_mm /// FINDA Coupler scr
|
||||||
// just another piece of PLA (probably having more resistance in the tubes)
|
// just another piece of PLA (probably having more resistance in the tubes)
|
||||||
// and we are at least 40mm off! It looks like this really depends on the exact position
|
// and we are at least 40mm off! It looks like this really depends on the exact position
|
||||||
// We'll probably need to check for stallguard while pushing the filament to avoid ginding the filament
|
// We'll probably need to check for stallguard while pushing the filament to avoid ginding the filament
|
||||||
static constexpr U_mm defaultBowdenLength = 467.0_mm; /// ~427.0_mm /// Default Bowden length. @TODO Should be stored in EEPROM.
|
static constexpr U_mm defaultBowdenLength = 427.0_mm; /// ~427.0_mm /// Default Bowden length. @TODO Should be stored in EEPROM. 392 a 784
|
||||||
static constexpr U_mm minimumBowdenLength = 341.0_mm; /// ~341.0_mm /// Minimum bowden length. @TODO Should be stored in EEPROM.
|
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 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 feedToFinda = cuttingEdgeToFindaMidpoint + filamentMinLoadedToMMU;
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ bool FeedToBondtech::Step() {
|
||||||
dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley));
|
dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley));
|
||||||
state = PushingFilamentToFSensor;
|
state = PushingFilamentToFSensor;
|
||||||
mm::motion.InitAxis(mm::Pulley);
|
mm::motion.InitAxis(mm::Pulley);
|
||||||
mm::motion.PlanMove<mm::Pulley>(config::defaultBowdenLength, config::pulleyFeedrate); //@@TODO constants - there was some strange acceleration sequence in the original FW,
|
mm::motion.PlanLongMove<mm::Pulley>(config::defaultBowdenLength, config::pulleyFeedrate, config::pulleySlowFeedrate);
|
||||||
// we can probably hand over some array of constants for hand-tuned acceleration + leverage some smoothing in the stepper as well
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case PushingFilamentToFSensor:
|
case PushingFilamentToFSensor:
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,27 @@ public:
|
||||||
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(end_rate));
|
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(end_rate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This function exists solely because of some mysterious overflow bug in planning/stepping
|
||||||
|
/// which occurrs when number of steps exceeds 32K. The bug doesn't even exhibit in unit tests :( .
|
||||||
|
/// Therefore it plans multiple segments in case the desired distance is longer than 32K steps.
|
||||||
|
/// So far this is only used for moving the Pulley...
|
||||||
|
template <Axis A, config::UnitBase B>
|
||||||
|
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 }) {
|
||||||
|
auto steps = unitToAxisUnit<AxisUnit<pos_t, A, Lenght>>(delta);
|
||||||
|
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
|
||||||
|
steps,
|
||||||
|
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(feed_rate),
|
||||||
|
unitToAxisUnit<AxisUnit<steps_t, A, Speed>>(end_rate));
|
||||||
|
}
|
||||||
|
|
||||||
/// @returns head position of an axis (last enqueued position)
|
/// @returns head position of an axis (last enqueued position)
|
||||||
/// @param axis axis affected
|
/// @param axis axis affected
|
||||||
pos_t Position(Axis axis) const;
|
pos_t Position(Axis axis) const;
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,11 @@ void FeedingToBondtech(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
REQUIRE(WhileCondition(
|
REQUIRE(WhileCondition(
|
||||||
tc,
|
tc,
|
||||||
[&](int step) -> bool {
|
[&](int step) -> bool {
|
||||||
if(step == 5000){ // on 5000th step make filament sensor trigger
|
if(step == 2000){ // on 5000th step make filament sensor trigger
|
||||||
mfs::fsensor.ProcessMessage(true);
|
mfs::fsensor.ProcessMessage(true);
|
||||||
}
|
}
|
||||||
return tc.TopLevelState() == ProgressCode::FeedingToBondtech; },
|
return tc.TopLevelState() == ProgressCode::FeedingToBondtech; },
|
||||||
200000UL));
|
20000UL));
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue