Browse Source

Add option to fix E/D ratio

Work around for slicers producing buggy gcode.
Sebastianv650 7 years ago
parent
commit
de6c40ed8f

+ 25
- 0
Marlin/Configuration_adv.h View File

@@ -592,6 +592,31 @@
592 592
 
593 593
 #if ENABLED(LIN_ADVANCE)
594 594
   #define LIN_ADVANCE_K 75
595
+
596
+  /**
597
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
598
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
599
+   * While this is harmless for normal printing (the fluid nature of the filament will
600
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
601
+   *
602
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
603
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
604
+   * if the slicer is using variable widths or layer heights within one print!
605
+   *
606
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
607
+   *
608
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
609
+   *   - W is the extrusion width in mm
610
+   *   - H is the layer height in mm
611
+   *   - D is the filament diameter in mm
612
+   *
613
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
614
+   *
615
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
616
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
617
+   */
618
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
619
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
595 620
 #endif
596 621
 
597 622
 // @section leveling

+ 35
- 1
Marlin/Marlin_main.cpp View File

@@ -7601,7 +7601,41 @@ inline void gcode_M503() {
7601 7601
    */
7602 7602
   inline void gcode_M905() {
7603 7603
     stepper.synchronize();
7604
-    planner.advance_M905(code_seen('K') ? code_value_float() : -1.0);
7604
+    
7605
+    float newD = -1;
7606
+    float newW = -1;
7607
+    float newH = -1;
7608
+    
7609
+    if (code_seen('K')) {
7610
+      float newK = code_value_float();
7611
+      if (newK >= 0.0)
7612
+        planner.set_extruder_advance_k(newK);
7613
+    }
7614
+
7615
+    SERIAL_ECHO_START;
7616
+    SERIAL_ECHOPAIR("Advance factor: ", planner.get_extruder_advance_k());
7617
+    SERIAL_EOL;
7618
+    
7619
+    if (code_seen('D'))
7620
+      newD = code_value_float();
7621
+    if (code_seen('W'))
7622
+      newW = code_value_float();
7623
+    if (code_seen('H'))
7624
+      newH = code_value_float();
7625
+
7626
+    if (newD > 0 && newW > 0 && newH > 0) {
7627
+      float E_D_ratio = newW * newH / (sq(newD / 2) * M_PI);
7628
+      planner.set_E_D_ratio(E_D_ratio);
7629
+      SERIAL_ECHO_START;
7630
+      SERIAL_ECHOPAIR("E/D ratio: ", E_D_ratio);
7631
+      SERIAL_EOL;
7632
+    }
7633
+    else if (newD != -1 || newW != -1 || newH != -1) {
7634
+      planner.set_E_D_ratio(0);
7635
+      SERIAL_ECHO_START;
7636
+      SERIAL_ECHOPGM("E/D ratio: Automatic");
7637
+      SERIAL_EOL;
7638
+    }
7605 7639
   }
7606 7640
 #endif
7607 7641
 

+ 25
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -572,6 +572,31 @@
572 572
 
573 573
 #if ENABLED(LIN_ADVANCE)
574 574
   #define LIN_ADVANCE_K 75
575
+
576
+  /**
577
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
578
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
579
+   * While this is harmless for normal printing (the fluid nature of the filament will
580
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
581
+   *
582
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
583
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
584
+   * if the slicer is using variable widths or layer heights within one print!
585
+   *
586
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
587
+   *
588
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
589
+   *   - W is the extrusion width in mm
590
+   *   - H is the layer height in mm
591
+   *   - D is the filament diameter in mm
592
+   *
593
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
594
+   *
595
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
596
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
597
+   */
598
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
599
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
575 600
 #endif
576 601
 
577 602
 // @section leveling

+ 25
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -602,6 +602,31 @@
602 602
 
603 603
 #if ENABLED(LIN_ADVANCE)
604 604
   #define LIN_ADVANCE_K 140 // start value for PLA on K8200
605
+
606
+  /**
607
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
608
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
609
+   * While this is harmless for normal printing (the fluid nature of the filament will
610
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
611
+   *
612
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
613
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
614
+   * if the slicer is using variable widths or layer heights within one print!
615
+   *
616
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
617
+   *
618
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
619
+   *   - W is the extrusion width in mm
620
+   *   - H is the layer height in mm
621
+   *   - D is the filament diameter in mm
622
+   *
623
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
624
+   *
625
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
626
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
627
+   */
628
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
629
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
605 630
 #endif
606 631
 
607 632
 // @section leveling

+ 25
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -597,6 +597,31 @@
597 597
 
598 598
 #if ENABLED(LIN_ADVANCE)
599 599
   #define LIN_ADVANCE_K 75
600
+
601
+  /**
602
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
603
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
604
+   * While this is harmless for normal printing (the fluid nature of the filament will
605
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
606
+   *
607
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
608
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
609
+   * if the slicer is using variable widths or layer heights within one print!
610
+   *
611
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
612
+   *
613
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
614
+   *   - W is the extrusion width in mm
615
+   *   - H is the layer height in mm
616
+   *   - D is the filament diameter in mm
617
+   *
618
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
619
+   *
620
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
621
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
622
+   */
623
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
624
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
600 625
 #endif
601 626
 
602 627
 // @section leveling

+ 25
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -591,6 +591,31 @@
591 591
 
592 592
 #if ENABLED(LIN_ADVANCE)
593 593
   #define LIN_ADVANCE_K 75
594
+
595
+  /**
596
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
597
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
598
+   * While this is harmless for normal printing (the fluid nature of the filament will
599
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
600
+   *
601
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
602
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
603
+   * if the slicer is using variable widths or layer heights within one print!
604
+   *
605
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
606
+   *
607
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
608
+   *   - W is the extrusion width in mm
609
+   *   - H is the layer height in mm
610
+   *   - D is the filament diameter in mm
611
+   *
612
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
613
+   *
614
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
615
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
616
+   */
617
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
618
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
594 619
 #endif
595 620
 
596 621
 // @section leveling

+ 25
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -591,6 +591,31 @@
591 591
 
592 592
 #if ENABLED(LIN_ADVANCE)
593 593
   #define LIN_ADVANCE_K 75
594
+
595
+  /**
596
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
597
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
598
+   * While this is harmless for normal printing (the fluid nature of the filament will
599
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
600
+   *
601
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
602
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
603
+   * if the slicer is using variable widths or layer heights within one print!
604
+   *
605
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
606
+   *
607
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
608
+   *   - W is the extrusion width in mm
609
+   *   - H is the layer height in mm
610
+   *   - D is the filament diameter in mm
611
+   *
612
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
613
+   *
614
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
615
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
616
+   */
617
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
618
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
594 619
 #endif
595 620
 
596 621
 // @section leveling

+ 25
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -596,6 +596,31 @@
596 596
 
597 597
 #if ENABLED(LIN_ADVANCE)
598 598
   #define LIN_ADVANCE_K 75
599
+
600
+  /**
601
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
602
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
603
+   * While this is harmless for normal printing (the fluid nature of the filament will
604
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
605
+   *
606
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
607
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
608
+   * if the slicer is using variable widths or layer heights within one print!
609
+   *
610
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
611
+   *
612
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
613
+   *   - W is the extrusion width in mm
614
+   *   - H is the layer height in mm
615
+   *   - D is the filament diameter in mm
616
+   *
617
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
618
+   *
619
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
620
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
621
+   */
622
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
623
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
599 624
 #endif
600 625
 
601 626
 // @section leveling

+ 25
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -591,6 +591,31 @@
591 591
 
592 592
 #if ENABLED(LIN_ADVANCE)
593 593
   #define LIN_ADVANCE_K 75
594
+
595
+  /**
596
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
597
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
598
+   * While this is harmless for normal printing (the fluid nature of the filament will
599
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
600
+   *
601
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
602
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
603
+   * if the slicer is using variable widths or layer heights within one print!
604
+   *
605
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
606
+   *
607
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
608
+   *   - W is the extrusion width in mm
609
+   *   - H is the layer height in mm
610
+   *   - D is the filament diameter in mm
611
+   *
612
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
613
+   *
614
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
615
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
616
+   */
617
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
618
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
594 619
 #endif
595 620
 
596 621
 // @section leveling

+ 25
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 25
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -589,6 +589,31 @@
589 589
 
590 590
 #if ENABLED(LIN_ADVANCE)
591 591
   #define LIN_ADVANCE_K 75
592
+
593
+  /**
594
+   * Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
595
+   * For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
596
+   * While this is harmless for normal printing (the fluid nature of the filament will
597
+   * close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
598
+   *
599
+   * For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
600
+   * to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
601
+   * if the slicer is using variable widths or layer heights within one print!
602
+   *
603
+   * This option sets the default E:D ratio at startup. Use `M905` to override this value.
604
+   *
605
+   * Example: `M905 W0.4 H0.2 D1.75`, where:
606
+   *   - W is the extrusion width in mm
607
+   *   - H is the layer height in mm
608
+   *   - D is the filament diameter in mm
609
+   *
610
+   * Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
611
+   *
612
+   * Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
613
+   * Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
614
+   */
615
+  #define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
616
+                                  // Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
592 617
 #endif
593 618
 
594 619
 // @section leveling

+ 10
- 13
Marlin/planner.cpp View File

@@ -142,6 +142,7 @@ float Planner::previous_speed[NUM_AXIS],
142 142
 
143 143
 #if ENABLED(LIN_ADVANCE)
144 144
   float Planner::extruder_advance_k = LIN_ADVANCE_K,
145
+        Planner::E_D_ratio = LIN_ADVANCE_E_D_RATIO,
145 146
         Planner::position_float[NUM_AXIS] = { 0 };
146 147
 #endif
147 148
 
@@ -1323,8 +1324,15 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1323 1324
                             && extruder_advance_k
1324 1325
                             && (uint32_t)esteps != block->step_event_count
1325 1326
                             && de_float > 0.0;
1326
-    if (block->use_advance_lead)
1327
-      block->abs_adv_steps_multiplier8 = lround(extruder_advance_k * (de_float / mm_D_float) * block->nominal_speed / (float)block->nominal_rate * axis_steps_per_mm[E_AXIS_N] * 256.0);
1327
+    if (block->use_advance_lead) {
1328
+      // Check if we should use the fixed E_D_ratio
1329
+      if (UNEAR_ZERO(E_D_ratio)) {
1330
+        block->abs_adv_steps_multiplier8 = lround(extruder_advance_k * (de_float / mm_D_float) * block->nominal_speed / (float)block->nominal_rate * axis_steps_per_mm[E_AXIS_N] * 256.0);
1331
+      }
1332
+      else {
1333
+        block->abs_adv_steps_multiplier8 = lround(extruder_advance_k * E_D_ratio * block->nominal_speed / (float)block->nominal_rate * axis_steps_per_mm[E_AXIS_N] * 256.0);
1334
+      }
1335
+    }
1328 1336
 
1329 1337
   #elif ENABLED(ADVANCE)
1330 1338
 
@@ -1478,14 +1486,3 @@ void Planner::refresh_positioning() {
1478 1486
   }
1479 1487
 
1480 1488
 #endif
1481
-
1482
-#if ENABLED(LIN_ADVANCE)
1483
-
1484
-  void Planner::advance_M905(const float &k) {
1485
-    if (k >= 0.0) extruder_advance_k = k;
1486
-    SERIAL_ECHO_START;
1487
-    SERIAL_ECHOPAIR("Advance factor: ", extruder_advance_k);
1488
-    SERIAL_EOL;
1489
-  }
1490
-
1491
-#endif

+ 4
- 1
Marlin/planner.h View File

@@ -210,6 +210,7 @@ class Planner {
210 210
     #if ENABLED(LIN_ADVANCE)
211 211
       static float position_float[NUM_AXIS];
212 212
       static float extruder_advance_k;
213
+      static float E_D_ratio;
213 214
     #endif
214 215
 
215 216
     #if ENABLED(ULTRA_LCD)
@@ -266,7 +267,9 @@ class Planner {
266 267
     #endif
267 268
 
268 269
     #if ENABLED(LIN_ADVANCE)
269
-      void advance_M905(const float &k);
270
+      static void set_extruder_advance_k(const float &k) { extruder_advance_k = k; };
271
+      static float get_extruder_advance_k() { return extruder_advance_k; };
272
+      static void set_E_D_ratio(const float &ratio) { E_D_ratio = ratio; };
270 273
     #endif
271 274
 
272 275
     /**

Loading…
Cancel
Save