소스 검색

Merge pull request #8357 from tcm0116/1.1.x-M600

[1.1.x] Normalize load/unload length in M600
Scott Lahteine 6 년 전
부모
커밋
972248c333
No account linked to committer's email address
12개의 변경된 파일146개의 추가작업 그리고 129개의 파일을 삭제
  1. 0
    6
      Marlin/Marlin.h
  2. 29
    47
      Marlin/Marlin_main.cpp
  3. 19
    22
      Marlin/configuration_store.cpp
  4. 2
    0
      Marlin/gcode.cpp
  5. 2
    4
      Marlin/gcode.h
  6. 36
    16
      Marlin/planner.cpp
  7. 13
    0
      Marlin/planner.h
  8. 2
    1
      Marlin/temperature.cpp
  9. 8
    15
      Marlin/ubl_G29.cpp
  10. 32
    15
      Marlin/ultralcd.cpp
  11. 2
    2
      Marlin/ultralcd_impl_DOGM.h
  12. 1
    1
      Marlin/ultralcd_impl_HD44780.h

+ 0
- 6
Marlin/Marlin.h 파일 보기

@@ -215,10 +215,6 @@ extern int16_t feedrate_percentage;
215 215
 #define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01)
216 216
 
217 217
 extern bool axis_relative_modes[];
218
-extern bool volumetric_enabled;
219
-extern int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
220
-extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
221
-extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
222 218
 extern bool axis_known_position[XYZ];
223 219
 extern bool axis_homed[XYZ];
224 220
 extern volatile bool wait_for_heatup;
@@ -427,8 +423,6 @@ extern uint8_t active_extruder;
427 423
   extern float mixing_factor[MIXING_STEPPERS];
428 424
 #endif
429 425
 
430
-void calculate_volumetric_multipliers();
431
-
432 426
 /**
433 427
  * Blocking movement and shorthand functions
434 428
  */

+ 29
- 47
Marlin/Marlin_main.cpp 파일 보기

