Commit Graph

57 Commits (12dd0bdd903119d5cf8c43eba45b6caebaedc9ad)

Author SHA1 Message Date
D.R.racer c0189d81af Distinguish among different error states when recovering ToolChange
Some errors need specific recovery, it seems it is no longer possible to "just" retry.
2022-11-18 22:42:05 +01:00
Guðni Már Gilbert 353affb9f3 Optimise Catch2 V3 includes + fix a few cases of missing includes 2022-10-22 15:41:44 +02:00
Guðni Már Gilbert 45f70e004c Update CMake integration for Catch v3.1.0 2022-10-22 15:41:44 +02:00
D.R.racer 4f1a301e0e Force fix formatting 2022-09-22 12:16:41 +02:00
D.R.racer 0fa8a3c278 Refactor original solution from @leptun
- rename stall*guard to StallGuard (match name with the vendor)
- separate TMC2130 module from EEPROM (they do not need to know about each other at all)
- separate SGTHRS settings from motion - moved to globals like all other "global" parameters
- improved EEPROM storage for SGTHRS
2022-09-22 12:16:41 +02:00
D.R.racer 4964e9a781 Fixup unit tests due to new homing behavior 2022-08-02 07:16:54 +02:00
D.R.racer 3c3e625f39 Unit test ErrDisengageIdler: make sure it never sets error while disengaging 2022-07-20 16:23:43 +02:00
D.R.racer d80a58cfdb Fix unit tests 2022-06-20 17:03:40 +02:00
D.R.racer 2874dd3bc9 Make sure the selector never moves if FINDA is pressed
It looks we have some kind of leak when filament sensor state is not completely coherent with FINDA state.
This is yet to be discovered and fixed with some unit tests.
2022-06-20 14:20:31 +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 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
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
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 bcba966a0e Fix repeated re-homing + add more unit tests for that scenario 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 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 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
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 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 6f982e2505 Cleanup compiler warnings 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 ffd8924d8c Fix start MMU with filament blocking the selector 2021-11-03 10:37:51 +01:00
D.R.racer 9438253106 Avoid trying to unload filament when not loaded
however, it looks like the EEPROM is not updated correctly, needs more testing
2021-10-21 15:16:29 +02:00
D.R.racer ee247246ee Fix unit tests
- fix homing procedure for Idler and Selector
  (homing now ends with a move to the Parking position)
- fix unit tests' startup conditions with regard to necessary
  homing of Idler and Selector

TODO: still test_cut_filament fails for minor reasons
2021-10-21 07:55:41 +02:00
D.R.racer c26cc30185 Add finer filament loaded states and improve unit tests
We need to know better where the filament is, a simple "filament loaded true/false"
does not correspond to the reality.
2021-10-12 18:11:05 +02:00
D.R.racer 5cf4a496e3 Introduce checking for enabled/disabled Pulley axis in unit tests 2021-10-12 18:11:05 +02:00
D.R.racer 37ff9b8a8f Fix unit tests for AbortPlannedMoves(axis) 2021-09-07 15:03:36 +02:00
D.R.racer 52a6d57704 Remove Motion::Home completely 2021-09-07 15:03:36 +02:00
D.R.racer ffe5bc2807 Make Idler and Selector only wait for their own axis
... and fix the unit tests for this
2021-09-02 08:35:56 +02:00
3d-gussner 382a2c8dc0 Fix unit test: feed_to_finda 2021-08-31 06:59:29 +02:00
Yuri D'Elia 04631677cc Motion/PulseGen: implement move chaining and end-speed control
Allow to chain moves by adding one extra parameter to the PlanMove[to]
functions: ending speed.

A move will always be accelerated from the last speed towards end ending
speed. The following:

  PlanMove(100._mm, 50._mm_s, 50._mm_s);
  PlanMove(200._mm, 100._mm_s);

Will first move the axis 100mm, accelerating towards 50mm/s, then
accelerate again to 100mm/s. The move will for then decelerate towards a
full stop after reaching 300mm in total.

Acceleration can be changed for each segment, so that a custom
acceleration curve can be created:

  SetAcceleration(10._mm_s2);
  PlanMove(100._mm, 50._mm_s, 50._mm_s);
  SetAcceleration(100._mm_s2);
  PlanMove(100._mm, 50._mm_s, 50._mm_s);

The ending speed might not always be reached, depending on the current
acceleration settings. The new function "Rate()" will return the ending
feedrate of the last move, if necessary.

