Commit Graph

636 Commits (e28ab28824e6837931e3a77f9016fc603cb17de7)

Author SHA1 Message Date
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 7002e3b0c7 Avoid homing Idler and Selector at the same time
This PR is an experimental code to delay homing of the Selector after the Idler homes properly.

Unit tests are expected to fail at this moment...
2022-08-02 07:16:54 +02: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
Yuri D'Elia 4794cfea40 Convert illegal constexpr to static const pointers
We cannot get a constexpr definition of the register addresses, and any
reinterpret cast is currently illegal for a constexpr in c++17.

Change the SPI0, TIFR and TIMSK to volatile const pointers instead.

SPI0 has volatile members instead of marking the entire struct as
volatile, which is probably not a good idea as it technically drops the
volatile from the original pointer.
2022-07-25 10:27:16 +02:00
D.R.racer a7587d737a Bump version to 2.0.19
since we introduced a breaking change (extension) of protocol in commit 32ad80e
2022-07-22 16:00:44 +02:00
D.R.racer 32ad80e283 Confirm Button "commands" as well (send B0 A) 2022-07-20 16:23:43 +02:00
D.R.racer 7688554581 Defer setting error until ErrDisengagingIdler finishes 2022-07-20 16:23:43 +02:00
D.R.racer 26151fb176 Only restart the feed phase when FINDA NOT pressed 2022-06-22 09:45:02 +02:00
D.R.racer a01ff57ea3 Improve restart ToolChange -> FeedToFINDA
It looks like we don't have to reset the whole ToolChange state machine when resolving an error with the middle button (Retry) - but jump straight into the feeding phase.
The reasons are multiple:
- If an error happens during the unload phase, it is handled separately in the UnloadFilament state machine
- If an error happens during the feeding phase, the unload has been already successfully completed.
  And when restarted from the very beginning, the ToolChange does the last retract sequence from the UnloadFilament phase
  -> that is not healthy, because the filament gets pushed away from the Pulley and causes another error.
2022-06-22 09:45:02 +02:00
D.R.racer f70c3ed5ec Bump MMU FW version to 2.0.18 2022-06-21 14:30:16 +02:00
D.R.racer bc298ab114 Add unit test for empty event queue 2022-06-20 17:03:40 +02:00
D.R.racer b82ffe8db9 Add missing ResponseParamCode Button support + unit test 2022-06-20 17:03:40 +02:00
D.R.racer d80a58cfdb Fix unit tests 2022-06-20 17:03:40 +02:00
D.R.racer 5a636529ca "Printer in Charge" mode: report buttons into the printer for processing
Sets the UI module into a mode when the printer is in charge of processing the buttons (from all sources).
That means the MMU will detect its buttons but it will not react upon them.
This mode is important for error recovery when the printer needs to do some stuff before the MMU (like preheating the nozzle).
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 d2ba215580 Increment MMU error count with every new error ocurred 2022-06-20 13:54:07 +02:00
D.R.racer cecb659564 Reject LoadFilament if filament state > AtPulley
If the MMU receives a command LoadFilament with a slot number SL we reject
the command to avoid moving the selector (effectively cutting the piece of filament present in FINDA).

That includes the scenario when the selector is standing at the very same slot SL, because the filament could be held by the printer (i.e. loaded in the nozzle).

There is one special case though - same slot AND filament load state == InSelector (it MUST NOT be anywhere farther)
2022-06-20 13:53:35 +02:00
Yuri D'Elia f8080bc73b Avoid runtime floats in Pulley::PlanMove
Using U_mm inside a compilation unit will force the compiler to generate
a runtime copy of the function, and we don't want that.

But there seems also to be an optimization problem with gcc <= 7.x where
even when declaring an inline function constexpr, if called enough
times, the compiler will choose _not_ to evaluate the function at
compile time and thus avoid our compile-time float->integer
conversions...

