Commit Graph

59 Commits (cbada468be9304ec877198963e3c4555e244db1b)

Author SHA1 Message Date
Guðni Már Gilbert cbada468be
Merge 3e68bb41e3 into 48d4d920be 2025-12-02 10:11:37 +01:00
D.R.racer f4388b8d20 ToolChange: don't disengage Idler after unload, but engage next slot immediately 2025-12-01 10:48:28 +01:00
Guðni Már Gilbert 3e68bb41e3 idler/selector: simplify init
The homing is always invalidated in all cases. Let's simply invalidate
the homing only in the init method. The state machine's Ready state then
decides when it is OK to perform the homing move.

We shouldn't need to guess the axis's position, and should assume its not correct. Currently the init methods are only called during the boot up sequence.

Change in memory:
Flash: -126 bytes
SRAM: 0 bytes
2025-11-30 09:43:18 +00:00
Guðni Már Gilbert f240bb24d1 idler: adjust distance threshold
Before, the axis limits had an error of 25° so 225° would actually be measured as 250°.

Now after fixing axisUnitToTruncatedUnit to return a more accurate value, the new values are lower. Adjust the distances by 20° to offset previous error.
2025-10-30 07:43:35 +01:00
Guðni Már Gilbert dc68b70cff idler: reduce duplicate code
Change in memory:
Flash: 54 bytes
SRAM: 0 bytes
2025-01-02 11:30:35 +01:00
Guðni Már Gilbert 4ab07d627a optimisation: compare uint16_t against uint16_t
AxisDistance returns uint16_t type and is currently compared with long double axis length. The axis lengths fit easily into uint16_t:

selectorLimits.lenght = 75
idlerLimits.lenght = 225

Change in memory:
Flash: -122 bytes
SRAM: 0 bytes
2024-12-24 13:44:55 +00:00
D.R.racer f07e206398 Hold/Resume Idler+Selector even after their homing errors
MMU-222
2023-03-14 18:14:02 +01:00
D.R.racer f0a633b4b6 Ignore Idler's SG signal from TMC when rolling over filaments 2023-03-14 17:58:11 +01:00
D.R.racer b97b7561c6 Ignoring the diag pin (stallguard) completely in specified range
This seems to greatly improve overall homing reliability of Idler on MMUs which couldn't home with inserted filaments at all.
The only downside is the fact, that we may actually "home" a blocked Idler correctly.
2023-03-14 17:58:11 +01:00
D.R.racer 95915cb080 Prototype adaptive Idler homing sg_thrs
Needs to be tweaked further to make it a production code.
But my primary concern now is the fact that it doesn't seem to help too much while homing over the too-tightened Idler cover.
2023-03-14 17:58:11 +01:00
D.R.racer 9b43b61939 Idler+Selector homing speeds: writeable registers 2023-03-02 19:54:50 +01:00
D.R.racer ea41fd6b83 Update unit tests 2023-03-02 12:20:06 +01:00
D.R.racer d75119c8d6 Suspend all moves of Idler and Selector when entering an Error screen 2023-03-02 12:20:06 +01:00
D.R.racer 425f89c862 Optimization - save 30B 2022-12-29 11:27:34 +01:00
D.R.racer 0bca66aeb5 Allow runtime config/register motor/axis iRun current
This commit introduces a new set of registers 0x1e, 0x1f and 0x20 which allow reading and writing iRun current values for each axis/motor.
Please note the register contains raw TMC2130 iRun value which needs to be translated into mA to be understandable by people.
Translation table of iRun -> mA is present in tmc2130.cpp for now.
2022-12-29 11:27:34 +01:00
D.R.racer a52f833223 Fix and tune CutFilament + unit tests
Several issues addressed in this PR:
- CutFilament tuning + error recovery
- introduce register 0x1d (cut filament selector iRun current level)
- optimize setting iRun and iHold currents in the FW
- CutFilament unit test fixed
2022-12-28 12:15:47 +01:00
D.R.racer 3f09ba0c16 Unit tests: selector refused to move in ToolChange
Revealed all kinds of subtle issues (which is great). All have been fixed in this commit.
2022-11-17 07:32:38 +01:00
D.R.racer dc487c36b6 Remove Enable/Disable TMC when reiniting Movable axes
The previous commits by @leptun were correct but there has been one call to Disable axis (and TMC) hidden in `InitMovement`.
Therefore `InitMovement` has been split into 2 separate functions - one is there to allow the original full axis reinit, but the other `InitMovementNoReinitAxis` now only prepares a move without reiniting the TMC driver.

