The principle has been implemented, but the TMC is not providing
the right data for some reason - homing doesn't work at all right now.
Also, after solving the physical homing, unit tests must be updated.
This PR brings the following improvements:
- unifies the error handling of TMC and Homing/Stallguard errors on all motorized modules (Idler, Selector, Pulley)
- now we distinguish between Homing and TMC errors + we have a separate handling of these two kinds into CommandBase unified for all motorized modules
- adds unit tests to verify the function
- fixes SetFINDAStateAndDebounce (didn't obey the press parameter before)
Introduce axisUnitToTruncatedUnit to convert from an AxisUnit (now
conveniently returned from Motion::CurPosition) to a physical unit *but*
directly into a truncated integer type, avoiding conversions to long
double types at runtime.
The related function truncatedUnit perform the same truncation of a
constant unit, so that the result of axisUnitToTruncatedUnit and
truncatedUnit(unit) result in the same type for clarity.
Both functions accept a pre-multiplier, which is applied at compile
time for constant values when optimizations are enabled.
Fixes the motion stutters generally happening as more than a single
axis are active and one completes in the middle of the motion.
Do not generate a spourious interval as one axis exits the queue. This
short interval didn't account for the minimal stepping quantum,
potentially causing a timer overflow.
This solves a number of issues - if FINDA or FSensor failed,
the unload was never "complete" - filament was stuck in the selector
blocking it from normal operation.
Now, after all errors have been resolved, filament is explicitly FED
into FINDA and then RETRACTED to Pulley.
Slower loading speed is necessary for precise detection
of filament sensor trigger and starting rotation of the E-motor.
Experimentally it turned out speeds above 80mm/s tend to cause timing issues
(sometimes one can hear a crack as MMU' or the printer's drive gears
slip while pushing the filament).
Such a timing issue then causes blobs in purge towers.
On the other hand - 80mm/s for the fast part of filament load
seems not only absolutely reliable, but also very quiet.
120mm/s for unload is much louder (we may slow it down later)
Take advantage of __TEXT_REGION_LENGTH__ in the avr5 linker script to
preset the effective available space in the flash.
This ensures we don't overflow into the bootloader.
Solves an interesting tiny issue introduced in the previous commits.
When we start with the filament in selector, the corresponding LED
is set to ON. However, all of the logic state machines only operated
on the LED pair of the active slot -> the starting LED may have been
left ON in some edge cases.
Now, this is resolved by clearing all other LEDs except for the active
slot where appropriate.
Both movable components now perform homing sequences transparently
whenever the logic layer invalidates the homingValid flag.
That reflects the fact, that the user may have moved the Idler or Selector
while trying to resolve a HW issue with un/loading filament.
Basic rules:
- Idler gets rehomed immediately and then moves into the target slot position
- Selector rehomes once it is possible - i.e. when filament load state
is AtPulley - then it immediately and spontanneously executes the homing
sequence and then returns to the desired state
Motivation:
- resolve startup issues (EEPROM says we have filament, but FINDA is not triggered)
- resolve accidental moves of Idler and/or Selector while
digging out stuck filament from the unit
Previously it looked like only the active block has been discarded
which worked most of the time, since we only planned single moves.
But with introduction of PlanLongMove in one of the last commits
this is not true anymore.
we may discuss when to check for the FSensor state and why,
but this approach seemed to me like the least invasive method
of just checking the fsensor state and reporting an error in case
it didn't switch off.
In AVR __builtin_abs() breaks for non-base types.
Provide a generic function and use an overload when it is safe to use
instead.
This fixes the underlying step count calculation in PlanMove, thus
removing the need for the PlanLongMove work-around.