Ver código fonte

Fix cold/lengthy extrusion handling

Scott Lahteine 6 anos atrás
pai
commit
24b302c001
2 arquivos alterados com 32 adições e 23 exclusões
  1. 13
    8
      Marlin/Marlin_main.cpp
  2. 19
    15
      Marlin/planner.cpp

+ 13
- 8
Marlin/Marlin_main.cpp Ver arquivo

@@ -12947,27 +12947,32 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12947 12947
  *
12948 12948
  * This may result in several calls to planner.buffer_line to
12949 12949
  * do smaller moves for DELTA, SCARA, mesh moves, etc.
12950
+ *
12951
+ * Make sure current_position[E] and destination[E] are good
12952
+ * before calling or cold/lengthy extrusion may get missed.
12950 12953
  */
12951 12954
 void prepare_move_to_destination() {
12952 12955
   clamp_to_software_endstops(destination);
12953 12956
   refresh_cmd_timeout();
12954 12957
 
12955
-  #if ENABLED(PREVENT_COLD_EXTRUSION)
12958
+  #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
12956 12959
 
12957 12960
     if (!DEBUGGING(DRYRUN)) {
12958 12961
       if (destination[E_AXIS] != current_position[E_AXIS]) {
12959
-        if (thermalManager.tooColdToExtrude(active_extruder)) {
12960
-          current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12961
-          SERIAL_ECHO_START();
12962
-          SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
12963
-        }
12962
+        #if ENABLED(PREVENT_COLD_EXTRUSION)
12963
+          if (thermalManager.tooColdToExtrude(active_extruder)) {
12964
+            current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12965
+            SERIAL_ECHO_START();
12966
+            SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
12967
+          }
12968
+        #endif // PREVENT_COLD_EXTRUSION
12964 12969
         #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
12965
-          if (fabs(destination[E_AXIS] - current_position[E_AXIS]) > EXTRUDE_MAXLENGTH / volumetric_multiplier[active_extruder]) {
12970
+          if (FABS(destination[E_AXIS] - current_position[E_AXIS]) > (EXTRUDE_MAXLENGTH) / volumetric_multiplier[active_extruder]) {
12966 12971
             current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12967 12972
             SERIAL_ECHO_START();
12968 12973
             SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
12969 12974
           }
12970
-        #endif
12975
+        #endif // PREVENT_LENGTHY_EXTRUDE
12971 12976
       }
12972 12977
     }
12973 12978
 

+ 19
- 15
Marlin/planner.cpp Ver arquivo

@@ -719,24 +719,28 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
719 719
 
720 720
   long de = target[E_AXIS] - position[E_AXIS];
721 721
 
722
+  const float e_factor = volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01;
723
+
722 724
   #if ENABLED(LIN_ADVANCE)
723 725
     float de_float = e - position_float[E_AXIS];
724 726
   #endif
725 727
 
726
-  #if ENABLED(PREVENT_COLD_EXTRUSION)
728
+  #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
727 729
     if (de) {
728
-      if (thermalManager.tooColdToExtrude(extruder)) {
729
-        position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
730
-        de = 0; // no difference
731
-        #if ENABLED(LIN_ADVANCE)
732
-          position_float[E_AXIS] = e;
733
-          de_float = 0;
734
-        #endif
735
-        SERIAL_ECHO_START();
736
-        SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
737
-      }
730
+      #if ENABLED(PREVENT_COLD_EXTRUSION)
731
+        if (thermalManager.tooColdToExtrude(extruder)) {
732
+          position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
733
+          de = 0; // no difference
734
+          #if ENABLED(LIN_ADVANCE)
735
+            position_float[E_AXIS] = e;
736
+            de_float = 0;
737
+          #endif
738
+          SERIAL_ECHO_START();
739
+          SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
740
+        }
741
+      #endif // PREVENT_COLD_EXTRUSION
738 742
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
739
-        int32_t de_mm = labs(de * volumetric_multiplier[active_extruder]);
743
+        const int32_t de_mm = labs(de * e_factor);
740 744
         if (de_mm > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
741 745
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
742 746
           de = 0; // no difference
@@ -747,9 +751,9 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
747 751
           SERIAL_ECHO_START();
748 752
           SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
749 753
         }
750
-      #endif
754
+      #endif // PREVENT_LENGTHY_EXTRUDE
751 755
     }
752
-  #endif
756
+  #endif // PREVENT_COLD_EXTRUSION || PREVENT_LENGTHY_EXTRUDE
753 757
 
754 758
   // Compute direction bit-mask for this block
755 759
   uint8_t dm = 0;
@@ -778,7 +782,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
778 782
   #endif
779 783
   if (de < 0) SBI(dm, E_AXIS);
780 784
 
781
-  const float esteps_float = de * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01;
785
+  const float esteps_float = de * e_factor;
782 786
   const int32_t esteps = abs(esteps_float) + 0.5;
783 787
 
784 788
   // Calculate the buffer head after we push this byte

Carregando…
Cancelar
Salvar