This approach seems to have the benefit of fixing the Idler creep over time.

The disadvantage is the fact, that setting StallGuard threshold is no longer called. We may need to add a special piece of code to handle/apply SGTHRS change at runtime like before.
2022-10-20 12:09:42 +02:00
Alex Voinea d77d31b883 Idler dynamic IHOLD adjustments 2022-10-20 12:09:42 +02:00
Alex Voinea 55e8caa054 Always check for tmc errors 2022-10-11 07:13:42 +02:00
Alex Voinea 739f4cd2a3 Check for tmc2130 error flags 2022-10-11 07:13:42 +02:00
D.R.racer 283403306e Add additional registers
It looks like the units' conversion linked some floating point routines ... C++ units are a PITA :(
2022-08-11 10:26:42 +02:00
D.R.racer 5dffd32025 Introduce Idler::PartiallyDisengage
This is to solve a potential problem while feeding to printer's drive gears - while disengaging the Idler, the Pulley was still rotating to avoid grinding the filament (printer is pulling it).
Other filaments could have moved a bit when the Idler's bearings ran over them while the Pulley was still rotating slowly -> the filament could have been moved into the Selector's path causing trouble (especially when not used in the print).
Therefore, the Idler disengages partially now - moves into an intermediate position between the slots.
Then, the Pulley is completely stopped and after that the Idler does a full disengage like before.
2022-08-02 07:28:10 +02:00
Alex Voinea 989b6e6191 homing changes to increase reliability 2022-08-02 07:16:54 +02:00
D.R.racer 7e759fdb51 Rebase onto main: use axisUnitToTruncatedUnit 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
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 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 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 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 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 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
Alex Voinea a87b981a3d Homing initial 2021-10-21 07:55:41 +02:00
D.R.racer 0fbcb9dac2 Tag all source files with @file for doxygen 2021-10-18 17:59:46 +02:00
D.R.racer d35bcd258a Refactor after rebase onto main 2021-10-14 14:27:56 +02:00
3d-gussner 67657329d1 Correct debug messages for state 2021-10-12 18:11:05 +02:00
D.R.racer b13214b7f5 Fix debug sprintf variant 2021-10-12 18:11:05 +02:00
D.R.racer 236a40c6ef Use dbg_logic logging
and improve the variadic version used to print formatted
text at some spots in previous commits
2021-10-12 18:11:05 +02:00
3d-gussner 0bead533df clang-format 2021-10-12 18:11:05 +02:00
3d-gussner 15adeaa180 Add DEBUG_LOGIC 2021-10-12 18:11:05 +02:00
D.R.racer b1b5b9db84 Set better planned moves for homing + abort moves at StallGuard 2021-09-07 15:03:36 +02:00
D.R.racer dea41738a5 Add homing capability to Idler and Selector
MMU-73
2021-09-07 15:03:36 +02:00
D.R.racer 712b67beb4 Add checking of TMC2130 error states for Idler and Selector
we shall think about the Pulley as well, it looks like it should get its
own class just like Idler and Selector as it behaves very similarly in terms
of stepping and error checking
2021-09-02 08:35:56 +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
D.R.racer a58450acb6 Extract feedrates of Idler and Selector into config.h 2021-08-27 15:31:20 +02:00
D.R.racer 2f5dff6c5b Introduce short namespace aliases
especially for modules
2021-08-04 11:03:56 +02:00
D.R.racer ef96d998a3 Link top level error reporting to TMC2130 error flags 2021-08-02 07:45:45 +02:00
D.R.racer 751ee46450 Add bit masks for error codes for the TMC drivers
+ add common error handling for idler and selector
+ improve error handling in command_base
+ rename ERR1xxxx errors to ERRxxxx (remove the '1')
2021-08-02 07:45:45 +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