Erik van der Zalm 12 vuotta sitten
vanhempi
commit
84d9cf7339

+ 24
- 8
Marlin/Configuration.h Näytä tiedosto

@@ -20,9 +20,6 @@
20 20
 // if unwanted behavior is observed on a user's machine when running at very slow speeds.
21 21
 #define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
22 22
 
23
-// If defined the movements slow down when the look ahead buffer is only half full
24
-#define SLOWDOWN
25
-
26 23
 // BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration
27 24
 
28 25
 //// The following define selects which electronics board you have. Please choose the one that matches your setup
@@ -65,11 +62,11 @@
65 62
 
66 63
 #define BED_CHECK_INTERVAL 5000 //ms
67 64
 
68
-//// Experimental watchdog and minimal temp
69
-// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
70
-// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
71
-/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE
72
-//#define WATCHPERIOD 5000 //5 seconds
65
+//// Heating sanity check:
66
+// This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
67
+// If the temperature has not increased at the end of that period, the target temperature is set to zero. 
68
+// It can be reset with another M104/M109
69
+//#define WATCHPERIOD 20000 //20 seconds
73 70
 
74 71
 // Actual temperature must be close to target for this long before M109 returns success
75 72
 #define TEMP_RESIDENCY_TIME 30  // (seconds)
@@ -163,6 +160,14 @@
163 160
   #endif
164 161
 #endif // PIDTEMP
165 162
 
163
+//  extruder run-out prevention. 
164
+//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
165
+//#define EXTRUDER_RUNOUT_PREVENT  
166
+#define EXTRUDER_RUNOUT_MINTEMP 190  
167
+#define EXTRUDER_RUNOUT_SECONDS 30.
168
+#define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
169
+#define EXTRUDER_RUNOUT_SPEED 1500.  //extrusion speed
170
+
166 171
 
167 172
 //===========================================================================
168 173
 //=============================Mechanical Settings===========================
@@ -250,7 +255,12 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
250 255
 #define DEFAULT_XYJERK                20.0    // (mm/sec)
251 256
 #define DEFAULT_ZJERK                 0.4     // (mm/sec)
252 257
 
258
+// If defined the movements slow down when the look ahead buffer is only half full
259
+#define SLOWDOWN
253 260
 
261
+//default stepper release if idle
262
+#define DEFAULT_STEPPER_DEACTIVE_TIME 60
263
+#define DEFAULT_STEPPER_DEACTIVE_COMMAND "M84 X Y E"  //z stays  powered
254 264
 
255 265
 
256 266
 //===========================================================================
@@ -303,6 +313,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
303 313
 //#define ULTRA_LCD  //general lcd support, also 16x2
304 314
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
305 315
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
316
+#define SD_FINISHED_RELEASECOMMAND "M84 X Y E" // no z because of layer shift.
306 317
 
307 318
 #define ULTIPANEL
308 319
 #ifdef ULTIPANEL
@@ -339,6 +350,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
339 350
   #define AUTOTEMP_OLDWEIGHT 0.98
340 351
 #endif
341 352
 
353
+//this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
354
+//can be software-disabled for whatever purposes by
355
+#define PREVENT_DANGEROUS_EXTRUDE
356
+#define EXTRUDE_MINTEMP 190
357
+#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
342 358
 
343 359
 const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
344 360
 

+ 2
- 0
Marlin/Marlin.h Näytä tiedosto

@@ -4,6 +4,7 @@
4 4
 // Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
5 5
 // Licence: GPL
6 6
 #define  HardwareSerial_h // trick to disable the standard HWserial
7
+#include <stdio.h>
7 8
 #include <math.h>
8 9
 #if ARDUINO >= 100
9 10
   #include "Arduino.h"
@@ -147,6 +148,7 @@ extern float homing_feedrate[];
147 148
 extern bool axis_relative_modes[];
148 149
 extern float current_position[NUM_AXIS] ;
149 150
 extern float add_homeing[3];
151
+extern bool stop_heating_wait;
150 152
 
151 153
 // Handling multiple extruders pins
152 154
 extern uint8_t active_extruder;

+ 103
- 38
Marlin/Marlin.pde Näytä tiedosto

@@ -27,6 +27,8 @@
27 27
 
28 28
 #include <math.h>
29 29
 #include <EEPROM.h>
30
+#include <stdio.h>
31
+
30 32
 #include "EEPROMwrite.h"
31 33
 #include "fastio.h"
32 34
 #include "Configuration.h"
@@ -39,7 +41,7 @@
39 41
 #include "motion_control.h"
40 42
 #include "cardreader.h"
41 43
 #include "watchdog.h"
42
-#include <stdio.h>
44
+
43 45
 
