Browse Source

Merge pull request #1876 from thinkyhead/cold_extrude

Catch dangerous extrude before trying several
Scott Lahteine 9 years ago
parent
commit
2ca099d1e7
5 changed files with 56 additions and 51 deletions
  1. 2
    2
      Marlin/ConfigurationStore.cpp
  2. 4
    0
      Marlin/Marlin.h
  3. 48
    36
      Marlin/Marlin_main.cpp
  4. 1
    8
      Marlin/planner.cpp
  5. 1
    5
      Marlin/planner.h

+ 2
- 2
Marlin/ConfigurationStore.cpp View File

669
   #ifdef DELTA
669
   #ifdef DELTA
670
     SERIAL_ECHO_START;
670
     SERIAL_ECHO_START;
671
     if (!forReplay) {
671
     if (!forReplay) {
672
-      SERIAL_ECHOLNPGM("Endstop adjustement (mm):");
672
+      SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
673
       SERIAL_ECHO_START;
673
       SERIAL_ECHO_START;
674
     }
674
     }
675
     SERIAL_ECHOPAIR("  M666 X", endstop_adj[X_AXIS] );
675
     SERIAL_ECHOPAIR("  M666 X", endstop_adj[X_AXIS] );
686
   #elif defined(Z_DUAL_ENDSTOPS)
686
   #elif defined(Z_DUAL_ENDSTOPS)
687
     SERIAL_ECHO_START;
687
     SERIAL_ECHO_START;
688
     if (!forReplay) {
688
     if (!forReplay) {
689
-      SERIAL_ECHOLNPGM("Z2 Endstop adjustement (mm):");
689
+      SERIAL_ECHOLNPGM("Z2 Endstop adjustment (mm):");
690
       SERIAL_ECHO_START;
690
       SERIAL_ECHO_START;
691
     }
691
     }
692
     SERIAL_ECHOPAIR("  M666 Z", z_endstop_adj );
692
     SERIAL_ECHOPAIR("  M666 Z", z_endstop_adj );

+ 4
- 0
Marlin/Marlin.h View File

273
   extern float zprobe_zoffset;
273
   extern float zprobe_zoffset;
274
 #endif
274
 #endif
275
 
275
 
276
+#ifdef PREVENT_DANGEROUS_EXTRUDE
277
+  extern float extrude_min_temp;
278
+#endif
279
+
276
 extern int fanSpeed;
280
 extern int fanSpeed;
277
 
281
 
278
 #ifdef BARICUDA
282
 #ifdef BARICUDA

+ 48
- 36
Marlin/Marlin_main.cpp View File

380
 void get_arc_coordinates();
380
 void get_arc_coordinates();
381
 bool setTargetedHotend(int code);
381
 bool setTargetedHotend(int code);
382
 
382
 
383
-void serial_echopair_P(const char *s_P, float v)
384
-    { serialprintPGM(s_P); SERIAL_ECHO(v); }
385
-void serial_echopair_P(const char *s_P, double v)
386
-    { serialprintPGM(s_P); SERIAL_ECHO(v); }
387
-void serial_echopair_P(const char *s_P, unsigned long v)
388
-    { serialprintPGM(s_P); SERIAL_ECHO(v); }
383
+void serial_echopair_P(const char *s_P, float v)         { serialprintPGM(s_P); SERIAL_ECHO(v); }
384
+void serial_echopair_P(const char *s_P, double v)        { serialprintPGM(s_P); SERIAL_ECHO(v); }
385
+void serial_echopair_P(const char *s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
386
+
387
+#ifdef PREVENT_DANGEROUS_EXTRUDE
388
+  float extrude_min_temp = EXTRUDE_MINTEMP;
389
+#endif
389
 
390
 
390
 #ifdef SDSUPPORT
391
 #ifdef SDSUPPORT
391
   #include "SdFatUtil.h"
392
   #include "SdFatUtil.h"
1009
 inline void line_to_z(float zPosition) {
1010
 inline void line_to_z(float zPosition) {
1010
   plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1011
   plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1011
 }
1012
 }
1013
+inline void line_to_destination(float mm_m) {
1014
+  plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], mm_m/60, active_extruder);
1015
+}
1012
 inline void line_to_destination() {
1016
 inline void line_to_destination() {
1013
-  plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1017
+  line_to_destination(feedrate);
1014
 }
1018
 }
