Browse 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 13 years ago
parent
commit
63aec3c56e
5 changed files with 86 additions and 38 deletions
  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 View File

29
 // Ultimaker = 7
29
 // Ultimaker = 7
30
 // Teensylu = 8
30
 // Teensylu = 8
31
 // Gen3+ =9
31
 // Gen3+ =9
32
+
32
 #ifndef MOTHERBOARD
33
 #ifndef MOTHERBOARD
33
 #define MOTHERBOARD 7
34
 #define MOTHERBOARD 7
34
 #endif
35
 #endif
88
 
89
 
89
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
90
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
90
 // Ultimaker
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
 // Makergear
96
 // Makergear
96
 //    #define  DEFAULT_Kp 7.0
97
 //    #define  DEFAULT_Kp 7.0
98
 //    #define  DEFAULT_Kd 12  
99
 //    #define  DEFAULT_Kd 12  
99
 
100
 
100
 // Mendel Parts V9 on 12V    
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
 #endif // PIDTEMP
105
 #endif // PIDTEMP
105
 
106
 
106
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
107
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
202
   #define ULTRA_LCD
203
   #define ULTRA_LCD
203
   #define LCD_WIDTH 20
204
   #define LCD_WIDTH 20
204
   #define LCD_HEIGHT 4
205
   #define LCD_HEIGHT 4
205
-
206
+  
206
 // Preheat Constants
207
 // Preheat Constants
207
   #define PLA_PREHEAT_HOTEND_TEMP 180 
208
   #define PLA_PREHEAT_HOTEND_TEMP 180 
208
   #define PLA_PREHEAT_HPB_TEMP 70
209
   #define PLA_PREHEAT_HPB_TEMP 70
215
 #else //no panel but just lcd 
216
 #else //no panel but just lcd 
216
   #ifdef ULTRA_LCD
217
   #ifdef ULTRA_LCD
217
     #define LCD_WIDTH 16
218
     #define LCD_WIDTH 16
218
-    #define LCD_HEIGHT 2
219
+    #define LCD_HEIGHT 2    
219
   #endif
220
   #endif
220
 #endif
221
 #endif
221
 
222
 

+ 3
- 0
Marlin/Marlin.h View File

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

+ 51
- 17
Marlin/Marlin.pde View File

110
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
110
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
111
 // M503 - print the current settings (from memory not from eeprom)
111
 // M503 - print the current settings (from memory not from eeprom)
112
 // M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
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
 //Stepper Movement Variables
115
 //Stepper Movement Variables
115
 
116
 
135
 uint8_t active_extruder = 0;
136
 uint8_t active_extruder = 0;
136
 unsigned char FanSpeed=0;
137
 unsigned char FanSpeed=0;
137
 
138
 
139
+
138
 //===========================================================================
140
 //===========================================================================
139
 //=============================private variables=============================
141
 //=============================private variables=============================
140
 //===========================================================================
142
 //===========================================================================
143
 static float offset[3] = {0.0, 0.0, 0.0};
145
 static float offset[3] = {0.0, 0.0, 0.0};
144
 static bool home_all_axis = true;
146
 static bool home_all_axis = true;
145
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
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
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
150
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
149
 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.
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
 
176
 
175
 static uint8_t tmp_extruder;
177
 static uint8_t tmp_extruder;
176
 
178
 
179
+bool Stopped=false;
177
 
180
 
178
 //===========================================================================
181
 //===========================================================================
179
 //=============================ROUTINES=============================
182
 //=============================ROUTINES=============================
415
           case 1:
418
           case 1:
416
           case 2:
419
           case 2:
417
           case 3:
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
             break;
432
             break;
424
           default:
433
           default:
425
             break;
434
             break;
547
     {
556
     {
548
     case 0: // G0 -> G1
557
     case 0: // G0 -> G1
549
     case 1: // G1
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
       //break;
565
       //break;
555
     case 2: // G2  - CW ARC
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
     case 3: // G3  - CCW ARC
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
     case 4: // G4 dwell
578
     case 4: // G4 dwell
564
       LCD_MESSAGEPGM(MSG_DWELL);
579
       LCD_MESSAGEPGM(MSG_DWELL);
565
       codenum = 0;
580
       codenum = 0;
972
     #if (PS_ON_PIN > -1)
987
     #if (PS_ON_PIN > -1)
973
       case 80: // M80 - ATX Power On
988
       case 80: // M80 - ATX Power On
974
         SET_OUTPUT(PS_ON_PIN); //GND
989
         SET_OUTPUT(PS_ON_PIN); //GND
990
+        WRITE(PS_ON_PIN, LOW);
975
         break;
991
         break;
976
       #endif
992
       #endif
977
       
993
       
1236
       EEPROM_printSettings();
1252
       EEPROM_printSettings();
1237
     }
1253
     }
1238
     break;
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
   while(1); // Wait for reset
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 View File