44 46
 
45 47
 #define VERSION_STRING  "1.0.0 Beta 1"
@@ -108,6 +110,7 @@
108 110
 // M206 - set additional homeing offset
109 111
 // M220 - set speed factor override percentage S:factor in percent
110 112
 // M301 - Set PID parameters P I and D
113
+// M302 - Allow cold extrudes
111 114
 // M400 - Finish all moves
112 115
 // M500 - stores paramters in EEPROM
113 116
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
@@ -135,7 +138,7 @@ volatile bool feedmultiplychanged=false;
135 138
 float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
136 139
 float add_homeing[3]={0,0,0};
137 140
 uint8_t active_extruder = 0;
138
-
141
+bool stop_heating_wait=false;
139 142
 
140 143
 //===========================================================================
141 144
 //=============================private variables=============================
@@ -175,7 +178,8 @@ const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
175 178
 //Inactivity shutdown variables
176 179
 static unsigned long previous_millis_cmd = 0;
177 180
 static unsigned long max_inactive_time = 0;
178
-static unsigned long stepper_inactive_time = 0;
181
+static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000;
182
+static unsigned long last_stepperdisabled_time=30*1000; //first release check after 30 seconds
179 183
 
180 184
 static unsigned long starttime=0;
181 185
 static unsigned long stoptime=0;
@@ -232,7 +236,9 @@ void setup()
232 236
   SERIAL_PROTOCOLLNPGM("start");
233 237
   SERIAL_ECHO_START;
234 238
   SERIAL_ECHOPGM("Free Memory:");
235
-  SERIAL_ECHOLN(freeMemory());
239
+  SERIAL_ECHO(freeMemory());
240
+  SERIAL_ECHOPGM(" PlannerBufferBytes:");
241
+  SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
236 242
   for(int8_t i = 0; i < BUFSIZE; i++)
237 243
   {
238 244
     fromsd[i] = false;
@@ -498,19 +504,16 @@ FORCE_INLINE void process_commands()
498 504
     case 1: // G1
499 505
       get_coordinates(); // For X Y Z E F
500 506
       prepare_move();
501
-      previous_millis_cmd = millis();
502 507
       //ClearToSend();
503 508
       return;
504 509
       //break;
505 510
     case 2: // G2  - CW ARC
506 511
       get_arc_coordinates();
507 512
       prepare_arc_move(true);
508
-      previous_millis_cmd = millis();
509 513
       return;
510 514
     case 3: // G3  - CCW ARC
511 515
       get_arc_coordinates();
512 516
       prepare_arc_move(false);
513
-      previous_millis_cmd = millis();
514 517
       return;
515 518
     case 4: // G4 dwell
516 519
       LCD_MESSAGEPGM("DWELL...");
@@ -520,7 +523,7 @@ FORCE_INLINE void process_commands()
520 523
       
521 524
       st_synchronize();
522 525
       codenum += millis();  // keep track of when we started waiting
523
-      
526
+      previous_millis_cmd = millis();
524 527
       while(millis()  < codenum ){
525 528
         manage_heater();
526 529
       }
@@ -540,34 +543,53 @@ FORCE_INLINE void process_commands()
540 543
       #ifdef QUICK_HOME
541 544
       if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) )  //first diagonal move
542 545
       {
543
-        current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
546
+        current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;  
544 547
 
545 548
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); 
546
-        destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
547
-        destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR; 
548
-        feedrate =homing_feedrate[X_AXIS]; 
549
+        destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;  
550
+        feedrate = homing_feedrate[X_AXIS]; 
549 551
         if(homing_feedrate[Y_AXIS]<feedrate)
550 552
           feedrate =homing_feedrate[Y_AXIS]; 
551
-        prepare_move();
552
-        current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
553
+        prepare_move(); 
554
+    
555
+        current_position[X_AXIS] = (X_HOME_DIR == -1) ? 0 : X_MAX_LENGTH;
556
+        current_position[Y_AXIS] = (Y_HOME_DIR == -1) ? 0 : Y_MAX_LENGTH;
557
+        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
558
+        destination[X_AXIS] = current_position[X_AXIS];
559
+        destination[Y_AXIS] = current_position[Y_AXIS];
560
+        feedrate = 0.0;
561
+        st_synchronize();
562
+        plan_set_position(0, 0, current_position[Z_AXIS], current_position[E_AXIS]);
563
+        current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;
564
+        endstops_hit_on_purpose();
553 565
       }
554 566
       #endif
555 567
       
556 568
       if((home_all_axis) || (code_seen(axis_codes[X_AXIS]))) 
557 569
       {
558 570
         HOMEAXIS(X);
559
-	current_position[0]=code_value()+add_homeing[0];
560 571
       }
