Parcourir la source

Replaced Kill by Stop. If the printer is stopped. Fix the error and use M999 to restart.

Moved the PID_dT in the Ki and Kd calculation from the configuration.h to temperature.cpp
Erik van der Zalm il y a 13 ans
Parent
révision
63aec3c56e
5 fichiers modifiés avec 86 ajouts et 38 suppressions
  1. 9
    8
      Marlin/Configuration.h
  2. 3
    0
      Marlin/Marlin.h
  3. 51
    17
      Marlin/Marlin.pde
  4. 4
    0
      Marlin/language.h
  5. 19
    13
      Marlin/temperature.cpp

+ 9
- 8
Marlin/Configuration.h Voir le fichier

@@ -29,6 +29,7 @@
29 29
 // Ultimaker = 7
30 30
 // Teensylu = 8
31 31
 // Gen3+ =9
32
+
32 33
 #ifndef MOTHERBOARD
33 34
 #define MOTHERBOARD 7
34 35
 #endif
@@ -88,9 +89,9 @@
88 89
 
89 90
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
90 91
 // Ultimaker
91
-    #define  DEFAULT_Kp  22.2
92
-    #define  DEFAULT_Ki (1.08*PID_dT)  
93
-    #define  DEFAULT_Kd (114/PID_dT)  
92
+    #define  DEFAULT_Kp 22.2
93
+    #define  DEFAULT_Ki 1.08  
94
+    #define  DEFAULT_Kd 114  
94 95
 
95 96
 // Makergear
96 97
 //    #define  DEFAULT_Kp 7.0
@@ -98,9 +99,9 @@
98 99
 //    #define  DEFAULT_Kd 12  
99 100
 
100 101
 // Mendel Parts V9 on 12V    
101
-//    #define  DEFAULT_Kp  63.0
102
-//    #define  DEFAULT_Ki (2.25*PID_dT)  
103
-//    #define  DEFAULT_Kd (440/PID_dT)
102
+//    #define  DEFAULT_Kp 63.0
103
+//    #define  DEFAULT_Ki 2.25
104
+//    #define  DEFAULT_Kd 440
104 105
 #endif // PIDTEMP
105 106
 
106 107
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
@@ -202,7 +203,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
202 203
   #define ULTRA_LCD
203 204
   #define LCD_WIDTH 20
204 205
   #define LCD_HEIGHT 4
205
-
206
+  
206 207
 // Preheat Constants
207 208
   #define PLA_PREHEAT_HOTEND_TEMP 180 
208 209
   #define PLA_PREHEAT_HPB_TEMP 70
@@ -215,7 +216,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
215 216
 #else //no panel but just lcd 
216 217
   #ifdef ULTRA_LCD
217 218
     #define LCD_WIDTH 16
218
-    #define LCD_HEIGHT 2
219
+    #define LCD_HEIGHT 2    
219 220
   #endif
220 221
 #endif
221 222
 

+ 3
- 0
Marlin/Marlin.h Voir le fichier

@@ -162,6 +162,9 @@ void ClearToSend();
162 162
 void get_coordinates();
163 163
 void prepare_move();
164 164
 void kill();
165
+void Stop();
166
+
167
+bool IsStopped();
165 168
 
166 169
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
167 170
 void prepare_arc_move(char isclockwise);

+ 51
- 17
Marlin/Marlin.pde Voir le fichier

@@ -110,6 +110,7 @@
110 110
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
111 111
 // M503 - print the current settings (from memory not from eeprom)
112 112
 // M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
113
+// M999 - Restart after being stopped by error
113 114
 
114 115
 //Stepper Movement Variables
115 116
 
@@ -135,6 +136,7 @@ float add_homeing[3]={0,0,0};
135 136
 uint8_t active_extruder = 0;
136 137
 unsigned char FanSpeed=0;
137 138
 
139
+
138 140
 //===========================================================================
139 141
 //=============================private variables=============================
140 142
 //===========================================================================