For this reason, split the body of the function in two parts: the actual
function that uses AxisUnits at runtime for calling motion.PlanMove, and
a wrapper that forces the conversion. By marking this function as
always_inline, the body is correctly evaluated at compile time at each
call site.
2022-06-18 09:07:03 +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 750e83c5e9 Tune debounce timeout of buttons 2022-06-14 07:31:51 +02:00
D.R.racer fbb46e5951 Distinguish fast and slow feed stage
Originally, only FeedingToBondtech was reported to the printer.
With PR#173 we have this operation separated into a fast and a slow stage (for MK3S with the chimney).
It looks like the printer could benefit from knowing if the MMU is still pushing fast
or when it entered the slow stage (to prevent ramming hard the Bondtech gears)

Along with this new state being reported, we also introduce a new ErrorCode::FSENSOR_TOO_EARLY
which basically means that the fsensor triggered in the fast feeding stage.
2022-05-23 07:41:54 +02:00
D.R.racer d830a92fee Distinguish between fast and slow FeedToBondtech stage 2022-05-23 07:34:46 +02:00
Yuri D'Elia ea3b8e5c85 pulse_gen: Fix acceleration_rate block calculations
The acceleration_rate should really by a premultiplication by 1<<24 so
that the division in Step() (while calculating the acc_step_rate) can be
computed again with a right shift.

This was incorrectly changed to F_CPU, which was close enough but would
cause the acceleration to be always slighly slower than expected.

Fix the ratio, but keep the multiplication in fixed-point to avoid a
float conversion.
2022-05-21 15:13:49 +02:00
D.R.racer e99e7441e1 Add unit tests for unlimited load 2022-05-13 12:54:23 +02:00
D.R.racer 6b06fed4b1 Perform a re-check (LoadFilamentLimited) after successful LoadFilament
- [] Unit tests of unlimited LoadFilament need to be introduced as the complexity of this scenario is increasing

.
2022-05-13 12:54:23 +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
Yuri D'Elia 3fbdf8bb2b motion: PlanMove() correctly also when overflowing Position()
Correctly compute both the number of steps and direction when
under/overflowing the current position by performing a relative move.

This makes a repeated PlanMove() _always_ perform the move correcly,
even when the upper-level code might require to handle the overflow
itself for measurement.

Add tests for this condition by exposing the internal CurBlockShift() to
the motion unit tests.
2022-05-11 08:48:53 +02:00
Yuri D'Elia 1a2034f545 motion: Allow to get the motion controller for any axis 2022-05-11 08:48:53 +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
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 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 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 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 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 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
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 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
D.R.racer c2325b687a Unittests: set buttons more consistently 2021-11-17 08:48:59 +01:00
D.R.racer 872b2206ed Cleanup error recovery of LoadFilament
+ cover all paths with unit tests
2021-11-17 08:48:59 +01:00
D.R.racer 96397ec16b Improve error handling of ToolChange state machines
... and fix an edge case in LoadFilament
2021-11-17 08:48:59 +01:00
D.R.racer bfa710525b Discard all remaining planned blocks with AbortPlannedMoves
Previously it looked like only the active block has been discarded
which worked most of the time, since we only planned single moves.
But with introduction of PlanLongMove in one of the last commits
this is not true anymore.
2021-11-17 08:48:59 +01:00
D.R.racer 62e12102fd Check for FSensor OFF after unloaded to FINDA
we may discuss when to check for the FSensor state and why,
but this approach seemed to me like the least invasive method
of just checking the fsensor state and reporting an error in case
it didn't switch off.
2021-11-17 08:48:59 +01:00
D.R.racer 2a1539b65b Fix Right button handling for Load/Unload 2021-11-17 08:48:59 +01:00
Yuri D'Elia b6a676e093 AVR: Do not use __builtin_abs() for long types
In AVR __builtin_abs() breaks for non-base types.

Provide a generic function and use an overload when it is safe to use
instead.