561 572
 
562 573
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
563 574
        HOMEAXIS(Y);
564
-       current_position[1]=code_value()+add_homeing[1];
565 575
       }
566 576
 
567 577
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
568 578
         HOMEAXIS(Z);
569
-	current_position[2]=code_value()+add_homeing[2];
570
-      }       
579
+      }
580
+      
581
+      if(code_seen(axis_codes[X_AXIS])) 
582
+      {
583
+        current_position[0]=code_value()+add_homeing[0];
584
+      }
585
+
586
+      if(code_seen(axis_codes[Y_AXIS])) {
587
+       current_position[1]=code_value()+add_homeing[1];
588
+      }
589
+
590
+      if(code_seen(axis_codes[Z_AXIS])) {
591
+        current_position[2]=code_value()+add_homeing[2];
592
+      }
571 593
       #ifdef ENDSTOPS_ONLY_FOR_HOMING
572 594
         enable_endstops(false);
573 595
       #endif
@@ -817,6 +839,7 @@ FORCE_INLINE void process_commands()
817 839
           }
818 840
           manage_heater();
819 841
           LCD_STATUS;
842
+        if(stop_heating_wait) break;
820 843
         #ifdef TEMP_RESIDENCY_TIME
821 844
             /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
822 845
               or when current temp falls outside the hysteresis after target temp was reached */
@@ -830,6 +853,7 @@ FORCE_INLINE void process_commands()
830 853
         }
831 854
         LCD_MESSAGEPGM("Heating done.");
832 855
         starttime=millis();
856
+        previous_millis_cmd = millis();
833 857
       }
834 858
       break;
835 859
     case 190: // M190 - Wait for bed heater to reach target.
@@ -853,6 +877,7 @@ FORCE_INLINE void process_commands()
853 877
           manage_heater();
854 878
         }
855 879
         LCD_MESSAGEPGM("Bed done.");
880
+        previous_millis_cmd = millis();
856 881
     #endif
857 882
     break;
858 883
 
@@ -896,20 +921,25 @@ FORCE_INLINE void process_commands()
896 921
       }
897 922
       else
898 923
       { 
899
-        #if ((E_ENABLE_PIN != X_ENABLE_PIN) && (E_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
900
-        if(code_seen('E')) {
901
-          st_synchronize();
902
-          LCD_MESSAGEPGM("Free Move");
924
+        bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3])));
925
+        if(all_axis)
926
+        {
903 927
           disable_e0();
904 928
           disable_e1();
905 929
           disable_e2();
906
-        }
907
-        else {
908 930
           finishAndDisableSteppers();
909 931
         }
910
-        #else
911
-          finishAndDisableSteppers();
912
-        #endif
932
+        else
933
+        {
934
+          st_synchronize();
935
+          if(code_seen('X')) disable_x();
936
+          if(code_seen('Y')) disable_y();
937
+          if(code_seen('Z')) disable_z();
938
+          #if ((E_ENABLE_PIN != X_ENABLE_PIN) && (E_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
939
+            if(code_seen('E')) disable_e();
940
+          #endif 
941
+          LCD_MESSAGEPGM("Partial Release");
942
+        }
913 943
       }
914 944
       break;
915 945
     case 85: // M85
@@ -979,7 +1009,11 @@ FORCE_INLINE void process_commands()
979 1009
     case 201: // M201
980 1010
       for(int8_t i=0; i < NUM_AXIS; i++) 
981 1011
       {
982
-        if(code_seen(axis_codes[i])) axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
1012
+        if(code_seen(axis_codes[i]))
1013
+        {
1014
+          max_acceleration_units_per_sq_second[i] = code_value();
1015
+          axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
1016
+        }
983 1017
       }
984 1018
       break;
985 1019
     #if 0 // Not used for Sprinter/grbl gen6
@@ -1049,6 +1083,12 @@ FORCE_INLINE void process_commands()
1049 1083
       }
1050 1084
       break;
1051 1085
     #endif //PIDTEMP
1086
+      
1087
+    case 302: // finish all moves
1088
+    {
1089
+      allow_cold_extrudes(true);
1090
+    }
1091
+    break;
1052 1092
     case 400: // finish all moves
