Przeglądaj źródła

Unload first before retrying

Should free the filament if accidentally held by the fsensor.
D.R.racer 2 lat temu
rodzic
commit
fe6e3ca2b1
2 zmienionych plików z 23 dodań i 6 usunięć
  1. 21 6
      Firmware/mmu2.cpp
  2. 2 0
      Firmware/mmu2.h

+ 21 - 6
Firmware/mmu2.cpp

@@ -51,8 +51,8 @@ static constexpr float MMU2_LOAD_TO_NOZZLE_FEED_RATE = 20.0F; // mm/s
 static constexpr float MMU2_UNLOAD_TO_FINDA_FEED_RATE = 120.0F; // mm/s
 
 // The first the MMU does is initialise its axis. Meanwhile the E-motor will unload 20mm of filament in approx. 1 second.
-static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH = 20.0f; // mm
-static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE = 20.0f; // mm/s
+static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH = 80.0f; // mm
+static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE = 80.0f; // mm/s
 
 static constexpr uint8_t MMU2_NO_TOOL = 99;
 static constexpr uint32_t MMU_BAUD = 115200;
@@ -735,6 +735,18 @@ void MMU2::CheckUserInput(){
         SERIAL_ECHOLN(btn);
         ResumeHotendTemp(); // Recover the hotend temp before we attempt to do anything else...
         Button(btn);
+
+        // A quick hack: for specific error codes move the E-motor every time.
+        // Not sure if we can rely on the fsensor.
+        // Just plan the move, let the MMU take over when it is ready
+        switch(lastErrorCode){
+        case ErrorCode::FSENSOR_DIDNT_SWITCH_OFF:
+        case ErrorCode::FSENSOR_TOO_EARLY:
+            HelpUnloadToFinda();
+            break;
+        default:
+            break;
+        }
         break;
     case RestartMMU:
         Reset(ResetPin); // we cannot do power cycle on the MK3
@@ -990,8 +1002,7 @@ void MMU2::OnMMUProgressMsgChanged(ProgressCode pc){
             // We're likely recovering from an MMU error
             st_synchronize();
             unloadFilamentStarted = true;
-            current_position[E_AXIS] -= MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH;
-            plan_buffer_line_curposXYZE(MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE);
+            HelpUnloadToFinda();
         }
         break;
     case ProgressCode::FeedingToFSensor:
@@ -1005,13 +1016,17 @@ void MMU2::OnMMUProgressMsgChanged(ProgressCode pc){
     }
 }
 
+void __attribute__((noiniline)) MMU2::HelpUnloadToFinda(){
+    current_position[E_AXIS] -= MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH;
+    plan_buffer_line_curposXYZE(MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE);
+}
+
 void MMU2::OnMMUProgressMsgSame(ProgressCode pc){
     switch (pc) {
     case ProgressCode::UnloadingToFinda:
         if (unloadFilamentStarted && !blocks_queued()) { // Only plan a move if there is no move ongoing
             if (fsensor.getFilamentPresent()) {
-                current_position[E_AXIS] -= MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH;
-                plan_buffer_line_curposXYZE(MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE);
+                HelpUnloadToFinda();
             } else {
                 unloadFilamentStarted = false;
             }

+ 2 - 0
Firmware/mmu2.h

@@ -290,6 +290,8 @@ private:
     /// Common processing of pushing filament into the extruder - shared by tool_change, load_to_nozzle and probably others
     void ToolChangeCommon(uint8_t slot);
 
+    void HelpUnloadToFinda();
+
     ProtocolLogic logic; ///< implementation of the protocol logic layer
     uint8_t extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet
     uint8_t tool_change_extruder; ///< only used for UI purposes