1015
 inline void sync_plan_position() {
1019
 inline void sync_plan_position() {
1016
   plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1020
   plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
4099
 
4103
 
4100
 #ifdef PREVENT_DANGEROUS_EXTRUDE
4104
 #ifdef PREVENT_DANGEROUS_EXTRUDE
4101
 
4105
 
4106
+  void set_extrude_min_temp(float temp) { extrude_min_temp = temp; }
4107
+
4102
   /**
4108
   /**
4103
    * M302: Allow cold extrudes, or set the minimum extrude S<temperature>.
4109
    * M302: Allow cold extrudes, or set the minimum extrude S<temperature>.
4104
    */
4110
    */
5444
 void prepare_move() {
5450
 void prepare_move() {
5445
   clamp_to_software_endstops(destination);
5451
   clamp_to_software_endstops(destination);
5446
   refresh_cmd_timeout();
5452
   refresh_cmd_timeout();
5447
-  
5453
+
5454
+  #ifdef PREVENT_DANGEROUS_EXTRUDE
5455
+    float de = destination[E_AXIS] - current_position[E_AXIS];
5456
+    if (de) {
5457
+      if (degHotend(active_extruder) < extrude_min_temp) {
5458
+        current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
5459
+        SERIAL_ECHO_START;
5460
+        SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
5461
+      }
5462
+      #ifdef PREVENT_LENGTHY_EXTRUDE
5463
+        if (labs(de) > EXTRUDE_MAXLENGTH) {
5464
+          current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
5465
+          SERIAL_ECHO_START;
5466
+          SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
5467
+        }
5468
+      #endif
5469
+    }
5470
+  #endif
5471
+
5448
   #ifdef SCARA //for now same as delta-code
5472
   #ifdef SCARA //for now same as delta-code
5449
 
5473
 
5450
     float difference[NUM_AXIS];
5474
     float difference[NUM_AXIS];
5451
     for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
5475
     for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
5452
 
5476
 
5453
-    float cartesian_mm = sqrt(  sq(difference[X_AXIS]) +
5454
-                                sq(difference[Y_AXIS]) +
5455
-                                sq(difference[Z_AXIS]));
5477
+    float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
5456
     if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
5478
     if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
5457
     if (cartesian_mm < 0.000001) { return; }
5479
     if (cartesian_mm < 0.000001) { return; }
5458
     float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
5480
     float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
5464
 
5486
 
5465
     for (int s = 1; s <= steps; s++) {
5487
     for (int s = 1; s <= steps; s++) {
5466
       float fraction = float(s) / float(steps);
5488
       float fraction = float(s) / float(steps);
5467
-      for(int8_t i = 0; i < NUM_AXIS; i++) {
5468
-        destination[i] = current_position[i] + difference[i] * fraction;
5469
-      }
5489
+      for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction;
5470
   
5490
   
5471
       calculate_delta(destination);
5491
       calculate_delta(destination);
5472
       //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
5492
       //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
5476
       //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
5496
       //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
5477
       //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
5497
       //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
5478
 
5498
 
5479
-      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
5480
-        destination[E_AXIS], feedrate*feedmultiply/60/100.0,
5481
-        active_extruder);
5499
+      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
5482
     }
5500
     }
5483
 
5501
 
5484
   #endif // SCARA
5502
   #endif // SCARA
5488
     float difference[NUM_AXIS];
5506
     float difference[NUM_AXIS];
5489
     for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
5507
     for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
5490
 
5508
 
5491
-    float cartesian_mm = sqrt(sq(difference[X_AXIS]) +
5492
-                              sq(difference[Y_AXIS]) +
5493
-                              sq(difference[Z_AXIS]));
5509
+    float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
5494
     if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
5510
     if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
5495
     if (cartesian_mm < 0.000001) return;
5511
     if (cartesian_mm < 0.000001) return;
5496
     float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
5512
     float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
5507
       #ifdef ENABLE_AUTO_BED_LEVELING
5523
       #ifdef ENABLE_AUTO_BED_LEVELING
5508
         adjust_delta(destination);
5524
         adjust_delta(destination);
5509
       #endif
5525
       #endif
5510
-      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
5511
-                       destination[E_AXIS], feedrate*feedmultiply/60/100.0,
5512
-                       active_extruder);
5526
+      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
5513
     }
5527
     }
5514
 
5528
 
5515
   #endif // DELTA
5529
   #endif // DELTA
5519
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
5533
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
5520
         // move duplicate extruder into correct duplication position.
5534
         // move duplicate extruder into correct duplication position.
5521
         plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5535
         plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5522
-        plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
5523
-            current_position[E_AXIS], max_feedrate[X_AXIS], 1);
5536
+        plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
5537
+          current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[X_AXIS], 1);
5524
         sync_plan_position();
5538
         sync_plan_position();
5525
         st_synchronize();
5539
         st_synchronize();
5526
         extruder_duplication_enabled = true;
5540
         extruder_duplication_enabled = true;
5528
       }
5542
       }