@@ -143,7 +145,7 @@ static float destination[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
143 145
 static float offset[3] = {0.0, 0.0, 0.0};
144 146
 static bool home_all_axis = true;
145 147
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
146
-static long gcode_N, gcode_LastN;
148
+static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
147 149
 
148 150
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
149 151
 static bool relative_mode_e = false;  //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
@@ -174,6 +176,7 @@ static unsigned long stoptime=0;
174 176
 
175 177
 static uint8_t tmp_extruder;
176 178
 
179
+bool Stopped=false;
177 180
 
178 181
 //===========================================================================
179 182
 //=============================ROUTINES=============================
@@ -415,11 +418,17 @@ void get_command()
415 418
           case 1:
416 419
           case 2:
417 420
           case 3:
418
-	    #ifdef SDSUPPORT
419
-            if(card.saving)
420
-              break;
421
-	    #endif //SDSUPPORT
422
-            SERIAL_PROTOCOLLNPGM(MSG_OK); 
421
+            if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
422
+	      #ifdef SDSUPPORT
423
+              if(card.saving)
424
+                break;
425
+	      #endif //SDSUPPORT
426
+              SERIAL_PROTOCOLLNPGM(MSG_OK); 
427
+            }
428
+            else {
429
+              SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
430
+              LCD_MESSAGEPGM(MSG_STOPPED);
431
+            }
423 432
             break;
424 433
           default:
425 434
             break;
@@ -547,19 +556,25 @@ void process_commands()
547 556
     {
548 557
     case 0: // G0 -> G1
549 558
     case 1: // G1
550
-      get_coordinates(); // For X Y Z E F
551
-      prepare_move();
552
-      //ClearToSend();
553
-      return;
559
+      if(Stopped == false) {
560
+        get_coordinates(); // For X Y Z E F
561
+        prepare_move();
562
+        //ClearToSend();
563
+        return;
564
+      }
554 565
       //break;
555 566
     case 2: // G2  - CW ARC
556
-      get_arc_coordinates();
557
-      prepare_arc_move(true);
558
-      return;
567
+      if(Stopped == false) {
568
+        get_arc_coordinates();
569
+        prepare_arc_move(true);
570
+        return;
571
+      }
559 572
     case 3: // G3  - CCW ARC
560
-      get_arc_coordinates();
561
-      prepare_arc_move(false);
562
-      return;
573
+      if(Stopped == false) {
574
+        get_arc_coordinates();
575
+        prepare_arc_move(false);
576
+        return;
577
+      }
563 578
     case 4: // G4 dwell
564 579
       LCD_MESSAGEPGM(MSG_DWELL);
565 580
       codenum = 0;
@@ -972,6 +987,7 @@ void process_commands()
972 987
     #if (PS_ON_PIN > -1)
973 988
       case 80: // M80 - ATX Power On
974 989
         SET_OUTPUT(PS_ON_PIN); //GND
990
+        WRITE(PS_ON_PIN, LOW);
975 991
         break;
976 992
       #endif
977 993
       
@@ -1236,7 +1252,11 @@ void process_commands()
1236 1252
       EEPROM_printSettings();
1237 1253
     }
1238 1254
     break;
1239
-
1255
+    case 999: // Restart after being stopped
1256
+      Stopped = false;
1257
+      gcode_LastN = Stopped_gcode_LastN;
1258
+      FlushSerialRequestResend();
1259
+    break;
1240 1260
     }
1241 1261
   }
1242 1262
 
@@ -1438,4 +1458,18 @@ void kill()
1438 1458
   while(1); // Wait for reset
1439 1459
 }
1440 1460
 
1461
+void Stop()
1462
+{
1463
+  disable_heater();
1464
+  if(Stopped == false) {
1465
+    Stopped = true;
1466
+    Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
1467
+    SERIAL_ERROR_START;
1468
+    SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
1469
+    LCD_MESSAGEPGM(MSG_STOPPED);
1470
+  }
1471
+}
1472
+
1473
+bool IsStopped() { return Stopped; };
1474
+
1441 1475
 

+ 4
- 0
Marlin/language.h Voir le fichier

@@ -78,6 +78,7 @@
78 78
 	#define MSG_NO_MOVE "No move."
79 79
 	#define MSG_PART_RELEASE "Partial Release"
80 80
 	#define MSG_KILLED "KILLED. "
81
+        #define MSG_STOPPED "STOPPED. "
81 82
 	#define MSG_PREHEAT_PLA " Preheat PLA"
82 83
 	#define MSG_PREHEAT_ABS " Preheat ABS"
83 84
 	#define MSG_STEPPER_RELEASED "Released."
@@ -116,6 +117,7 @@
116 117
 	#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
117 118
 	#define MSG_COUNT_X " Count X:"
118 119
 	#define MSG_ERR_KILLED "Printer halted. kill() called !!"
