Commit Graph

91 Commits (72fbffea724c23bc2e547cdfbec024671e993f5b)

Author SHA1 Message Date
D.R.racer 72fbffea72 Add HW EEPROM reset
Now the whole functionality takes +196B

As noted by @leptun, we cannot reliably check for >1 buttons pressed at once.
Since the left button is the least used, let's use it for invoking the HW EEPROM clear upon MMU start.
2023-02-24 16:19:31 +01:00
D.R.racer b6c3cba396 Refactor CheckFINDAvsEEPROM and setup2 2022-12-27 12:41:29 +01:00
D.R.racer 98daf765af Separate NoCommand and StartUp (new state machine)
The reasons for this change are:
- NoCommand is used during the lifetime of the firmware as a fallback in case an unknown command is received (simplifies command handling code). It must remain not doing anything.
- StartUp became a complex infrastructure which needs to "live" until an error is fixed (if any). That requires a "standard" StateInner() function which waits for the user to resolve the error.

Unit tests renamed as well.
2022-12-27 12:41:29 +01:00
Guðni Már Gilbert 4d38d1f620 PFW-1423 add Retry handling in NoCommand for init error 2022-12-27 12:41:29 +01:00
Guðni Már Gilbert 21a3ceb2b2 PFW-1428 Enable UART1 receiver when the MMU is ready to process incoming messages 2022-11-01 06:39:10 +01:00
VintagePC 10fd23700b Improve implementation 2022-09-16 19:39:27 -04:00
D.R.racer 858cd0349b Upgrade build system to gcc 7.3
based on PR#185 and https://github.com/wavexx/Prusa-Firmware-MMU-Private/pull/1
2022-07-27 17:04:52 +02:00
D.R.racer de8a2f35ae Fix setup/FINDA init state
It turned out FINDA needs running timer to perform BlockingInit() correctly.
Therefore setup() was split into setup() (no IRQ) and setup2() (IRQ enabled).

Then, finally, the check for FINDA state became reliable upon start of the FW.
2022-06-14 07:32:08 +02:00
D.R.racer 7ae9c9019c Clear EEPROM filament state upon start when FINDA is off
Complement to PR#176
2022-06-14 07:32:08 +02:00
D.R.racer c5aea89cac Report FINDA/EEPROM disrepancy to the printer 2022-05-13 08:17:28 +02:00
D.R.racer e9aae8570a Try to recover FINDA pressed + no EEPROM record at start 2022-05-13 08:17:28 +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 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 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 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 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 ffd8924d8c Fix start MMU with filament blocking the selector 2021-11-03 10:37:51 +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
Alex Voinea 9dc2ccc337 Revert accidental include 2021-10-14 14:27:56 +02:00
Alex Voinea 362d012eff USB cdc stdout stream 2021-10-14 14:27:56 +02:00
D.R.racer 1a5cd52d58 Fix some doxygen comments 2021-09-29 13:28:34 +02:00
D.R.racer dc3f5764a6 Add filament sensor status reporting from printer into MMU 2021-09-29 13:28:34 +02:00
D.R.racer ee353cd98c Report "Reset finished" after MMU FW start
kudos to @leptun for this original and actually a very clean idea.

For the start we report "Reset finished" which in fact corresponds with the MMU state pretty closely
and plays nicely even with the protocol implementation.
And, since the default startup command is the noCommand, which always returns "Finished"
the implementation is clean and straightforward - the response to the first Q0 messages
will look like "X0 F" until a command (T, L, U ...) has been issued.
2021-09-29 13:28:34 +02:00
Alex Voinea 77e0f56142
Merge branch 'main' into lufa-cmake 2021-09-23 04:31:11 -07:00
D.R.racer b6d630d1c9 Clean up the code + introduce USB CDC module
... and tune some more namespaces
2021-09-23 13:06:36 +02:00
3d-gussner d3d992da5b Cheange LED modes to be consistent. 2021-09-23 10:04:50 +02:00
Alex Voinea 4f6ea16515 Functional USB reset 2021-09-20 19:01:08 +02:00
Alex Voinea 6346dd3989 USB reset initial 2021-09-20 17:31:45 +02:00
Alex Voinea 29018671b5 Reduce verbosity 2021-09-20 17:31:45 +02:00
Alex Voinea a8b1725dfe Line encoding update 2021-09-20 17:31:45 +02:00
Alex Voinea 9611db9f53 Fix formatting and 🐑 2021-09-20 17:31:45 +02:00
Alex Voinea 895671aeb2 Fix descriptors 2021-09-20 17:31:45 +02:00
Alex Voinea 26fd53251b Checkpoint 2021-09-20 17:31:45 +02:00
Alex Voinea d1fd815e0c Quick and dirty workaround 2021-09-20 16:36:44 +02:00
Alex Voinea 06b959bb66 watchdog configuration 2021-09-20 16:28:53 +02:00
Alex Voinea 56eee8dcfb Reset the board using the cpu hal instead of the watchdog hal
Also some naming changes
2021-09-20 16:28:42 +02:00
D.R.racer 3b46c35595 Add handling of the X0 message (restart the MMU) via Watchdog 2021-09-20 16:28:17 +02:00
D.R.racer 324ced6807 Add watchdog implementation + use it in main() 2021-09-20 16:28:17 +02:00
D.R.racer 3646b8b1c0 Change M0/M1 into a command
That implies changing motor's mode from SpreadCycle into StealtMode (or vice versa)
requires a stand still MMU with no other command (i.e. motor moves) being performed.
This elegantly solves the synchronization problem of TMC2130 mode change, as it results
in severe jerking while a motor is moving.

The change in protocol is minimal - M0/M1 first return `M0 A` (accepted) and another `Q0` then
returns `M0 F` (finished). The MK4 counterpart may ignore the additional report if necessary
as the mode change is done immediately (shortly after responding with `M0 A`)
2021-09-07 14:17:03 +02:00
D.R.racer 09f81f8b33 Leverage the ability of motion to SetMode to all know axes 2021-09-02 12:27:41 +02:00
D.R.racer 852ca37e8f Add stealtMode flag into the global storage hive
May be used elsewhere to return to the desired motors' mode e.g. after homing
(which requires switching to normal mode)
2021-09-02 12:27:41 +02:00
D.R.racer 1e6194a9b9 Add support for M0/M1 messages
... route the messages into modules::motion's SetMode of all axes.
2021-09-02 12:27:41 +02:00
D.R.racer b4d4807971 Add globa Panic() function
The intent is to halt the firmware while retaining the reporting capabilities and blinking LEDs
2021-08-31 14:19:40 +02:00
D.R.racer dc3d8941f7 Fix formatting 2021-08-31 06:59:29 +02:00