Commit Graph

714 Commits (7bbee87a0898ec82a8108e3f7f4ce0cb68d5097b)

Author SHA1 Message Date
D.R.racer 8e8a17c34e Fix unit test UnloadFilament 2022-02-17 08:21:15 +01:00
D.R.racer b685ec4aff Fix waiting for homing of Selector after UnloadFilament 2022-02-17 08:21:15 +01:00
D.R.racer c95c6677b1 Add more unit tests for homing + fix the homing
It is a carpet-bombing-commit again, but solving the problem correctly required such an approach.
2022-02-17 08:21:15 +01:00
D.R.racer 684051abe8 Enlarge load distance from fsensor to drive gear
shall prevent printer load fails
2022-02-17 08:21:15 +01:00
D.R.racer bcba966a0e Fix repeated re-homing + add more unit tests for that scenario 2022-02-17 08:21:15 +01:00
D.R.racer f25f88b164 Extract buttonADCMaxValue into config
to be used later
2022-02-17 08:21:15 +01:00
D.R.racer 18891dbeaf Add ClearButtons into unit tests 2022-02-17 08:21:15 +01:00
D.R.racer 7e759fdb51 Rebase onto main: use axisUnitToTruncatedUnit 2022-02-17 08:21:15 +01:00
D.R.racer 7fbd3c9c7e Fix homing error recovery + add homing unit tests 2022-02-17 08:21:15 +01:00
D.R.racer 4d9d310f00 Fix unit tests 2022-02-17 08:21:15 +01:00
D.R.racer d0ae94d655 Remove "moving away from front end" as it homes without it
after tuning of constants by @leptun in the previous commits
2022-02-17 08:21:15 +01:00
Alex Voinea 1b5936a8f6 Fix idler axis length (eyeballed it, we should find the real value) 2022-02-17 08:21:15 +01:00
Alex Voinea 26d2c9f2ca Fix SG_thrs and tcoolthrs parameters 2022-02-17 08:21:15 +01:00
D.R.racer f9addb0d7a WIP: homing on both ends of axes
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.
2022-02-17 08:21:15 +01:00
D.R.racer 0c9d59ba5a Fix processing of Home commands + unit tests 2022-02-17 08:21:15 +01:00
D.R.racer e338eb9f4c Add missing pulley.Step() to main 2022-02-17 08:21:15 +01:00
D.R.racer 6b53db7610 Rebase onto main 2022-02-17 08:21:15 +01:00
D.R.racer a408651e62 CurrentPositionPulley_mm->CurrentPosition_mm and use it in debug prints 2022-02-17 08:21:15 +01:00
D.R.racer ee3c43b12c One more mp->mpu (in a commented piece of code) 2022-02-17 08:21:15 +01:00
D.R.racer c5e5f57100 Rename mp (modules::pulley) namespace to mpu
clashed with the already used `modules::protocol` (mp)
2022-02-17 08:21:15 +01:00
D.R.racer b36e6b99a1 Add Pulley as a Movable module
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)
2022-02-17 08:21:15 +01:00
Yuri D'Elia 53d285280d Avoid runtime conversions of floats in UnloadToFinda
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.
2022-02-01 07:00:53 +01:00
Yuri D'Elia 86d5e87a09 motion: Implement Position/CurPosition returning AxisUnit
These come in handy to avoid manual casts and enforce types at runtime.
2022-02-01 07:00:53 +01:00
Yuri D'Elia e318a9f9c1 tests/motion:: ensure stepTimerQuantum is always respected
This catches motion stutters as fixed in
502f42b7be
2022-01-31 14:38:37 +01:00
Yuri D'Elia 5af7d9a10f motion: correctly reset residuals of a stopping axes
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.
2022-01-31 14:38:37 +01:00
Yuri D'Elia e7003133f5 tests/motion: Do not step in test_motion::ResetMotionSim
Calling stepUntilDone defeats the purpose of the following REQUIRE().
The test should always start from a clean state.
2022-01-31 14:38:37 +01:00
Yuri D'Elia cabf284882 motion: Remove motion.ResetAxesData
Use motion.SetPosition directly to minimize redundant code which is used
for unit tests only.
2022-01-31 14:38:37 +01:00
Yuri D'Elia 2e32204d17 motion: Improve legibility of motion::SetPosition 2022-01-31 14:38:37 +01:00
D.R.racer 5ba8ba9646 Longer unload distance for FSensor OFF check
It's been too tight before causing unload errors unnecessarily.
We can play with this parameter more in the future.
2022-01-19 17:08:35 +01:00
D.R.racer ea8dd7e365 Unload now rechecks the position of filament after recovery
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.
2022-01-19 17:08:35 +01:00
D.R.racer 8a6d962bd4 Separate load/unload speeds + faster
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)
2022-01-19 17:08:35 +01:00
D.R.racer 7cdb63f07a Make Idler::Engage not obey the position of filament
fixes UnloadFilament startup - it wasn't waiting for the Idler to engage
before moving the Pulley
2022-01-19 17:08:35 +01:00
D.R.racer 97b362f2b7 Join feedrates of Load-to-FINDA and Load-to-Nozzle
MMU-105
2022-01-19 17:08:35 +01:00
Yuri D'Elia 1623f315af Ensure code doesn't overflow into the MMU bootloader
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.
2022-01-19 13:56:33 +01:00
Yuri D'Elia b3c53b8a85 Move linker script configuration inside into a single spot
Use a block comment to avoid cmake-format messing up the relevant
newlines
2022-01-19 13:56:33 +01:00
D.R.racer 21390cefe1 Add Homing/Stalled error codes for Pulley, Idler, Selector 2022-01-18 09:43:18 +01:00
Alex Voinea fd6c0bcc23 Symmetrical latch signal 2021-12-01 09:07:08 +01:00
Alex Voinea f509dc8346 Adjust latch pulse length 2021-12-01 09:07:08 +01:00
Alex Voinea d399a024bb SHR16 correct signal timing 2021-12-01 09:07:08 +01:00
D.R.racer 662e05b813 Turn off other LEDs when appropriate
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.
2021-11-25 13:04:22 +01:00
D.R.racer f2f82c620a Set green LED at start when filament loaded + set Idler as idle at start 2021-11-25 13:04:22 +01:00
D.R.racer e064a6c2f5 Introduce H0 command to invoke Idler+Selector homing seq. if safe 2021-11-25 13:04:22 +01:00
D.R.racer 9bf2b401e4 Avoid homing the idler at start when printing 2021-11-25 13:04:22 +01:00
D.R.racer 6973dbff13 Introduce intelligent homing if Idler and Selector
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
2021-11-25 13:04:22 +01:00
D.R.racer 7d423df583 Swap buttons left<->right 2021-11-23 12:55:39 +01:00
D.R.racer 6f982e2505 Cleanup compiler warnings 2021-11-17 08:48:59 +01:00
D.R.racer 151adf810a Add ToolChange Error resolve Button2 unit tests 2021-11-17 08:48:59 +01:00
D.R.racer 515119edc8 Test ToolChange error recovery by button 0 and 1 2021-11-17 08:48:59 +01:00
D.R.racer 7fe9d7f329 Finish UnloadFilament unit test - error state resolved by user + checks 2021-11-17 08:48:59 +01:00
D.R.racer afab309d27 Extract common Dis/Engaging of idler in Error states into base class 2021-11-17 08:48:59 +01:00