This fixes the underlying step count calculation in PlanMove, thus
removing the need for the PlanLongMove work-around.
2021-11-11 07:41:48 +01:00
D.R.racer 2d81332626 Fix typo - selector homing condition 2021-11-03 10:37:51 +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 2640e9d899 Fix inverted condition (kudos to @leptun) 2021-11-03 10:13:03 +01:00
D.R.racer fa4e687fdc Fix chopping negative move values in PlanLongMove
+ use PlanLongMove in UnloadToFinda
+ fix comment in unit test
2021-11-03 10:13:03 +01:00
D.R.racer 5f1e3e018e Workaround planning moves longer than 32K steps 2021-11-03 10:13:03 +01:00
D.R.racer 7f9fc78cf6 Improve motion's unit tests 2021-11-03 10:13:03 +01:00
D.R.racer 6294e39746 Avoid repeated writes into the shift register
May reduce flickering of LEDs on some boards
2021-11-03 10:13:03 +01:00
D.R.racer 22522c253f Update code after rebase onto main 2021-10-21 15:16:29 +02: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 04348b2d86 Make all SHR16 public functions "thread-safe" 2021-10-21 10:17:10 +02:00
D.R.racer 19dcfcef79 Revert selector's config back after testing on real HW 2021-10-21 07:55:41 +02:00
D.R.racer 63509af294 Fix cut filament unit tests
still, this may need some more work in relation to PR #128
2021-10-21 07:55:41 +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
Alex Voinea 7380cb740a Pulley SG increased 2021-10-21 07:55:41 +02:00
Alex Voinea 99c05b79d0 Adjust SG filtering threshold 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 5b9c6ec36e Fix (workaround) LED blink when millis overflow + unit test 2021-10-18 16:30:08 +02:00
D.R.racer 8eb6240541 Add HAL AVR EEPROM implementation 2021-10-18 16:29:54 +02:00
D.R.racer abe2567c84 Fixes for loading filament into nozzle
Slower speed once we reach the fsensor + avoid grind while disengaging the Idler
while the printer is already pulling the filament.
2021-10-18 07:29:13 +02:00
Alex Voinea 9dc2ccc337 Revert accidental include 2021-10-14 14:27:56 +02:00
Alex Voinea 438ced6b96 Revert accidental commit 2021-10-14 14:27:56 +02:00
D.R.racer 9994d05d7f Reformat usb_cdc.cpp 2021-10-14 14:27:56 +02:00
D.R.racer d35bcd258a Refactor after rebase onto main 2021-10-14 14:27:56 +02:00
Alex Voinea 78af22e6c3 Dual bank test. Seemed to work for me. Don't care if it's placebo 2021-10-14 14:27:56 +02:00
Alex Voinea 538d4c8ef6 Remove useless debug info 2021-10-14 14:27:56 +02:00
Alex Voinea 3391b04ec7 update usb debug 2021-10-14 14:27:56 +02:00
Alex Voinea ea7d44a611 debug USB stream 2021-10-14 14:27:56 +02:00
Alex Voinea 362d012eff USB cdc stdout stream 2021-10-14 14:27:56 +02:00
3d-gussner 63aead0ab8 Update eject to use FilamentLoadState NotLoaded 2021-10-12 18:11:05 +02:00
3d-gussner fb97e519aa Feed slowly if FilamentLoadState is unknown 2021-10-12 18:11:05 +02:00
D.R.racer 206923598b Fix error codes formatting 2021-10-12 18:11:05 +02:00
D.R.racer e1af08b3d5 Fix unit tests
That includes:
- introduce pulley slow feedrate and fsensor-to-nozzle distance
  in config necessary for slowly feeding the filament from fsensor into the nozzle.
  (the constant is subject to extraction into some other config as it has to be used in the printer as well).
- update FeedToBondtech accordingly to perform a gentle push into the nozzle
  after fsensor detects the filament + update its unit tests.
- slight cleanup of LoadFilament + fix its unit tests
- add FeedingToNozzle progress code, as it might be interesting
  to inform the printer about this task in the future