5529
       else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) { // handle unparking of head
5543
       else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) { // handle unparking of head
5530
         if (current_position[E_AXIS] == destination[E_AXIS]) {
5544
         if (current_position[E_AXIS] == destination[E_AXIS]) {
5531
-          // this is a travel move - skit it but keep track of current position (so that it can later
5532
-          // be used as start of first non-travel move)
5545
+          // This is a travel move (with no extrusion)
5546
+          // Skip it, but keep track of the current position
5547
+          // (so it can be used as the start of the next non-travel move)
5533
           if (delayed_move_time != 0xFFFFFFFFUL) {
5548
           if (delayed_move_time != 0xFFFFFFFFUL) {
5534
             set_current_to_destination();
5549
             set_current_to_destination();
5535
-            if (destination[Z_AXIS] > raised_parked_position[Z_AXIS])
5536
-              raised_parked_position[Z_AXIS] = destination[Z_AXIS];
5550
+            if (destination[Z_AXIS] > raised_parked_position[Z_AXIS]) raised_parked_position[Z_AXIS] = destination[Z_AXIS];
5537
             delayed_move_time = millis();
5551
             delayed_move_time = millis();
5538
             return;
5552
             return;
5539
           }
5553
           }
5540
         }
5554
         }
5541
         delayed_move_time = 0;
5555
         delayed_move_time = 0;
5542
         // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
5556
         // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
5543
-        plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS],    current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
5544
-        plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS],
5545
-            current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder);
5546
-        plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
5547
-            current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
5557
+        plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
5558
+        plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], min(max_feedrate[X_AXIS], max_feedrate[Y_AXIS]), active_extruder);
5559
+        plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder);
5548
         active_extruder_parked = false;
5560
         active_extruder_parked = false;
5549
       }
5561
       }
5550
     }
5562
     }
5552
 
5564
 
5553
   #if !defined(DELTA) && !defined(SCARA)
5565
   #if !defined(DELTA) && !defined(SCARA)
5554
     // Do not use feedmultiply for E or Z only moves
5566
     // Do not use feedmultiply for E or Z only moves
5555
-    if ( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
5567
+    if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) {
5556
       line_to_destination();
5568
       line_to_destination();
5557
     }
5569
     }
5558
     else {
5570
     else {
5560
         mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
5572
         mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
5561
         return;
5573
         return;
5562
       #else
5574
       #else
5563
-        plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
5575
+        line_to_destination(feedrate * feedmultiply / 100.0);
5564
       #endif  // MESH_BED_LEVELING
5576
       #endif  // MESH_BED_LEVELING
5565
     }
5577
     }
5566
   #endif // !(DELTA || SCARA)
5578
   #endif // !(DELTA || SCARA)

+ 1
- 8
Marlin/planner.cpp View File

113
 //===========================================================================
113
 //===========================================================================
114
 //=============================private variables ============================
114
 //=============================private variables ============================
115
 //===========================================================================
115
 //===========================================================================
116
-#ifdef PREVENT_DANGEROUS_EXTRUDE
117
-  float extrude_min_temp = EXTRUDE_MINTEMP;
118
-#endif
119
 #ifdef XY_FREQUENCY_LIMIT
116
 #ifdef XY_FREQUENCY_LIMIT
120
   // Used for the frequency limit
117
   // Used for the frequency limit
121
   #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
118
   #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
508
   #ifdef PREVENT_DANGEROUS_EXTRUDE
505
   #ifdef PREVENT_DANGEROUS_EXTRUDE
509
     if (de) {
506
     if (de) {
510
       if (degHotend(active_extruder) < extrude_min_temp) {
507
       if (degHotend(active_extruder) < extrude_min_temp) {
511
-        position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part
508
+        position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
512
         de = 0; // no difference
509
         de = 0; // no difference
513
         SERIAL_ECHO_START;
510
         SERIAL_ECHO_START;
514
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
511
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
998
   st_set_e_position(position[E_AXIS]);
995
   st_set_e_position(position[E_AXIS]);
999
 }
996
 }
1000
 
997
 
1001
-#ifdef PREVENT_DANGEROUS_EXTRUDE
1002
-  void set_extrude_min_temp(float temp) { extrude_min_temp = temp; }
1003
-#endif
1004
-
1005
 // Calculate the steps/s^2 acceleration rates, based on the mm/s^s
998
 // Calculate the steps/s^2 acceleration rates, based on the mm/s^s
1006
 void reset_acceleration_rates() {
999
 void reset_acceleration_rates() {
1007
   for (int i = 0; i < NUM_AXIS; i++)
1000
   for (int i = 0; i < NUM_AXIS; i++)

+ 1
- 5
Marlin/planner.h View File

161
     return NULL;
161
     return NULL;
162
 }
162
 }
163
 
163
 
164
-#ifdef PREVENT_DANGEROUS_EXTRUDE
165
-  void set_extrude_min_temp(float temp);
166
-#endif
167
-
168
 void reset_acceleration_rates();
164
 void reset_acceleration_rates();
169
 
165
 
170
-#endif //PLANNER_H
166
+#endif // PLANNER_H

Loading…
Cancel
Save