Browse Source

🚸 More automatic MMU2 load (#24750)

FBN 1 year ago
parent
commit
d0e7c2c208
No account linked to committer's email address
1 changed files with 25 additions and 5 deletions
  1. 25
    5
      Marlin/src/feature/mmu/mmu2.cpp

+ 25
- 5
Marlin/src/feature/mmu/mmu2.cpp View File

@@ -585,7 +585,7 @@ static void mmu2_not_responding() {
585 585
       command(MMU_CMD_T0 + index);
586 586
       manage_response(true, true);
587 587
       mmu_continue_loading();
588
-      command(MMU_CMD_C0);
588
+      //command(MMU_CMD_C0);
589 589
       extruder = index;
590 590
       active_extruder = 0;
591 591
 
@@ -653,13 +653,33 @@ static void mmu2_not_responding() {
653 653
   }
654 654
 
655 655
   void MMU2::mmu_continue_loading() {
656
+    // Try to load the filament a limited number of times
656 657
     for (uint8_t i = 0; i < MMU_LOADING_ATTEMPTS_NR; i++) {
657
-      DEBUG_ECHOLNPGM("Additional load attempt #", i);
658
-      if (FILAMENT_PRESENT()) break;
658
+      DEBUG_ECHOLNPGM("Load attempt #", i + 1);
659
+
660
+      // Done as soon as filament is present
661
+      bool fil_present = FILAMENT_PRESENT();
662
+      if (fil_present) break;
663
+
664
+      // Attempt to load the filament, 1mm at a time, for 3s
659 665
       command(MMU_CMD_C0);
666
+      stepper.enable_extruder();
667
+      const millis_t expire_ms = millis() + 3000;
668
+      do {
669
+        current_position.e += 1;
670
+        line_to_current_position(MMU_LOAD_FEEDRATE);
671
+        planner.synchronize();
672
+        // When (T0 rx->ok) load is ready, but in fact it did not load
673
+        // successfully or an overload created pressure in the extruder.
674
+        // Send (C0) to load more and move E_AXIS a little to release pressure.
675
+        if ((fil_present = FILAMENT_PRESENT())) MMU2_COMMAND("A");
676
+      } while (!fil_present && PENDING(millis(), expire_ms));
677
+      stepper.disable_extruder();
660 678
       manage_response(true, true);
661 679
     }
662
-    if (!FILAMENT_PRESENT()) {
680
+
681
+    // Was the filament still missing in the last check?
682
+    if (!fil_present) {
663 683
       DEBUG_ECHOLNPGM("Filament never reached sensor, runout");
664 684
       filament_runout();
665 685
     }
@@ -682,7 +702,7 @@ static void mmu2_not_responding() {
682 702
       command(MMU_CMD_T0 + index);
683 703
       manage_response(true, true);
684 704
       command(MMU_CMD_C0);
685
-      extruder = index; //filament change is finished
705
+      extruder = index; // Filament change is finished
686 706
       active_extruder = 0;
687 707
       stepper.enable_extruder();
688 708
       SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);

Loading…
Cancel
Save