- revert non-clean changes from RetractFromFinda - it should not disengage the idler
- revert incorrect + fix ToolChange
- clean-up UnloadFilament
2021-10-12 18:11:05 +02:00
Alex Voinea 94e6d1403e (Hopefully) Fir shr16 timing issues
Should also hopefully fix the random behavior of the DIR pins. When I was testing a really slow timing, the steppers seemed to want to not go in the right direction. That was fixed with the critical section. The 1us delay might be overkill, but I'm not the one that added a 100nF capacitor on the LATCH line (basically chip select). This might be part of the randomness that happened and why some board behaved better than others (stronger GPIO outputs)
2021-10-12 18:11:05 +02:00
Alex Voinea 34442469a3 More extreme speeds. They reveal errors in the motion planner 2021-10-12 18:11:05 +02:00
Alex Voinea 6e50d902d2 Steppers should be disabled on startup 2021-10-12 18:11:05 +02:00
Alex Voinea ef997a6352 Update cuttingEdgeRetract 2021-10-12 18:11:05 +02:00
Alex Voinea 0a1290102c Actually fix retract filament from finda 2021-10-12 18:11:05 +02:00
Alex Voinea 6071257973 Fix unloading state machine 2021-10-12 18:11:05 +02:00
3d-gussner 221f40c7a1 Fix issue that all tool changes after first one fail to change to planned slot
Update Filament Load state
2021-10-12 18:11:05 +02:00
3d-gussner 33b467f1bc Add debug to retract from finda 2021-10-12 18:11:05 +02:00
3d-gussner 62116b1283 Update debug 2021-10-12 18:11:05 +02:00
3d-gussner d9134b16fc Update Filament Load state order 2021-10-12 18:11:05 +02:00
3d-gussner 82f2e8ec54 fix some debug output 2021-10-12 18:11:05 +02:00
3d-gussner f9561e6cf7 Remove double operations
- feed to finda engages the idler so no need to do that before
- retract from finda disengages the idler, again avoid double operation
LEDs set mostly by feed to finda and retract from finda
2021-10-12 18:11:05 +02:00
3d-gussner 5cfb0887d0 Disengage Idler after retracted from FINDA
Add some dbg_logic output
2021-10-12 18:11:05 +02:00
3d-gussner b752c5c4e7 Set FilamentLoaded state to InSelector if FINDA triggers 2021-10-12 18:11:05 +02:00
3d-gussner fa50462929 Add InFSensor state 2021-10-12 18:11:05 +02:00
3d-gussner 67657329d1 Correct debug messages for state 2021-10-12 18:11:05 +02:00
3d-gussner f99adae31e Use config.h 2021-10-12 18:11:05 +02:00
3d-gussner abf875bda0 After Load Filament is compeleted the slot LED should be off 2021-10-12 18:11:05 +02:00
3d-gussner 28c8e09bcf Use config.h to define DEBUGS 2021-10-12 18:11:05 +02:00
3d-gussner dbf26d13ac Make search for error codes easier 2021-10-12 18:11:05 +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 5af0125672 LoadFilament should not set filament loaded (surprisingly)
because of the change of semantics of LoadFilament operation.
LoadFilament pushes the filament into FINDA and then retracts it back just to keep the
filament ready to be grabbed by the idler and pulley and loaded into the printer's nozzle.

So the selector is not blocked by the filament -> filament NOT loaded
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 5cf4a496e3 Introduce checking for enabled/disabled Pulley axis in unit tests 2021-10-12 18:11:05 +02:00
D.R.racer f18ff63cf7 Fix PROGMEM addressing in debug.h
I hate when the compiler doesn't check something what it normally does:
`pgm_read_byte` is more than happy with a parameter (*str), which reads
an address at a location where *str points to - which is obviously not the intent.
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
D.R.racer bbd14ed217 Fix ToolChange operation + unit tests 2021-10-12 18:11:05 +02:00
D.R.racer 505930c576 Explain better final Idler state in FeedToFinda and FeedToBondtech 2021-10-12 18:11:05 +02:00
D.R.racer e0d1fe3b73 Extract common ErrDisengagingIdler state's implementation 2021-10-12 18:11:05 +02:00
D.R.racer 6426295e32 Change the semantics of load filament
Load filament performs feed to FINDA and retract:
- engage idler
- feed normal to FINDA with config::feedToFinda distance until FINDA triggers
- retract normal and as soon FINDA un-triggers move back to PTFE config::cuttingEdgeToFindaMidpoint
- disengage the idler