@@ -452,13 +452,10 @@ FORCE_INLINE float homing_feedrate(const AxisEnum a) { return pgm_read_float(&ho
452 452
 
453 453
 float feedrate_mm_s = MMM_TO_MMS(1500.0);
454 454
 static float saved_feedrate_mm_s;
455
-int16_t feedrate_percentage = 100, saved_feedrate_percentage,
456
-    flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100);
455
+int16_t feedrate_percentage = 100, saved_feedrate_percentage;
457 456
 
458 457
 // Initialized by settings.load()
459
-bool axis_relative_modes[] = AXIS_RELATIVE_MODES,
460
-     volumetric_enabled;
461
-float filament_size[EXTRUDERS], volumetric_multiplier[EXTRUDERS];
458
+bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
462 459
 
463 460
 #if HAS_WORKSPACE_OFFSET
464 461
   #if HAS_POSITION_SHIFT
@@ -2417,17 +2414,8 @@ static void clean_up_after_endstop_or_probe_move() {
2417 2414
       : !position_is_reachable_by_probe(rx, ry)
2418 2415
     ) return NAN;
2419 2416
 
2420
-    const float old_feedrate_mm_s = feedrate_mm_s;
2421
-
2422
-    #if ENABLED(DELTA)
2423
-      if (current_position[Z_AXIS] > delta_clip_start_height)
2424
-        do_blocking_move_to_z(delta_clip_start_height);
2425
-    #endif
2426
-
2427
-    feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
2428
-
2429 2417
     // Move the probe to the given XY
2430
-    do_blocking_move_to_xy(nx, ny);
2418
+    do_blocking_move_to_xy(nx, ny, XY_PROBE_FEEDRATE_MM_S);
2431 2419
 
2432 2420
     float measured_z = NAN;
2433 2421
     if (!DEPLOY_PROBE()) {
@@ -2453,8 +2441,6 @@ static void clean_up_after_endstop_or_probe_move() {
2453 2441
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< probe_pt");
2454 2442
     #endif
2455 2443
 
2456
-    feedrate_mm_s = old_feedrate_mm_s;
2457
-
2458 2444
     if (isnan(measured_z)) {
2459 2445
       LCD_MESSAGEPGM(MSG_ERR_PROBING_FAILED);
2460 2446
       SERIAL_ERROR_START();
@@ -3226,7 +3212,7 @@ static void homeaxis(const AxisEnum axis) {
3226 3212
     set_destination_from_current();
3227 3213
     stepper.synchronize();  // Wait for buffered moves to complete
3228 3214
 
3229
-    const float renormalize = 100.0 / flow_percentage[active_extruder] / volumetric_multiplier[active_extruder];
3215
+    const float renormalize = 1.0 / planner.e_factor[active_extruder];
3230 3216
 
3231 3217
     if (retracting) {
3232 3218
       // Retract by moving from a faux E position back to the current E position
@@ -6553,7 +6539,7 @@ inline void gcode_M17() {
6553 6539
   #endif
6554 6540
 
6555 6541
   void do_pause_e_move(const float &length, const float fr) {
6556
-    current_position[E_AXIS] += length;
6542
+    current_position[E_AXIS] += length / planner.e_factor[active_extruder];
6557 6543
     set_destination_from_current();
6558 6544
     RUNPLAN(fr);
6559 6545
     stepper.synchronize();
@@ -8832,15 +8818,14 @@ inline void gcode_M200() {
8832 8818
     // setting any extruder filament size disables volumetric on the assumption that
8833 8819
     // slicers either generate in extruder values as cubic mm or as as filament feeds
8834 8820
     // for all extruders
8835
-    volumetric_enabled = (parser.value_linear_units() != 0.0);
8836
-    if (volumetric_enabled) {
8837
-      filament_size[target_extruder] = parser.value_linear_units();
8821
+    if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) ) {
8822
+      planner.filament_size[target_extruder] = parser.value_linear_units();
8838 8823
       // make sure all extruders have some sane value for the filament size
8839
-      for (uint8_t i = 0; i < COUNT(filament_size); i++)
8840
-        if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
8824
+      for (uint8_t i = 0; i < COUNT(planner.filament_size); i++)
8825
+        if (!planner.filament_size[i]) planner.filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
8841 8826
     }
8842 8827
   }
8843
-  calculate_volumetric_multipliers();
8828
+  planner.calculate_volumetric_multipliers();
8844 8829
 }
8845 8830
 
8846 8831
 /**
@@ -9201,8 +9186,10 @@ inline void gcode_M220() {
9201 9186
  */
9202 9187
 inline void gcode_M221() {
9203 9188
   if (get_target_extruder_from_command(221)) return;
9204
-  if (parser.seenval('S'))
9205
-    flow_percentage[target_extruder] = parser.value_int();
9189
+  if (parser.seenval('S')) {
9190
+    planner.flow_percentage[target_extruder] = parser.value_int();
9191
+    planner.refresh_e_factor(target_extruder);
9192
+  }
9206 9193
 }
9207 9194
 
9208 9195
 /**
@@ -9735,7 +9722,7 @@ inline void gcode_M400() { stepper.synchronize(); }
9735 9722
     //SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
9736 9723
     //SERIAL_PROTOCOL(filament_width_meas);
9737 9724
     //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
9738
-    //SERIAL_PROTOCOL(flow_percentage[active_extruder]);
9725
+    //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
9739 9726
   }
9740 9727
 
9741 9728
   /**
@@ -9743,7 +9730,7 @@ inline void gcode_M400() { stepper.synchronize(); }
9743 9730
    */
9744 9731
   inline void gcode_M406() {
9745 9732
     filament_sensor = false;
9746
-    calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
9733
+    planner.calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
9747 9734
   }
9748 9735
 
9749 9736
   /**
@@ -12947,27 +12934,32 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12947 12934
  *
12948 12935
  * This may result in several calls to planner.buffer_line to
12949 12936
  * do smaller moves for DELTA, SCARA, mesh moves, etc.
12937
+ *
12938
+ * Make sure current_position[E] and destination[E] are good
12939
+ * before calling or cold/lengthy extrusion may get missed.
12950 12940
  */
12951 12941
 void prepare_move_to_destination() {
12952 12942
   clamp_to_software_endstops(destination);
12953 12943
   refresh_cmd_timeout();
12954 12944
 
12955
-  #if ENABLED(PREVENT_COLD_EXTRUSION)
12945
+  #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
12956 12946
 
12957 12947
     if (!DEBUGGING(DRYRUN)) {
12958 12948
       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
-        }
12949
+        #if ENABLED(PREVENT_COLD_EXTRUSION)
12950
+          if (thermalManager.tooColdToExtrude(active_extruder)) {
12951
+            current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12952
+            SERIAL_ECHO_START();
12953
+            SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
12954
+          }
12955
+        #endif // PREVENT_COLD_EXTRUSION
12964 12956
         #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
12965
-          if (destination[E_AXIS] - current_position[E_AXIS] > EXTRUDE_MAXLENGTH) {
12957
+          if (FABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder] > (EXTRUDE_MAXLENGTH)) {
12966 12958
             current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12967 12959
             SERIAL_ECHO_START();
12968 12960
             SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
12969 12961
           }
12970
-        #endif
12962
+        #endif // PREVENT_LENGTHY_EXTRUDE
12971 12963
       }
12972 12964
     }
12973 12965
 
@@ -13382,16 +13374,6 @@ void prepare_move_to_destination() {
13382 13374
 
13383 13375
 #endif // FAST_PWM_FAN
13384 13376
 
13385
-float calculate_volumetric_multiplier(const float diameter) {
13386
-  if (!volumetric_enabled || diameter == 0) return 1.0;
13387
-  return 1.0 / (M_PI * sq(diameter * 0.5));
13388
-}
13389
-
13390
-void calculate_volumetric_multipliers() {
13391
-  for (uint8_t i = 0; i < COUNT(filament_size); i++)
13392
-    volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
13393
-}
13394
-
13395 13377
 void enable_all_steppers() {
13396 13378
   enable_X();
13397 13379
   enable_Y();

+ 19
- 22
Marlin/configuration_store.cpp 파일 보기

@@ -138,8 +138,8 @@
138 138
  *  533  M208 R    swap_retract_recover_feedrate_mm_s (float)
139 139
  *
140 140
  * Volumetric Extrusion:                            21 bytes
141
- *  537  M200 D    volumetric_enabled               (bool)
142
- *  538  M200 T D  filament_size                    (float x5) (T0..3)
141
+ *  537  M200 D    parser.volumetric_enabled        (bool)
142
+ *  538  M200 T D  planner.filament_size            (float x5) (T0..3)
143 143
  *
144 144
  * HAVE_TMC2130:                                    22 bytes
145 145
  *  558  M906 X    Stepper X current                (uint16_t)
@@ -188,10 +188,7 @@ MarlinSettings settings;
188 188
 #include "temperature.h"
189 189
 #include "ultralcd.h"
190 190
 #include "stepper.h"
191
-
192
-#if ENABLED(INCH_MODE_SUPPORT) || (ENABLED(ULTIPANEL) && ENABLED(TEMPERATURE_UNITS_SUPPORT))
193
-  #include "gcode.h"
194
-#endif
191
+#include "gcode.h"
195 192
 
196 193
 #if ENABLED(MESH_BED_LEVELING)
197 194
   #include "mesh_bed_leveling.h"
@@ -238,7 +235,7 @@ void MarlinSettings::postprocess() {
238 235
     thermalManager.updatePID();
239 236
   #endif
240 237
 
241
-  calculate_volumetric_multipliers();
238
+  planner.calculate_volumetric_multipliers();
242 239
 
243 240
   #if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE)
244 241
     // Software endstops depend on home_offset
@@ -569,11 +566,11 @@ void MarlinSettings::postprocess() {
569 566
     EEPROM_WRITE(swap_retract_recover_length);
570 567
     EEPROM_WRITE(swap_retract_recover_feedrate_mm_s);
571 568
 
572
-    EEPROM_WRITE(volumetric_enabled);
569
+    EEPROM_WRITE(parser.volumetric_enabled);
573 570
 
574 571
     // Save filament sizes
575 572
     for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
576
-      if (q < COUNT(filament_size)) dummy = filament_size[q];
573
+      if (q < COUNT(planner.filament_size)) dummy = planner.filament_size[q];
577 574
       EEPROM_WRITE(dummy);
578 575
     }
579 576
 
@@ -1018,10 +1015,10 @@ void MarlinSettings::postprocess() {
1018 1015
       // Volumetric & Filament Size
1019 1016
       //
1020 1017
 
1021
-      EEPROM_READ(volumetric_enabled);
1018
+      EEPROM_READ(parser.volumetric_enabled);
1022 1019
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
1023 1020
         EEPROM_READ(dummy);
1024
-        if (q < COUNT(filament_size)) filament_size[q] = dummy;
1021
+        if (q < COUNT(planner.filament_size)) planner.filament_size[q] = dummy;
1025 1022
       }
1026 1023
 
1027 1024
       //
@@ -1424,15 +1421,15 @@ void MarlinSettings::reset() {
1424 1421
     swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
1425 1422
   #endif // FWRETRACT
1426 1423
 
1427
-  volumetric_enabled =
1424
+  parser.volumetric_enabled =
1428 1425
     #if ENABLED(VOLUMETRIC_DEFAULT_ON)
1429 1426
       true
1430 1427
     #else
1431 1428
       false
1432 1429
     #endif
1433 1430
   ;
1434
-  for (uint8_t q = 0; q < COUNT(filament_size); q++)
1435
-    filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
1431
+  for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
1432
+    planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
1436 1433
 
1437 1434
   endstops.enable_globally(
1438 1435
     #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
@@ -1515,7 +1512,7 @@ void MarlinSettings::reset() {
1515 1512
     CONFIG_ECHO_START;
1516 1513
     #if ENABLED(INCH_MODE_SUPPORT)
1517 1514
       #define LINEAR_UNIT(N) ((N) / parser.linear_unit_factor)
1518
-      #define VOLUMETRIC_UNIT(N) ((N) / (volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
1515
+      #define VOLUMETRIC_UNIT(N) ((N) / (parser.volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
1519 1516
       SERIAL_ECHOPGM("  G2");
1520 1517
       SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0');
1521 1518
       SERIAL_ECHOPGM(" ; Units in ");
@@ -1552,37 +1549,37 @@ void MarlinSettings::reset() {
1552 1549
     if (!forReplay) {
1553 1550
       CONFIG_ECHO_START;
1554 1551
       SERIAL_ECHOPGM("Filament settings:");
1555
-      if (volumetric_enabled)
1552
+      if (parser.volumetric_enabled)
1556 1553
         SERIAL_EOL();
1557 1554
       else
1558 1555
         SERIAL_ECHOLNPGM(" Disabled");
1559 1556
     }
1560 1557
 
1561 1558
     CONFIG_ECHO_START;
1562
-    SERIAL_ECHOPAIR("  M200 D", filament_size[0]);
1559
+    SERIAL_ECHOPAIR("  M200 D", planner.filament_size[0]);
1563 1560
     SERIAL_EOL();
1564 1561
     #if EXTRUDERS > 1
1565 1562
       CONFIG_ECHO_START;
1566
-      SERIAL_ECHOPAIR("  M200 T1 D", filament_size[1]);
1563
+      SERIAL_ECHOPAIR("  M200 T1 D", planner.filament_size[1]);
1567 1564
       SERIAL_EOL();
1568 1565
       #if EXTRUDERS > 2
1569 1566
         CONFIG_ECHO_START;
1570
-        SERIAL_ECHOPAIR("  M200 T2 D", filament_size[2]);
1567
+        SERIAL_ECHOPAIR("  M200 T2 D", planner.filament_size[2]);
1571 1568
         SERIAL_EOL();
1572 1569
         #if EXTRUDERS > 3
1573 1570
           CONFIG_ECHO_START;
1574
-          SERIAL_ECHOPAIR("  M200 T3 D", filament_size[3]);
1571
+          SERIAL_ECHOPAIR("  M200 T3 D", planner.filament_size[3]);
1575 1572
           SERIAL_EOL();
1576 1573
           #if EXTRUDERS > 4
1577 1574
             CONFIG_ECHO_START;
1578
-            SERIAL_ECHOPAIR("  M200 T4 D", filament_size[4]);
1575
+            SERIAL_ECHOPAIR("  M200 T4 D", planner.filament_size[4]);
1579 1576
             SERIAL_EOL();
1580 1577
           #endif // EXTRUDERS > 4
1581 1578
         #endif // EXTRUDERS > 3
1582 1579
       #endif // EXTRUDERS > 2
1583 1580
     #endif // EXTRUDERS > 1
1584 1581
 
1585
-    if (!volumetric_enabled) {
1582
+    if (!parser.volumetric_enabled) {
1586 1583
       CONFIG_ECHO_START;
1587 1584
       SERIAL_ECHOLNPGM("  M200 D0");
1588 1585
     }

+ 2
- 0
Marlin/gcode.cpp 파일 보기

@@ -32,6 +32,8 @@
32 32
 // Must be declared for allocation and to satisfy the linker
33 33
 // Zero values need no initialization.
34 34
 
35
+bool GCodeParser::volumetric_enabled;
36
+
35 37
 #if ENABLED(INCH_MODE_SUPPORT)
36 38
   float GCodeParser::linear_unit_factor, GCodeParser::volumetric_unit_factor;
37 39
 #endif

+ 2
- 4
Marlin/gcode.h 파일 보기

@@ -44,10 +44,6 @@
44 44
   #include "serial.h"
45 45
 #endif
46 46
 
47
-#if ENABLED(INCH_MODE_SUPPORT)
48
-  extern bool volumetric_enabled;
49
-#endif
50
-
51 47
 /**
52 48
  * GCode parser
53 49
  *
@@ -76,6 +72,8 @@ public:
76 72
 
77 73
   // Global states for GCode-level units features
78 74
 
75
+  static bool volumetric_enabled;
76
+
79 77
   #if ENABLED(INCH_MODE_SUPPORT)
80 78
     static float linear_unit_factor, volumetric_unit_factor;
81 79
   #endif

+ 36
- 16
Marlin/planner.cpp 파일 보기

@@ -91,6 +91,12 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
91 91
   uint8_t Planner::last_extruder = 0;     // Respond to extruder change
92 92
 #endif
93 93
 
94
+int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
95
+
96
+float Planner::e_factor[EXTRUDERS],               // The flow percentage and volumetric multiplier combine to scale E movement
97
+      Planner::filament_size[EXTRUDERS],          // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
98
+      Planner::volumetric_multiplier[EXTRUDERS];  // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
99
+
94 100
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
95 101
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
96 102
 
@@ -521,6 +527,18 @@ void Planner::check_axes_activity() {
521 527
   #endif
522 528
 }
523 529
 
530
+inline float calculate_volumetric_multiplier(const float &diameter) {
531
+  if (!parser.volumetric_enabled || diameter == 0) return 1.0;
532
+  return 1.0 / CIRCLE_AREA(diameter * 0.5);
533
+}
534
+
535
+void Planner::calculate_volumetric_multipliers() {
536
+  for (uint8_t i = 0; i < COUNT(filament_size); i++) {
537
+    volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
538
+    refresh_e_factor(i);
539
+  }
540
+}
541
+
524 542
 #if PLANNER_LEVELING
525 543
   /**
526 544
    * rx, ry, rz - cartesian position in mm
@@ -720,23 +738,25 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
720 738
   long de = target[E_AXIS] - position[E_AXIS];
721 739
 
722 740
   #if ENABLED(LIN_ADVANCE)
723
-    float de_float = e - position_float[E_AXIS];
741
+    float de_float = e - position_float[E_AXIS]; // Should this include e_factor?
724 742
   #endif
725 743
 
726
-  #if ENABLED(PREVENT_COLD_EXTRUSION)
744
+  #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
727 745
     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
-      }
746
+      #if ENABLED(PREVENT_COLD_EXTRUSION)
747
+        if (thermalManager.tooColdToExtrude(extruder)) {
748
+          position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
749
+          de = 0; // no difference
750
+          #if ENABLED(LIN_ADVANCE)
751
+            position_float[E_AXIS] = e;
752
+            de_float = 0;
753
+          #endif
754
+          SERIAL_ECHO_START();
755
+          SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
756
+        }
757
+      #endif // PREVENT_COLD_EXTRUSION
738 758
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
739
-        if (labs(de) > (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
759
+        if (labs(de * e_factor[extruder]) > (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
740 760
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
741 761
           de = 0; // no difference
742 762
           #if ENABLED(LIN_ADVANCE)
@@ -746,9 +766,9 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
746 766
           SERIAL_ECHO_START();
747 767
           SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
748 768
         }
749
-      #endif
769
+      #endif // PREVENT_LENGTHY_EXTRUDE
750 770
     }
751
-  #endif
771
+  #endif // PREVENT_COLD_EXTRUSION || PREVENT_LENGTHY_EXTRUDE
752 772
 
753 773
   // Compute direction bit-mask for this block
754 774
   uint8_t dm = 0;
@@ -777,7 +797,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
777 797
   #endif
778 798
   if (de < 0) SBI(dm, E_AXIS);
779 799
 
780
-  const float esteps_float = de * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01;
800
+  const float esteps_float = de * e_factor[extruder];
781 801
   const int32_t esteps = abs(esteps_float) + 0.5;
782 802
 
783 803
   // Calculate the buffer head after we push this byte

+ 13
- 0
Marlin/planner.h 파일 보기

@@ -140,6 +140,13 @@ class Planner {
140 140
       static uint8_t last_extruder;             // Respond to extruder change
141 141
     #endif
142 142
 
143
+    static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
144
+
145
+    static float e_factor[EXTRUDERS],               // The flow percentage and volumetric multiplier combine to scale E movement
146
+                 filament_size[EXTRUDERS],          // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
147
+                 volumetric_multiplier[EXTRUDERS];  // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
148
+                                                    // May be auto-adjusted by a filament width sensor
149
+
143 150
     static float max_feedrate_mm_s[XYZE_N],     // Max speeds in mm per second
144 151
                  axis_steps_per_mm[XYZE_N],
145 152
                  steps_to_mm[XYZE_N];
@@ -236,9 +243,15 @@ class Planner {
236 243
     static void reset_acceleration_rates();
237 244
     static void refresh_positioning();
238 245
 
246
+    FORCE_INLINE static void refresh_e_factor(const uint8_t e) {
247
+      e_factor[e] = volumetric_multiplier[e] * flow_percentage[e] * 0.01;
248
+    }
249
+
239 250
     // Manage fans, paste pressure, etc.
240 251
     static void check_axes_activity();
241 252
 
253
+    static void calculate_volumetric_multipliers();
254
+
242 255
     /**
243 256
      * Number of moves currently in the planner
244 257
      */

+ 2
- 1
Marlin/temperature.cpp 파일 보기

@@ -815,7 +815,8 @@ void Temperature::manage_heater() {
815 815
       // Get the delayed info and add 100 to reconstitute to a percent of
816 816
       // the nominal filament diameter then square it to get an area
817 817
       const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0;
818
-      volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
818
+      planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
819
+      planner.refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
819 820
     }
820 821
   #endif // FILAMENT_WIDTH_SENSOR
821 822
 

+ 8
- 15
Marlin/ubl_G29.cpp 파일 보기

@@ -466,6 +466,7 @@
466 466
             //
467 467
             SERIAL_PROTOCOLLNPGM("Manually probing unreachable mesh locations.");
468 468
             do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
469
+
469 470
             if (!g29_x_flag && !g29_y_flag) {
470 471
               /**
471 472
                * Use a good default location for the path.
@@ -911,8 +912,7 @@
911 912
       has_control_of_lcd_panel = true;
912 913
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
913 914
 
914
-      do_blocking_move_to_z(in_height);
915
-      do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
915
+      do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
916 916
         //, min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
917 917
       stepper.synchronize();
918 918
 
@@ -955,8 +955,7 @@
955 955
       has_control_of_lcd_panel = true;
956 956
 
957 957
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
958
-      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
959
-      do_blocking_move_to_xy(rx, ry);
958
+      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
960 959
 
961 960
       lcd_return_to_status();
962 961
 
@@ -971,11 +970,9 @@
971 970
 
972 971
         if (!position_is_reachable(xProbe, yProbe)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points)
973 972
 
974
-        do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
975
-
976 973
         LCD_MESSAGEPGM(MSG_UBL_MOVING_TO_NEXT);
977 974
 
978
-        do_blocking_move_to_xy(xProbe, yProbe);
975
+        do_blocking_move_to(xProbe, yProbe, Z_CLEARANCE_BETWEEN_PROBES);
979 976
         do_blocking_move_to_z(z_clearance);
980 977
 
981 978
         KEEPALIVE_STATE(PAUSED_FOR_USER);
@@ -1032,8 +1029,7 @@
1032 1029
 
1033 1030
       restore_ubl_active_state_and_leave();
1034 1031
       KEEPALIVE_STATE(IN_HANDLER);
1035
-      do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1036
-      do_blocking_move_to_xy(rx, ry);
1032
+      do_blocking_move_to(rx, ry, Z_CLEARANCE_DEPLOY_PROBE);
1037 1033
     }
1038 1034
   #endif // NEWPANEL
1039 1035
 
@@ -1486,8 +1482,7 @@
1486 1482
 
1487 1483
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1488 1484
 
1489
-      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1490
-      do_blocking_move_to_xy(rx, ry);
1485
+      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
1491 1486
 
1492 1487
       uint16_t not_done[16];
1493 1488
       memset(not_done, 0xFF, sizeof(not_done));
@@ -1510,8 +1505,7 @@
1510 1505
         if (isnan(new_z)) // if the mesh point is invalid, set it to 0.0 so it can be edited
1511 1506
           new_z = 0.0;
1512 1507
 
1513
-        do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);    // Move the nozzle to where we are going to edit
1514
-        do_blocking_move_to_xy(rawx, rawy);
1508
+        do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point
1515 1509
 
1516 1510
         new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1517 1511
 
@@ -1571,9 +1565,8 @@
1571 1565
 
1572 1566
       if (do_ubl_mesh_map) display_map(g29_map_type);
1573 1567
       restore_ubl_active_state_and_leave();
1574
-      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1575 1568
 
1576
-      do_blocking_move_to_xy(rx, ry);
1569
+      do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
1577 1570
 
1578 1571
       LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1579 1572
       SERIAL_ECHOLNPGM("Done Editing Mesh");

+ 32
- 15
Marlin/ultralcd.cpp 파일 보기

@@ -33,6 +33,7 @@
33 33
 #include "stepper.h"
34 34
 #include "configuration_store.h"
35 35
 #include "utility.h"
36
+#include "gcode.h"
36 37
 
37 38
 #if HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER)
38 39
   #include "buzzer.h"
@@ -1248,6 +1249,22 @@ void kill_screen(const char* lcd_msg) {
1248 1249
     #endif
1249 1250
   #endif
1250 1251
 
1252
+  // Refresh the E factor after changing flow
1253
+  inline void _lcd_refresh_e_factor_0() { planner.refresh_e_factor(0); }
1254
+  #if EXTRUDERS > 1
1255
+    inline void _lcd_refresh_e_factor() { planner.refresh_e_factor(active_extruder); }
1256
+    inline void _lcd_refresh_e_factor_1() { planner.refresh_e_factor(1); }
1257
+    #if EXTRUDERS > 2
1258
+      inline void _lcd_refresh_e_factor_2() { planner.refresh_e_factor(2); }
1259
+      #if EXTRUDERS > 3
1260
+        inline void _lcd_refresh_e_factor_3() { planner.refresh_e_factor(3); }
1261
+        #if EXTRUDERS > 4
1262
+          inline void _lcd_refresh_e_factor_4() { planner.refresh_e_factor(4); }
1263
+        #endif // EXTRUDERS > 4
1264
+      #endif // EXTRUDERS > 3
1265
+    #endif // EXTRUDERS > 2
1266
+  #endif // EXTRUDERS > 1
1267
+
1251 1268
   /**
1252 1269
    *
1253 1270
    * "Tune" submenu
@@ -1327,17 +1344,17 @@ void kill_screen(const char* lcd_msg) {
1327 1344
     // Flow [1-5]:
1328 1345
     //
1329 1346
     #if EXTRUDERS == 1
1330
-      MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[0], 10, 999);
1347
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999, _lcd_refresh_e_factor_0);
1331 1348
     #else // EXTRUDERS > 1
1332
-      MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[active_extruder], 10, 999);
1333
-      MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N1, &flow_percentage[0], 10, 999);
1334
-      MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N2, &flow_percentage[1], 10, 999);
1349
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, _lcd_refresh_e_factor);
1350
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N1, &planner.flow_percentage[0], 10, 999, _lcd_refresh_e_factor_0);
1351
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N2, &planner.flow_percentage[1], 10, 999, _lcd_refresh_e_factor_1);
1335 1352
       #if EXTRUDERS > 2
1336
-        MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N3, &flow_percentage[2], 10, 999);
1353
+        MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N3, &planner.flow_percentage[2], 10, 999, _lcd_refresh_e_factor_2);
1337 1354
         #if EXTRUDERS > 3
1338
-          MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N4, &flow_percentage[3], 10, 999);
1355
+          MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N4, &planner.flow_percentage[3], 10, 999, _lcd_refresh_e_factor_3);
1339 1356
           #if EXTRUDERS > 4
1340
-            MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N5, &flow_percentage[4], 10, 999);
1357
+            MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N5, &planner.flow_percentage[4], 10, 999, _lcd_refresh_e_factor_4);
1341 1358
           #endif // EXTRUDERS > 4
1342 1359
         #endif // EXTRUDERS > 3
1343 1360
       #endif // EXTRUDERS > 2
@@ -3678,20 +3695,20 @@ void kill_screen(const char* lcd_msg) {
3678 3695
       MENU_ITEM_EDIT(float3, MSG_ADVANCE_K, &planner.extruder_advance_k, 0, 999);
3679 3696
     #endif
3680 3697
 
3681
-    MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
3698
+    MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
3682 3699
 
3683
-    if (volumetric_enabled) {
3700
+    if (parser.volumetric_enabled) {
3684 3701
       #if EXTRUDERS == 1
3685
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
3702
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3686 3703
       #else // EXTRUDERS > 1
3687
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
3688
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers);
3704
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3705
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3689 3706
         #if EXTRUDERS > 2
3690
-          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers);
3707
+          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3691 3708
           #if EXTRUDERS > 3
3692
-            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers);
3709
+            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3693 3710
             #if EXTRUDERS > 4
3694
-              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &filament_size[4], 1.5, 3.25, calculate_volumetric_multipliers);
3711
+              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3695 3712
             #endif // EXTRUDERS > 4
3696 3713
           #endif // EXTRUDERS > 3
3697 3714
         #endif // EXTRUDERS > 2

+ 2
- 2
Marlin/ultralcd_impl_DOGM.h 파일 보기

@@ -650,7 +650,7 @@ static void lcd_implementation_status_screen() {
650 650
     strcpy(zstring, ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS]))));
651 651
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
652 652
       strcpy(wstring, ftostr12ns(filament_width_meas));
653
-      strcpy(mstring, itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
653
+      strcpy(mstring, itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
654 654
     #endif
655 655
   }
656 656
 
@@ -739,7 +739,7 @@ static void lcd_implementation_status_screen() {
739 739
         lcd_print(ftostr12ns(filament_width_meas));
740 740
         lcd_printPGM(PSTR("  " LCD_STR_FILAM_MUL));
741 741
         u8g.print(':');
742
-        lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
742
+        lcd_print(itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
743 743
         u8g.print('%');
744 744
       }
745 745
     #else

+ 1
- 1
Marlin/ultralcd_impl_HD44780.h 파일 보기

@@ -857,7 +857,7 @@ static void lcd_implementation_status_screen() {
857 857
       lcd_printPGM(PSTR("Dia "));
858 858
       lcd.print(ftostr12ns(filament_width_meas));
859 859
       lcd_printPGM(PSTR(" V"));
860
-      lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
860
+      lcd.print(itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
861 861
       lcd.write('%');
862 862
       return;
863 863
     }

Loading…
취소
저장