1053 1093
     {
1054 1094
       st_synchronize();
@@ -1146,6 +1186,7 @@ FORCE_INLINE void get_arc_coordinates()
1146 1186
 
1147 1187
 void prepare_move()
1148 1188
 {
1189
+  
1149 1190
   if (min_software_endstops) {
1150 1191
     if (destination[X_AXIS] < 0) destination[X_AXIS] = 0.0;
1151 1192
     if (destination[Y_AXIS] < 0) destination[Y_AXIS] = 0.0;
@@ -1162,6 +1203,7 @@ void prepare_move()
1162 1203
   for(int8_t i=0; i < NUM_AXIS; i++) {
1163 1204
     current_position[i] = destination[i];
1164 1205
   }
1206
+  previous_millis_cmd = millis();
1165 1207
 }
1166 1208
 
1167 1209
 void prepare_arc_move(char isclockwise) {
@@ -1176,6 +1218,7 @@ void prepare_arc_move(char isclockwise) {
1176 1218
   for(int8_t i=0; i < NUM_AXIS; i++) {
1177 1219
     current_position[i] = destination[i];
1178 1220
   }
1221
+  previous_millis_cmd = millis();
1179 1222
 }
1180 1223
 
1181 1224
 void manage_inactivity(byte debug) 
@@ -1183,16 +1226,38 @@ void manage_inactivity(byte debug)
1183 1226
   if( (millis()-previous_millis_cmd) >  max_inactive_time ) 
1184 1227
     if(max_inactive_time) 
1185 1228
       kill(); 
1186
-  if( (millis()-previous_millis_cmd) >  stepper_inactive_time ) 
1187
-    if(stepper_inactive_time) 
1188
-    { 
1189
-      disable_x(); 
1190
-      disable_y(); 
1191
-      disable_z(); 
1192
-      disable_e0(); 
1193
-      disable_e1(); 
1194
-      disable_e2(); 
1229
+  if(stepper_inactive_time)  
1230
+  if( (millis()-last_stepperdisabled_time) >  stepper_inactive_time ) 
1231
+  {
1232
+    if(previous_millis_cmd>last_stepperdisabled_time)
1233
+      last_stepperdisabled_time=previous_millis_cmd;
1234
+    else
1235
+    {
1236
+      if(  (X_ENABLE_ON && (READ(X_ENABLE_PIN)!=0))  ||  (!X_ENABLE_ON && READ(X_ENABLE_PIN)==0)  )
1237
+        enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); 
1238
+      last_stepperdisabled_time=millis();
1195 1239
     }
1240
+  }
1241
+  #ifdef EXTRUDER_RUNOUT_PREVENT
1242
+    if( (millis()-previous_millis_cmd) >  EXTRUDER_RUNOUT_SECONDS*1000 ) 
1243
+    if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
1244
+    {
1245
+     bool oldstatus=READ(E_ENABLE_PIN);
1246
+     enable_e();
1247
+     float oldepos=current_position[E_AXIS];
1248
+     float oldedes=destination[E_AXIS];
1249
+     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], 
1250
+                      current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], 
1251
+                      EXTRUDER_RUNOUT_SPEED/60.*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], active_extruder);
1252
+     current_position[E_AXIS]=oldepos;
1253
+     destination[E_AXIS]=oldedes;
1254
+     plan_set_e_position(oldepos);
1255
+     previous_millis_cmd=millis();
1256
+     //enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND);
1257
+     st_synchronize();
1258
+     WRITE(E_ENABLE_PIN,oldstatus);
1259
+    }
1260
+  #endif
1196 1261
   check_axes_activity();
1197 1262
 }
1198 1263
 
@@ -1215,4 +1280,4 @@ void kill()
1215 1280
   while(1); // Wait for reset
1216 1281
 }
1217 1282
 
1218
-
1283
+

+ 1
- 0
Marlin/cardreader.h Näytä tiedosto

@@ -44,6 +44,7 @@ public:
44 44
   bool cardOK ;
45 45
   char filename[11];
46 46
   bool filenameIsDir;
47
+  int lastnr; //last number of the autostart;
47 48
 private:
48 49
   SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
49 50
   Sd2Card card;

+ 6
- 2
Marlin/cardreader.pde Näytä tiedosto

@@ -14,6 +14,7 @@ CardReader::CardReader()
14 14
    autostart_atmillis=0;
15 15
 
16 16
    autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
17
+   lastnr=0;
17 18
   //power to SD reader
18 19
   #if SDPOWER > -1
19 20
     SET_OUTPUT(SDPOWER); 
@@ -334,7 +335,7 @@ void CardReader::checkautostart(bool force)
334 335
     if(!cardOK) //fail
335 336
       return;
336 337
   }
337
-  static int lastnr=0;
338
+  
338 339
   char autoname[30];
339 340
   sprintf(autoname,"auto%i.g",lastnr);
340 341
   for(int8_t i=0;i<(int)strlen(autoname);i++)
@@ -431,10 +432,13 @@ void CardReader::updir()
431 432
 
432 433
 void CardReader::printingHasFinished()