That implied introducing another substate machine - RetractFromFinda, which does the opposite
of FeedToFinda while also checking for the FINDA switching off while retracting filament.

Still, ToolChange and CutFilament need fixing with this change
2021-10-12 18:11:05 +02:00
D.R.racer 5eedeb0968 Remove redundant ::Color and ::Mode for LED colors and modes
makes the code shorter and more readable, no identifier clashes revealed
2021-10-12 18:11:05 +02:00
D.R.racer 53b329941f Keep constants start with lowercase letter
and remove a few warnings from the build
2021-10-12 18:11:05 +02:00
D.R.racer ac1f13672a Fix format config.h 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
3d-gussner b8259ac555 Fix some LED status 2021-10-12 18:11:05 +02:00
3d-gussner b1f50d8789 Use constants 2021-10-12 18:11:05 +02:00
3d-gussner 645d0b55ed Use constants 2021-10-12 18:11:05 +02:00
3d-gussner c0938e41d5 Use constants 2021-10-12 18:11:05 +02:00
3d-gussner ddcf24af43 Use constants 2021-10-12 18:11:05 +02:00
3d-gussner 5c44cf9ee0 Add UnloadingToFinda 2021-10-12 18:11:05 +02:00
3d-gussner afe732d3ff Use constants 2021-10-12 18:11:05 +02:00
3d-gussner 64bd2bb894 Use constants 2021-10-12 18:11:05 +02:00
3d-gussner 2f2f4d7be3 Add some distances and put axis settings together 2021-10-12 18:11:05 +02:00
D.R.racer 1a5cd52d58 Fix some doxygen comments 2021-09-29 13:28:34 +02:00
D.R.racer 1402fb3dd6 Add 'F' and 'f' decoding + unit tests where necessary 2021-09-29 13:28:34 +02:00
D.R.racer 4900dd0222 Change FilamentSensor msg code from 'F' to 'f'
to avoid clash with Filament Type msg (which is not handled yet)
2021-09-29 13:28:34 +02:00
D.R.racer e277ca75ee Support F0 in response decoder 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 e59e7e3884 Make protocol decoder tolerant to leading whitespace 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
D.R.racer 89dcafbcef Add internal protocol decoding reset 2021-09-29 13:28:34 +02:00
D.R.racer 8a5614844c Add more error codes for the printer's perspective 2021-09-29 13:28:34 +02:00
D.R.racer 43c953b7f1 Fix appending newline character in puts* methods 2021-09-27 11:15:20 +02:00
D.R.racer 304988fc6c Simple debug logging via USART1
Encapsulates the #define macros and AVR implementation of dumping strings
(RAM and PROGMEM) onto USART1.
2021-09-27 11:15:20 +02:00
D.R.racer c896031a62 Merge branch 'lufa-cmake' of github.com:DRracer/Prusa-Firmware-MMU-Private into lufa-cmake 2021-09-23 13:40:34 +02:00
D.R.racer 10e08021fb Another fix format 2021-09-23 13:40:15 +02:00
Alex Voinea 77e0f56142
Merge branch 'main' into lufa-cmake 2021-09-23 04:31:11 -07:00
Alex Voinea e35ae30470
Remove some debug code 2021-09-23 14:24:07 +03:00
D.R.racer cddc16dc2e Tune USB CDC class + doc 2021-09-23 13:14:28 +02: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 9f0f7bc33b Fix limits.h naming conflict 2021-09-20 18:18:52 +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