Browse Source

Fix cold/lengthy extrusion handling

Scott Lahteine 7 years ago
parent
commit
24b302c001
2 changed files with 32 additions and 23 deletions
  1. 13
    8
      Marlin/Marlin_main.cpp
  2. 19
    15
      Marlin/planner.cpp

+ 13
- 8
Marlin/Marlin_main.cpp View File

12947
  *
12947
  *
12948
  * This may result in several calls to planner.buffer_line to
12948
  * This may result in several calls to planner.buffer_line to
12949
  * do smaller moves for DELTA, SCARA, mesh moves, etc.
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
 void prepare_move_to_destination() {
12954
 void prepare_move_to_destination() {
12952
   clamp_to_software_endstops(destination);
12955
   clamp_to_software_endstops(destination);
12953
   refresh_cmd_timeout();
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
     if (!DEBUGGING(DRYRUN)) {
12960
     if (!DEBUGGING(DRYRUN)) {
12958
       if (destination[E_AXIS] != current_position[E_AXIS]) {
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
         #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
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
             current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12971
             current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12967
             SERIAL_ECHO_START();
12972
             SERIAL_ECHO_START();
12968
             SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
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 View File

719
 
719
 
720
   long de = target[E_AXIS] - position[E_AXIS];
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
   #if ENABLED(LIN_ADVANCE)
724
   #if ENABLED(LIN_ADVANCE)
723
     float de_float = e - position_float[E_AXIS];
725
     float de_float = e - position_float[E_AXIS];
724
   #endif
726
   #endif
725
 
727
 
726
-  #if ENABLED(PREVENT_COLD_EXTRUSION)
728
+  #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
727
     if (de) {
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
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
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
         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
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
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
745
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
742
           de = 0; // no difference
746
           de = 0; // no difference
747
           SERIAL_ECHO_START();
751
           SERIAL_ECHO_START();
748
           SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
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
   // Compute direction bit-mask for this block
758
   // Compute direction bit-mask for this block
755
   uint8_t dm = 0;
759
   uint8_t dm = 0;
778
   #endif
782
   #endif
779
   if (de < 0) SBI(dm, E_AXIS);
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
   const int32_t esteps = abs(esteps_float) + 0.5;
786
   const int32_t esteps = abs(esteps_float) + 0.5;
783
 
787
 
784
   // Calculate the buffer head after we push this byte
788
   // Calculate the buffer head after we push this byte

Loading…
Cancel
Save