AbortPlannedMoves accepts a new "halt" parameter to control how moves
will be chanined when interrupting the current move. By default
(halt=true) the move is completely interrupted.

When halt=false is requested, a subsequent move will be chained starting
at the currently aborted velocity. This allows to chain moves in reponse
to events, for example to accelerate the pulley without stopping as soon
as the FINDA is triggered, it's sufficient to interrupt the current move
followed by a new one:

  PlanMove(maximum_loading_lenght, slow_feedrate);
  ... wait for PINDA trigger ...
  AbortPlannedMoves(true);
  PlanMove(bowden_lenght, fast_feedrate);

will seamlessy continue loading and transition to the fast feedrate.

Jerk control has been simplified. It now handles only the maximal
velocity change of the last segment, which doesn't require reverse
planning.
2021-08-30 12:49:34 +02:00
Yuri D'Elia d55e01bb58 Motion/PulseGen: allow to abort a move for chaining
Add a new parameter "halt" (default to true) to control the stopping
behavior:

- halt=true: no subsequent moves will be planned, motions stops abruptly
- half=false: a new move will be chained after the current one
2021-08-30 12:49:34 +02:00
D.R.racer 2f5dff6c5b Introduce short namespace aliases
especially for modules
2021-08-04 11:03:56 +02:00
D.R.racer aa5995368d Update to latest main + fix unit tests
... in relation to the newly introduced stepping in physical units rather than in steps
2021-08-02 10:52:18 +02:00
D.R.racer 16dc129b49 Set real slot positions for the Idler and Selector
Extracted from the previous FW, may need some tuning based on units selected
for each of these axes (degrees, millimeters) - waiting for an update
of the motion implementation.

Updated starting conditions of the unit tests to reflect the global configuration.

MMU-58
2021-08-02 10:52:18 +02:00
D.R.racer df2c1ba7fe Add prototype of unified handling of HW errors in the logic layer 2021-08-02 07:45:45 +02:00
D.R.racer a8147be803 Fix unit tests + rebase onto main + extract TMC parameters into config 2021-07-29 10:01:33 +02:00
Yuri D'Elia d955897829 Convert config::selectorSlotPositions to physical units 2021-07-25 23:13:28 +02:00
Yuri D'Elia 98845008aa Rename Motion::CurrentPos to Position()
This matches PulseGen::Position() and avoids confusion around the term
"current": Position() returns the head position in the queue, not the
"live" axis position.

We have PulseGen::CurPosition() now for this purpose, although we don't
expose it to Motion yet.
2021-07-13 01:03:03 +02:00
Yuri D'Elia 9b0dd2d633 Motion: fix new Step() prototype 2021-07-12 09:58:53 +02:00
Yuri D'Elia 7337e97765 Rename Motion::DisableAxis to Disable
Implement Motion::SetEnabled (for symmetry with TMC2130::SetEnabled).

Rename DisableAxis to Disable and use the new SetEnabled. This makes the
member names more consistent.
2021-07-11 21:38:01 +02:00
Yuri D'Elia d87db1ff76 Revised WIP for the Motion API
- Remove the combined PlanMove(a,b,c,rate) call. If we allow the units
  of the various motors to be changed at compile time, the unit of
  rate can vary between axes.
- Build PlanMove on top of the absolute PlanMoveTo.
- Add required stubs for TMC2130.
- Allow each axis mode to be set independently, since we have this
  feature for free anyway.
- Rework internals to use PulseGen data types and structs.
2021-07-07 16:59:39 +02:00
Yuri D'Elia ef7c776461 Update Motion for the new TMC2130/pins definitions 2021-07-07 16:59:04 +02:00
D.R.racer b484eeacb6 Start using config.h
Added some constexpr vars for buttons, finda, fsensor and
applied them in the FW and unit tests accordingly.
2021-07-05 18:07:54 +02:00
D.R.racer ffae941a28 Fix unit tests of load/unload filament 2021-06-30 07:39:31 +02:00
D.R.racer 46a40f7488 Extend Unload filament unit tests
+ now error states are covered as well
+ greatly cleaned-up code
2021-06-30 07:39:31 +02:00
D.R.racer ce20f0b001 Greatly improve unload filament unit test
+ relevant changes for other unit tests -> prepare for improving
of the other unit tests as well
2021-06-30 07:39:31 +02:00
D.R.racer 4d6d6fe0af Add more checks (esp. positions of idler and selector)
that resulted in finding several weak spots and now Cut and Eject filament
do not pass the test (which is correct, they really have logical issues)
2021-06-21 10:28:56 +02:00