Browse Source

Make flow correction optional, disabled by default

If you're using flow to correct for an incorrect source diameter, which
is probably the main usage when using the LCD, then LA shouldn't be
adjusted.

It's still unclear what the effect of M221 in gcode should be regarding
overall extrusion width. If M221 means "thicker lines", then LA should
also be adjusted accordingly.

This stems from the fact that the source diameter/length needs to be
known in order to determine a compression factor which is independent of
the extrusion width, but the FW only ever sees one value currently (the
extrusion length) which combines both.

This makes it impossible for the FW to adjust for one OR the other
scenario, depending on what you expect for M221 to mean.
Yuri D'Elia 3 years ago
parent
commit
a08ca19ade
2 changed files with 13 additions and 4 deletions
  1. 1 0
      Firmware/Configuration_adv.h
  2. 12 4
      Firmware/planner.cpp

+ 1 - 0
Firmware/Configuration_adv.h

@@ -288,6 +288,7 @@
   #define LA_K_DEF    0        // Default K factor (Unit: mm compression per 1mm/s extruder speed)
   #define LA_K_MAX    10       // Maximum acceptable K factor (exclusive, see notes in planner.cpp:plan_buffer_line)
   #define LA_LA10_MIN LA_K_MAX // Lin. Advance 1.0 threshold value (inclusive)
+  //#define LA_FLOWADJ         // Adjust LA along with flow/M221 for uniform width
   //#define LA_NOCOMPAT        // Disable Linear Advance 1.0 compatibility
   //#define LA_LIVE_K          // Allow adjusting K in the Tune menu
   //#define LA_DEBUG           // If enabled, this will generate debug information output over USB.

+ 12 - 4
Firmware/planner.cpp

@@ -1096,12 +1096,20 @@ Having the real displacement of the head, we can calculate the total movement le
                               && delta_mm[E_AXIS] >= 0
                               && abs(delta_mm[Z_AXIS]) < 0.5;
     if (block->use_advance_lead) {
+#ifdef LA_FLOWADJ
+        // M221/FLOW should change uniformly the extrusion thickness
+        float delta_e = (e - position_float[E_AXIS]) / extruder_multiplier[extruder];
+#else
+        // M221/FLOW only adjusts for an incorrect source diameter
+        float delta_e = (e - position_float[E_AXIS]);
+#endif
+        float delta_D = sqrt(sq(x - position_float[X_AXIS])
+                             + sq(y - position_float[Y_AXIS])
+                             + sq(z - position_float[Z_AXIS]));
+
         // all extrusion moves with LA require a compression which is proportional to the
         // extrusion_length to distance ratio (e/D)
-        e_D_ratio = ((e - position_float[E_AXIS]) / extruder_multiplier[extruder]) /
-                    sqrt(sq(x - position_float[X_AXIS])
-                         + sq(y - position_float[Y_AXIS])
-                         + sq(z - position_float[Z_AXIS]));
+        e_D_ratio = delta_e / delta_D;
 
         // Check for unusual high e_D ratio to detect if a retract move was combined with the last
         // print move due to min. steps per segment. Never execute this with advance! This assumes