78
 	#define MSG_NO_MOVE "No move."
78
 	#define MSG_NO_MOVE "No move."
79
 	#define MSG_PART_RELEASE "Partial Release"
79
 	#define MSG_PART_RELEASE "Partial Release"
80
 	#define MSG_KILLED "KILLED. "
80
 	#define MSG_KILLED "KILLED. "
81
+        #define MSG_STOPPED "STOPPED. "
81
 	#define MSG_PREHEAT_PLA " Preheat PLA"
82
 	#define MSG_PREHEAT_PLA " Preheat PLA"
82
 	#define MSG_PREHEAT_ABS " Preheat ABS"
83
 	#define MSG_PREHEAT_ABS " Preheat ABS"
83
 	#define MSG_STEPPER_RELEASED "Released."
84
 	#define MSG_STEPPER_RELEASED "Released."
116
 	#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
 	#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
 	#define MSG_COUNT_X " Count X:"
118
 	#define MSG_COUNT_X " Count X:"
118
 	#define MSG_ERR_KILLED "Printer halted. kill() called !!"
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
 	#define MSG_RESEND "Resend:"
121
 	#define MSG_RESEND "Resend:"
120
 	#define MSG_UNKNOWN_COMMAND "Unknown command:\""
122
 	#define MSG_UNKNOWN_COMMAND "Unknown command:\""
121
 	#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
123
 	#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
221
 	#define MSG_NO_MOVE "No move."
223
 	#define MSG_NO_MOVE "No move."
222
 	#define MSG_PART_RELEASE "Partial Release"
224
 	#define MSG_PART_RELEASE "Partial Release"
223
 	#define MSG_KILLED "KILLED. "
225
 	#define MSG_KILLED "KILLED. "
226
+	#define MSG_STOPPED "STOPPED. "
224
 	#define MSG_PREHEAT_PLA " Preheat PLA"
227
 	#define MSG_PREHEAT_PLA " Preheat PLA"
225
 	#define MSG_PREHEAT_ABS " Preheat ABS"
228
 	#define MSG_PREHEAT_ABS " Preheat ABS"
226
 	#define MSG_STEPPER_RELEASED "Released."
229
 	#define MSG_STEPPER_RELEASED "Released."
259
 	#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"
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
 	#define MSG_COUNT_X " Count X:"
263
 	#define MSG_COUNT_X " Count X:"
261
 	#define MSG_ERR_KILLED "Printer halted. kill() called !!"
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
 	#define MSG_RESEND "Resend:"
266
 	#define MSG_RESEND "Resend:"
263
 	#define MSG_UNKNOWN_COMMAND "Unknown command:\""
267
 	#define MSG_UNKNOWN_COMMAND "Unknown command:\""
264
 	#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
268
 	#define MSG_ACTIVE_EXTRUDER "Active Extruder: "

+ 19
- 13
Marlin/temperature.cpp View File

51
   float pid_setpoint[EXTRUDERS] = { 0.0 };
51
   float pid_setpoint[EXTRUDERS] = { 0.0 };
52
   
52
   
53
   float Kp=DEFAULT_Kp;
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
   #ifdef PID_ADD_EXTRUSION_RATE
56
   #ifdef PID_ADD_EXTRUSION_RATE
57
     float Kc=DEFAULT_Kc;
57
     float Kc=DEFAULT_Kc;
58
   #endif
58
   #endif
708
 
708
 
709
 void max_temp_error(uint8_t e) {
709
 void max_temp_error(uint8_t e) {
710
   digitalWrite(heater_pin_map[e], 0);
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
 void min_temp_error(uint8_t e) {
718
 void min_temp_error(uint8_t e) {
717
   digitalWrite(heater_pin_map[e], 0);
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
 void bed_max_temp_error(void) {
727
 void bed_max_temp_error(void) {
724
   digitalWrite(HEATER_BED_PIN, 0);
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
 #define HEAT_INTERVAL 250
735
 #define HEAT_INTERVAL 250
956
           max_temp_error(e);
962
           max_temp_error(e);
957
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
963
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
958
           {
964
           {
959
-            kill();;
965
+            Stop();;
960
           }
966
           }
961
           #endif
967
           #endif
962
        }
968
        }
965
           min_temp_error(e);
971
           min_temp_error(e);
966
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
972
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
967
           {
973
           {
968
-            kill();
974
+            Stop();
969
           }
975
           }
970
           #endif
976
           #endif
971
        }
977
        }
975
     if(current_raw_bed >= bed_maxttemp) {
981
     if(current_raw_bed >= bed_maxttemp) {
976
        target_raw_bed = 0;
982
        target_raw_bed = 0;
977
        bed_max_temp_error();
983
        bed_max_temp_error();
978
-       kill();
984
+       Stop();
979
     }
985
     }
980
 #endif
986
 #endif
981
   }
987
   }

Loading…
Cancel
Save