120
+	#define MSG_ERR_STOPPED "Printer stopped deu to errors. Fix the error and use M999 to restart!. (Temperature is reset. Set it before restarting)"
119 121
 	#define MSG_RESEND "Resend:"
120 122
 	#define MSG_UNKNOWN_COMMAND "Unknown command:\""
121 123
 	#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
@@ -221,6 +223,7 @@
221 223
 	#define MSG_NO_MOVE "No move."
222 224
 	#define MSG_PART_RELEASE "Partial Release"
223 225
 	#define MSG_KILLED "KILLED. "
226
+	#define MSG_STOPPED "STOPPED. "
224 227
 	#define MSG_PREHEAT_PLA " Preheat PLA"
225 228
 	#define MSG_PREHEAT_ABS " Preheat ABS"
226 229
 	#define MSG_STEPPER_RELEASED "Released."
@@ -259,6 +262,7 @@
259 262
 	#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
260 263
 	#define MSG_COUNT_X " Count X:"
261 264
 	#define MSG_ERR_KILLED "Printer halted. kill() called !!"
265
+	#define MSG_ERR_STOPPED "Printer stopped deu to errors. Fix the error and use M999 to restart!"
262 266
 	#define MSG_RESEND "Resend:"
263 267
 	#define MSG_UNKNOWN_COMMAND "Unknown command:\""
264 268
 	#define MSG_ACTIVE_EXTRUDER "Active Extruder: "

+ 19
- 13
Marlin/temperature.cpp Voir le fichier

@@ -51,8 +51,8 @@ int current_raw_bed = 0;
51 51
   float pid_setpoint[EXTRUDERS] = { 0.0 };
52 52
   
53 53
   float Kp=DEFAULT_Kp;
54
-  float Ki=DEFAULT_Ki;
55
-  float Kd=DEFAULT_Kd;
54
+  float Ki=(DEFAULT_Ki*PID_dT);
55
+  float Kd=(DEFAULT_Kd/PID_dT);
56 56
   #ifdef PID_ADD_EXTRUSION_RATE
57 57
     float Kc=DEFAULT_Kc;
58 58
   #endif
@@ -708,22 +708,28 @@ void disable_heater()
708 708
 
709 709
 void max_temp_error(uint8_t e) {
710 710
   digitalWrite(heater_pin_map[e], 0);
711
-  SERIAL_ERROR_START;
712
-  SERIAL_ERRORLN(e);
713
-  SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
711
+  if(IsStopped() == false) {
712
+    SERIAL_ERROR_START;
713
+    SERIAL_ERRORLN(e);
714
+    SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
715
+  }
714 716
 }
715 717
 
716 718
 void min_temp_error(uint8_t e) {
717 719
   digitalWrite(heater_pin_map[e], 0);
718
-  SERIAL_ERROR_START;
719
-  SERIAL_ERRORLN(e);
720
-  SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
720
+  if(IsStopped() == false) {
721
+    SERIAL_ERROR_START;
722
+    SERIAL_ERRORLN(e);
723
+    SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
724
+  }
721 725
 }
722 726
 
723 727
 void bed_max_temp_error(void) {
724 728
   digitalWrite(HEATER_BED_PIN, 0);
725
-  SERIAL_ERROR_START;
726
-  SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
729
+  if(IsStopped() == false) {
730
+    SERIAL_ERROR_START;
731
+    SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
732
+  }
727 733
 }
728 734
 
729 735
 #define HEAT_INTERVAL 250
@@ -956,7 +962,7 @@ ISR(TIMER0_COMPB_vect)
956 962
           max_temp_error(e);
957 963
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
958 964
           {
959
-            kill();;
965
+            Stop();;
960 966
           }
961 967
           #endif
962 968
        }
@@ -965,7 +971,7 @@ ISR(TIMER0_COMPB_vect)
965 971
           min_temp_error(e);
966 972
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
967 973
           {
968
-            kill();
974
+            Stop();
969 975
           }
970 976
           #endif
971 977
        }
@@ -975,7 +981,7 @@ ISR(TIMER0_COMPB_vect)
975 981
     if(current_raw_bed >= bed_maxttemp) {
976 982
        target_raw_bed = 0;
977 983
        bed_max_temp_error();
978
-       kill();
984
+       Stop();
979 985
     }
980 986
 #endif
981 987
   }

Chargement…
Annuler
Enregistrer