Commit Graph

785 Commits (c200b0286ead75a8cb6b7469c5bc3c06c0c6ffbd)

Author SHA1 Message Date
Yuri D'Elia 1a2034f545 motion: Allow to get the motion controller for any axis 2022-05-11 08:48:53 +02:00
Yuri D'Elia db494722aa motion: Remove the TODO (tests are now complete) 2022-05-11 08:48:53 +02:00
Yuri D'Elia afead891d1 motion: Fix motion::triple_move step count limit
Do not assume any step can be merged while moving three axes at the same
time.

Use the worst case scenario involving indepedent parameters for each
axis.
2022-05-11 08:46:26 +02:00
D.R.racer f428075a4d Make LoadFilament retract even when stopped with a button
+ fix unrelated unit test of unload to finda which got broken in PR#160
2022-05-11 08:20:41 +02:00
D.R.racer 9c1204dad9 Rename idle_mode to application 2022-05-10 20:03:16 +02:00
D.R.racer 047c76870c Move idle_mode out from logic subdir 2022-05-10 20:03:16 +02:00
D.R.racer c3739eaaef Make unlimited LoadFilament as default 2022-05-10 20:03:16 +02:00
Yuri D'Elia 6b4ba322bb Fix usage of CurrentPositionPulley_mm in debug macros
Rename to the correct Pulley::CurrentPosition_mm
2022-05-10 20:03:16 +02:00
D.R.racer ff1a89d369 Detect successful end of logic::command + start idle countdown
This commit looks horribly complex, but the main idea is to have each of the logic::commands
report their terminal OK state in the same way. That allow for leveraging this very moment
to initiate the idle timeout.

Additionally, I wanted to hide the logic of idle mode detection, which resulted in moving the
top level logic from main.cpp into logic/idle_mode.cpp and a set of additional files to compile
in unit tests.
2022-05-10 20:03:16 +02:00
D.R.racer 1f061405f6 Fix MoveSelector operation build 2022-05-10 20:03:16 +02:00
D.R.racer bd95807b23 Make LoadFilament terminate completely OK when button pressed 2022-05-10 20:03:16 +02:00
D.R.racer 8ce029a28c Fix unit tests
- circular buffer can return its count of elements (even though a better solution may be implemeted later)
- stub_motion can handle multiple planned moves
- improved load/unload filament tests
2022-05-10 20:03:16 +02:00
D.R.racer 1d8c1e8f3f Introduce manual operation of MMU
This PR brings the option to move the selector directly using
buttons of the MMU - obviously while the MMU is idle and no
filament is stuck in the selector.

Left/Right buttons move the selector Left/Right.

Middle button performs a LoadFilament (into the MMU) on the active slot.

With this PR a change of LoadFilament behavior is also introduced.
Now, LoadFilament spins the Pulley for infinite time while waiting
for either FINDA trigger and/or a button pressed.
2022-05-10 20:03:16 +02:00
D.R.racer 13c12aac7f Repeated unload
Set default nr. of repeated unloads to 1
+ introduce a unit test for repeated unloads
2022-05-10 19:58:09 +02:00
Yuri D'Elia 6fdc1638fa Include <array> to build test_protocol on gcc 12 2022-05-10 18:03:40 +02:00
Alex Voinea c058949cbe Make idler less sensitive SGT=5 -> SGT=7 2022-05-09 12:23:22 +02:00
Yuri D'Elia fbb5843158 Guard critical sections in modules::motion
While motion queuing is safe, code that relies on the current block
needs to run with the isr disabled.

Protect AbortPlannedMoves and CurPosition from isr' interference by
using a RAII guard.
2022-05-02 12:33:37 +02:00
Alex Voinea 8f827d68c5 Add R0 and R1 to clobbers of mulU24X24toH16 just to be on the safe side 2022-05-02 12:30:56 +02:00
D.R.racer f2b65ebda2 Improve mulU8X16toH16 accordingly 2022-05-02 12:30:56 +02:00
D.R.racer aefa962cc3 Fix mulU24X24toH16
based on https://github.com/prusa3d/Prusa-Firmware/pull/3365
2022-05-02 12:30:56 +02:00
D.R.racer ca86797a9c Invalidate currentSlot while homing
makes calls to Slot() consistent and reliable
2022-02-21 18:38:04 +01:00
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