433 434
 {
435
+ quickStop();
434 436
  sdprinting = false;
437
+ stop_heating_wait=true;
435 438
  if(SD_FINISHED_STEPPERRELEASE)
436 439
  {
437
-   finishAndDisableSteppers();
440
+   //finishAndDisableSteppers();
441
+   enquecommand(SD_FINISHED_RELEASECOMMAND);
438 442
  }
439 443
  autotempShutdown();
440 444
 }

+ 26
- 2
Marlin/planner.cpp Näytä tiedosto

@@ -103,7 +103,9 @@ volatile unsigned char block_buffer_tail;           // Index of the block to pro
103 103
 //===========================================================================
104 104
 //=============================private variables ============================
105 105
 //===========================================================================
106
-
106
+#ifdef PREVENT_DANGEROUS_EXTRUDE
107
+  bool allow_cold_extrude=false;
108
+#endif
107 109
 #ifdef XY_FREQUENCY_LIMIT
108 110
   // Used for the frequency limit
109 111
   static unsigned char old_direction_bits = 0;               // Old direction bits. Used for speed calculations
@@ -462,7 +464,23 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
462 464
   target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
463 465
   target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
464 466
   target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);     
465
-  target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); 
467
+  target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
468
+  
469
+  #ifdef PREVENT_DANGEROUS_EXTRUDE
470
+    if(target[E_AXIS]!=position[E_AXIS])
471
+    if(degHotend(active_extruder)<EXTRUDE_MINTEMP && !allow_cold_extrude)
472
+    {
473
+      position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
474
+      SERIAL_ECHO_START;
475
+      SERIAL_ECHOLNPGM(" cold extrusion prevented");
476
+    }
477
+    if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
478
+    {
479
+      position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
480
+      SERIAL_ECHO_START;
481
+      SERIAL_ECHOLNPGM(" too long extrusion prevented");
482
+    }
483
+  #endif
466 484
   
467 485
   // Prepare to set up new block
468 486
   block_t *block = &block_buffer[block_buffer_head];
@@ -778,3 +796,9 @@ uint8_t movesplanned()
778 796
  return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
779 797
 }
780 798
 
799
+void allow_cold_extrudes(bool allow)
800
+{
801
+  #ifdef PREVENT_DANGEROUS_EXTRUDE
802
+    allow_cold_extrude=allow;
803
+  #endif
804
+}

+ 12
- 0
Marlin/planner.h Näytä tiedosto

@@ -128,4 +128,16 @@ FORCE_INLINE block_t *plan_get_current_block()
128 128
   block->busy = true;
129 129
   return(block);
130 130
 }
131
+
132
+// Gets the current block. Returns NULL if buffer empty
133
+FORCE_INLINE bool blocks_queued() 
134
+{
135
+  if (block_buffer_head == block_buffer_tail) { 
136
+    return false; 
137
+  }
138
+  else
139
+    return true;
140
+}
141
+
142
+void allow_cold_extrudes(bool allow);
131 143
 #endif

+ 12
- 2
Marlin/stepper.cpp Näytä tiedosto

@@ -757,14 +757,15 @@ void st_init()
757 757
   sei();
758 758
 }
759 759
 
760
+
760 761
 // Block until all buffered steps are executed
761 762
 void st_synchronize()
762 763
 {
763
-  while(plan_get_current_block()) {
764
+    while( blocks_queued()) {
764 765
     manage_heater();
765 766
     manage_inactivity(1);
766 767
     LCD_STATUS;
767
-  }   
768
+  }
768 769
 }
769 770
 
770 771
 void st_set_position(const long &x, const long &y, const long &z, const long &e)
@@ -804,3 +805,12 @@ void finishAndDisableSteppers()
804 805
   disable_e1(); 
805 806
   disable_e2(); 
806 807
 }
808
+
809
+void quickStop()
810
+{
811
+  DISABLE_STEPPER_DRIVER_INTERRUPT();
812
+  while(blocks_queued())
813
+    plan_discard_current_block();
814
+  ENABLE_STEPPER_DRIVER_INTERRUPT();
815
+}
816
+

+ 1
- 1
Marlin/stepper.h Näytä tiedosto

@@ -67,5 +67,5 @@ void finishAndDisableSteppers();
67 67
 
68 68
 extern block_t *current_block;  // A pointer to the block currently being traced
69 69
 
70
-
70
+void quickStop();
71 71
 #endif

+ 16
- 1
Marlin/temperature.cpp Näytä tiedosto

@@ -85,6 +85,7 @@ static unsigned long  previous_millis_bed_heater;
85 85
   
86 86
 #ifdef WATCHPERIOD
87 87
   static int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
88
+  static int watch_oldtemp[3] = {0,0,0};
88 89
   static unsigned long watchmillis = 0;
89 90
 #endif //WATCHPERIOD
90 91
 
@@ -213,7 +214,20 @@ void manage_heater()
213 214
       soft_pwm[e] = 0;
214 215
     }
215 216
   } // End extruder for loop
216
-    
217
+  
218
+  #ifdef WATCHPERIOD
219
+    if(watchmillis && millis() - watchmillis > WATCHPERIOD){
220
+        if(watch_oldtemp[TEMPSENSOR_HOTEND_0] >= degHotend(active_extruder)){
221
+            setTargetHotend(0,active_extruder);
222
+            LCD_MESSAGEPGM("Heating failed");
223
+            SERIAL_ECHO_START;
224
+            SERIAL_ECHOLN("Heating failed");
225
+        }else{
226
+            watchmillis = 0;
227
+        }
228
+    }
229
+  #endif
230
+  
217 231
   if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
218 232
     return;
219 233
   previous_millis_bed_heater = millis();
@@ -493,6 +507,7 @@ void setWatch()
493 507
   for (int e = 0; e < EXTRUDERS; e++)
494 508
   {
495 509
     if(isHeatingHotend(e))
510
+    watch_oldtemp[TEMPSENSOR_HOTEND_0] = degHotend(0);
496 511
     {
497 512
       t = max(t,millis());
498 513
       watch_raw[e] = current_raw[e];

+ 144
- 143
Marlin/temperature.h Näytä tiedosto

@@ -1,144 +1,145 @@
1
-/*
2
-  temperature.h - temperature controller
3
-  Part of Marlin
4
-
5
-  Copyright (c) 2011 Erik van der Zalm
6
-
7
-  Grbl is free software: you can redistribute it and/or modify
8
-  it under the terms of the GNU General Public License as published by
9
-  the Free Software Foundation, either version 3 of the License, or
10
-  (at your option) any later version.
11
-
12
-  Grbl is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-  GNU General Public License for more details.
16
-
17
-  You should have received a copy of the GNU General Public License
18
-  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
-*/
20
-
21
-#ifndef temperature_h
22
-#define temperature_h 
23
-
24
-#include "Marlin.h"
25
-#include "fastio.h"
26
-#ifdef PID_ADD_EXTRUSION_RATE
27
-  #include "stepper.h"
28
-#endif
29
-
30
-// public functions
31
-void tp_init();  //initialise the heating
32
-void manage_heater(); //it is critical that this is called periodically.
33
-
34
-//low leven conversion routines
35
-// do not use this routines and variables outsie of temperature.cpp
36
-int temp2analog(int celsius, uint8_t e);
37
-int temp2analogBed(int celsius);
38
-float analog2temp(int raw, uint8_t e);
39
-float analog2tempBed(int raw);
40
-extern int target_raw[EXTRUDERS];  
41
-extern int heatingtarget_raw[EXTRUDERS];  
42
-extern int current_raw[EXTRUDERS];
43
-extern int target_raw_bed;
44
-extern int current_raw_bed;
45
-extern float Kp,Ki,Kd,Kc;
46
-
47
-#ifdef PIDTEMP
48
-  extern float pid_setpoint[EXTRUDERS];
49
-#endif
50
-  
51
-#ifdef WATCHPERIOD
52
-  extern int watch_raw[EXTRUDERS] ;
53
-  extern unsigned long watchmillis;
54
-#endif
55
-
56
-
57
-//high level conversion routines, for use outside of temperature.cpp
58
-//inline so that there is no performance decrease.
59
-//deg=degreeCelsius
60
-
61
-FORCE_INLINE float degHotend(uint8_t extruder) {  
62
-  return analog2temp(current_raw[extruder], extruder);
63
-};
64
-
65
-FORCE_INLINE float degBed() {
66
-  return analog2tempBed(current_raw_bed);
67
-};
68
-
69
-FORCE_INLINE float degTargetHotend(uint8_t extruder) {  
70
-  return analog2temp(target_raw[extruder], extruder);
71
-};
72
-
73
-FORCE_INLINE float degTargetBed() {   
74
-  return analog2tempBed(target_raw_bed);
75
-};
76
-
77
-FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {  
78
-  target_raw[extruder] = temp2analog(celsius, extruder);
79
-#ifdef PIDTEMP
80
-  pid_setpoint[extruder] = celsius;
81
-#endif //PIDTEMP
82
-};
83
-
84
-FORCE_INLINE void setTargetBed(const float &celsius) {  
85
-  target_raw_bed = temp2analogBed(celsius);
86
-};
87
-
88
-FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  
89
-  return target_raw[extruder] > current_raw[extruder];
90
-};
91
-
92
-FORCE_INLINE bool isHeatingBed() {
93
-  return target_raw_bed > current_raw_bed;
94
-};
95
-
96
-FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {  
97
-  return target_raw[extruder] < current_raw[extruder];
98
-};
99
-
100
-FORCE_INLINE bool isCoolingBed() {
101
-  return target_raw_bed < current_raw_bed;
102
-};
103
-
104
-#define degHotend0() degHotend(0)
105
-#define degTargetHotend0() degTargetHotend(0)
106
-#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
107
-#define isHeatingHotend0() isHeatingHotend(0)
108
-#define isCoolingHotend0() isCoolingHotend(0)
109
-#if EXTRUDERS > 1
110
-#define degHotend1() degHotend(1)
111
-#define degTargetHotend1() degTargetHotend(1)
112
-#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
113
-#define isHeatingHotend1() isHeatingHotend(1)
114
-#define isCoolingHotend1() isCoolingHotend(1)
115
-#endif
116
-#if EXTRUDERS > 2
117
-#define degHotend2() degHotend(2)
118
-#define degTargetHotend2() degTargetHotend(2)
119
-#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
120
-#define isHeatingHotend2() isHeatingHotend(2)
121
-#define isCoolingHotend2() isCoolingHotend(2)
122
-#endif
123
-#if EXTRUDERS > 3
124
-#error Invalid number of extruders
125
-#endif
126
-
127
-FORCE_INLINE void autotempShutdown(){
128
- #ifdef AUTOTEMP
129
- if(autotemp_enabled)
130
- {
131
-  autotemp_enabled=false;
132
-  if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
133
-    setTargetHotend(0,ACTIVE_EXTRUDER);
134
- }
135
- #endif
136
-}
137
-
138
-int getHeaterPower(int heater);
139
-void disable_heater();
140
-void setWatch();
141
-void updatePID();
142
-
143
-#endif
1
+/*
2
+  temperature.h - temperature controller
3
+  Part of Marlin
4
+
5
+  Copyright (c) 2011 Erik van der Zalm
6
+
7
+  Grbl is free software: you can redistribute it and/or modify
8
+  it under the terms of the GNU General Public License as published by
9
+  the Free Software Foundation, either version 3 of the License, or
10
+  (at your option) any later version.
11
+
12
+  Grbl is distributed in the hope that it will be useful,
13
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+  GNU General Public License for more details.
16
+
17
+  You should have received a copy of the GNU General Public License
18
+  along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
19
+*/
20
+
21
+#ifndef temperature_h
22
+#define temperature_h 
23
+
24
+#include "Marlin.h"
25
+#include "fastio.h"
26
+#include "planner.h"
27
+#ifdef PID_ADD_EXTRUSION_RATE
28
+  #include "stepper.h"
29
+#endif
30
+
31
+// public functions
32
+void tp_init();  //initialise the heating
33
+void manage_heater(); //it is critical that this is called periodically.
34
+
35
+//low leven conversion routines
36
+// do not use this routines and variables outsie of temperature.cpp
37
+int temp2analog(int celsius, uint8_t e);
38
+int temp2analogBed(int celsius);
39
+float analog2temp(int raw, uint8_t e);
40
+float analog2tempBed(int raw);
41
+extern int target_raw[EXTRUDERS];  
42
+extern int heatingtarget_raw[EXTRUDERS];  
43
+extern int current_raw[EXTRUDERS];
44
+extern int target_raw_bed;
45
+extern int current_raw_bed;
46
+extern float Kp,Ki,Kd,Kc;
47
+
48
+#ifdef PIDTEMP
49
+  extern float pid_setpoint[EXTRUDERS];
50
+#endif
51
+  
52
+// #ifdef WATCHPERIOD
53
+  extern int watch_raw[EXTRUDERS] ;
54
+//   extern unsigned long watchmillis;
55
+// #endif
56
+
57
+
58
+//high level conversion routines, for use outside of temperature.cpp
59
+//inline so that there is no performance decrease.
60
+//deg=degreeCelsius
61
+
62
+FORCE_INLINE float degHotend(uint8_t extruder) {  
63
+  return analog2temp(current_raw[extruder], extruder);
64
+};
65
+
66
+FORCE_INLINE float degBed() {
67
+  return analog2tempBed(current_raw_bed);
68
+};
69
+
70
+FORCE_INLINE float degTargetHotend(uint8_t extruder) {  
71
+  return analog2temp(target_raw[extruder], extruder);
72
+};
73
+
74
+FORCE_INLINE float degTargetBed() {   
75
+  return analog2tempBed(target_raw_bed);
76
+};
77
+
78
+FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {  
79
+  target_raw[extruder] = temp2analog(celsius, extruder);
80
+#ifdef PIDTEMP
81
+  pid_setpoint[extruder] = celsius;
82
+#endif //PIDTEMP
83
+};
84
+
85
+FORCE_INLINE void setTargetBed(const float &celsius) {  
86
+  target_raw_bed = temp2analogBed(celsius);
87
+};
88
+
89
+FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  
90
+  return target_raw[extruder] > current_raw[extruder];
91
+};
92
+
93
+FORCE_INLINE bool isHeatingBed() {
94
+  return target_raw_bed > current_raw_bed;
95
+};
96
+
97
+FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {  
98
+  return target_raw[extruder] < current_raw[extruder];
99
+};
100
+
101
+FORCE_INLINE bool isCoolingBed() {
102
+  return target_raw_bed < current_raw_bed;
103
+};
104
+
105
+#define degHotend0() degHotend(0)
106
+#define degTargetHotend0() degTargetHotend(0)
107
+#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
108
+#define isHeatingHotend0() isHeatingHotend(0)
109
+#define isCoolingHotend0() isCoolingHotend(0)
110
+#if EXTRUDERS > 1
111
+#define degHotend1() degHotend(1)
112
+#define degTargetHotend1() degTargetHotend(1)
113
+#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
114
+#define isHeatingHotend1() isHeatingHotend(1)
115
+#define isCoolingHotend1() isCoolingHotend(1)
116
+#endif
117
+#if EXTRUDERS > 2
118
+#define degHotend2() degHotend(2)
119
+#define degTargetHotend2() degTargetHotend(2)
120
+#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
121
+#define isHeatingHotend2() isHeatingHotend(2)
122
+#define isCoolingHotend2() isCoolingHotend(2)
123
+#endif
124
+#if EXTRUDERS > 3
125
+#error Invalid number of extruders
126
+#endif
127
+
128
+FORCE_INLINE void autotempShutdown(){
129
+ #ifdef AUTOTEMP
130
+ if(autotemp_enabled)
131
+ {
132
+  autotemp_enabled=false;
133
+  if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
134
+    setTargetHotend(0,ACTIVE_EXTRUDER);
135
+ }
136
+ #endif
137
+}
138
+
139
+int getHeaterPower(int heater);
140
+void disable_heater();
141
+void setWatch();
142
+void updatePID();
143
+
144
+#endif
144 145
 

+ 11
- 6
Marlin/ultralcd.pde Näytä tiedosto

@@ -441,7 +441,7 @@ void MainMenu::showStatus()
441 441
   force_lcd_update=false;
442 442
 }
443 443
 
444
-enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
444
+enum {ItemP_exit, ItemP_autostart,ItemP_disstep,ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude};
445 445
 
446 446
 //any action must not contain a ',' character anywhere, or this breaks:
447 447
 #define MENUITEM(repaint_action, click_action) \
@@ -462,6 +462,12 @@ void MainMenu::showPrepare()
462 462
     case ItemP_exit:
463 463
       MENUITEM(  lcdprintPGM(" Main \003")  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
464 464
       break;
465
+    case ItemP_autostart:
466
+      MENUITEM(  lcdprintPGM(" Autostart")  ,  BLOCK;card.lastnr=0;card.checkautostart(true);beepshort(); ) ;
467
+      break;
468
+    case ItemP_disstep:
469
+      MENUITEM(  lcdprintPGM(" Disable Steppers")  ,  BLOCK;enquecommand("M84");beepshort(); ) ;
470
+      break;
465 471
     case ItemP_home:
466 472
       MENUITEM(  lcdprintPGM(" Auto Home")  ,  BLOCK;enquecommand("G28 X-105 Y-105 Z0");beepshort(); ) ;
467 473
       break;
@@ -474,15 +480,14 @@ void MainMenu::showPrepare()
474 480
     case ItemP_extrude:
475 481
       MENUITEM(  lcdprintPGM(" Extrude")  ,  BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
476 482
       break;
477
-    case ItemP_disstep:
478
-      MENUITEM(  lcdprintPGM(" Disable Steppers")  ,  BLOCK;enquecommand("M84");beepshort(); ) ;
479
-      break;
483
+    
484
+    
480 485
     default:   
481 486
       break;
482 487
   }
483 488
   line++;
484 489
  }
485
- updateActiveLines(ItemP_disstep,encoderpos);
490
+ updateActiveLines(ItemP_extrude,encoderpos);
486 491
 }
487 492
 
488 493
 enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan};
@@ -1840,4 +1845,4 @@ char *ftostr51(const float &x)
1840 1845
 
1841 1846
 #endif //ULTRA_LCD
1842 1847
 
1843
-
1848
+

Loading…
Peruuta
Tallenna