chiark / gitweb /
Replaced Kill by Stop. If the printer is stopped. Fix the error and use M999 to restart.
authorErik van der Zalm <erik@vdzalm.eu>
Sun, 25 Mar 2012 12:36:51 +0000 (14:36 +0200)
committerErik van der Zalm <erik@vdzalm.eu>
Sun, 25 Mar 2012 12:36:51 +0000 (14:36 +0200)
Moved the PID_dT in the Ki and Kd calculation from the configuration.h to temperature.cpp

Marlin/Configuration.h
Marlin/Marlin.h
Marlin/Marlin.pde
Marlin/language.h
Marlin/temperature.cpp

index 896c93aa18f68268f5e7be72aaf40528a7a2b163..2adda3fd612074cc7af8ec030a2fc15924ef7513 100644 (file)
@@ -29,6 +29,7 @@
 // Ultimaker = 7
 // Teensylu = 8
 // Gen3+ =9
+
 #ifndef MOTHERBOARD
 #define MOTHERBOARD 7
 #endif
@@ -88,9 +89,9 @@
 
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
 // Ultimaker
-    #define  DEFAULT_Kp  22.2
-    #define  DEFAULT_Ki (1.08*PID_dT)  
-    #define  DEFAULT_Kd (114/PID_dT)  
+    #define  DEFAULT_Kp 22.2
+    #define  DEFAULT_Ki 1.08  
+    #define  DEFAULT_Kd 114  
 
 // Makergear
 //    #define  DEFAULT_Kp 7.0
@@ -98,9 +99,9 @@
 //    #define  DEFAULT_Kd 12  
 
 // Mendel Parts V9 on 12V    
-//    #define  DEFAULT_Kp  63.0
-//    #define  DEFAULT_Ki (2.25*PID_dT)  
-//    #define  DEFAULT_Kd (440/PID_dT)
+//    #define  DEFAULT_Kp 63.0
+//    #define  DEFAULT_Ki 2.25
+//    #define  DEFAULT_Kd 440
 #endif // PIDTEMP
 
 //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
   #define ULTRA_LCD
   #define LCD_WIDTH 20
   #define LCD_HEIGHT 4
-
+  
 // Preheat Constants
   #define PLA_PREHEAT_HOTEND_TEMP 180 
   #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
 #else //no panel but just lcd 
   #ifdef ULTRA_LCD
     #define LCD_WIDTH 16
-    #define LCD_HEIGHT 2
+    #define LCD_HEIGHT 2    
   #endif
 #endif
 
index 919287260b2c3822f8ac8c87c4c96d792fcb021a..c30c5da43cffd6f1304a38aafdcb0bb613464fe1 100644 (file)
@@ -162,6 +162,9 @@ void ClearToSend();
 void get_coordinates();
 void prepare_move();
 void kill();
+void Stop();
+
+bool IsStopped();
 
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
 void prepare_arc_move(char isclockwise);
index 5d8094006fb35a0c3467995a8762859b6c1996db..5ee40c038ccca52b596cb5250b8f1198c2339bcb 100644 (file)
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
 // M503 - print the current settings (from memory not from eeprom)
 // M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
+// M999 - Restart after being stopped by error
 
 //Stepper Movement Variables
 
@@ -135,6 +136,7 @@ float add_homeing[3]={0,0,0};
 uint8_t active_extruder = 0;
 unsigned char FanSpeed=0;
 
+
 //===========================================================================
 //=============================private variables=============================
 //===========================================================================
@@ -143,7 +145,7 @@ static float destination[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
 static float offset[3] = {0.0, 0.0, 0.0};
 static bool home_all_axis = true;
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
-static long gcode_N, gcode_LastN;
+static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
 
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
 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;
 
 static uint8_t tmp_extruder;
 
+bool Stopped=false;
 
 //===========================================================================
 //=============================ROUTINES=============================
@@ -415,11 +418,17 @@ void get_command()
           case 1:
           case 2:
           case 3:
-           #ifdef SDSUPPORT
-            if(card.saving)
-              break;
-           #endif //SDSUPPORT
-            SERIAL_PROTOCOLLNPGM(MSG_OK); 
+            if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
+             #ifdef SDSUPPORT
+              if(card.saving)
+                break;
+             #endif //SDSUPPORT
+              SERIAL_PROTOCOLLNPGM(MSG_OK); 
+            }
+            else {
+              SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
+              LCD_MESSAGEPGM(MSG_STOPPED);
+            }
             break;
           default:
             break;
@@ -547,19 +556,25 @@ void process_commands()
     {
     case 0: // G0 -> G1
     case 1: // G1
-      get_coordinates(); // For X Y Z E F
-      prepare_move();
-      //ClearToSend();
-      return;
+      if(Stopped == false) {
+        get_coordinates(); // For X Y Z E F
+        prepare_move();
+        //ClearToSend();
+        return;
+      }
       //break;
     case 2: // G2  - CW ARC
-      get_arc_coordinates();
-      prepare_arc_move(true);
-      return;
+      if(Stopped == false) {
+        get_arc_coordinates();
+        prepare_arc_move(true);
+        return;
+      }
     case 3: // G3  - CCW ARC
-      get_arc_coordinates();
-      prepare_arc_move(false);
-      return;
+      if(Stopped == false) {
+        get_arc_coordinates();
+        prepare_arc_move(false);
+        return;
+      }
     case 4: // G4 dwell
       LCD_MESSAGEPGM(MSG_DWELL);
       codenum = 0;
@@ -972,6 +987,7 @@ void process_commands()
     #if (PS_ON_PIN > -1)
       case 80: // M80 - ATX Power On
         SET_OUTPUT(PS_ON_PIN); //GND
+        WRITE(PS_ON_PIN, LOW);
         break;
       #endif
       
@@ -1236,7 +1252,11 @@ void process_commands()
       EEPROM_printSettings();
     }
     break;
-
+    case 999: // Restart after being stopped
+      Stopped = false;
+      gcode_LastN = Stopped_gcode_LastN;
+      FlushSerialRequestResend();
+    break;
     }
   }
 
@@ -1438,4 +1458,18 @@ void kill()
   while(1); // Wait for reset
 }
 
+void Stop()
+{
+  disable_heater();
+  if(Stopped == false) {
+    Stopped = true;
+    Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
+    SERIAL_ERROR_START;
+    SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
+    LCD_MESSAGEPGM(MSG_STOPPED);
+  }
+}
+
+bool IsStopped() { return Stopped; };
+
 
index 2cdbc594263997fbe9167249539c29134868bb63..42a9c67f4eba2b6b31ad83175f520fc168f5991c 100644 (file)
@@ -78,6 +78,7 @@
        #define MSG_NO_MOVE "No move."
        #define MSG_PART_RELEASE "Partial Release"
        #define MSG_KILLED "KILLED. "
+        #define MSG_STOPPED "STOPPED. "
        #define MSG_PREHEAT_PLA " Preheat PLA"
        #define MSG_PREHEAT_ABS " Preheat ABS"
        #define MSG_STEPPER_RELEASED "Released."
        #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"
        #define MSG_COUNT_X " Count X:"
        #define MSG_ERR_KILLED "Printer halted. kill() called !!"
+       #define MSG_ERR_STOPPED "Printer stopped deu to errors. Fix the error and use M999 to restart!. (Temperature is reset. Set it before restarting)"
        #define MSG_RESEND "Resend:"
        #define MSG_UNKNOWN_COMMAND "Unknown command:\""
        #define MSG_ACTIVE_EXTRUDER "Active Extruder: "
        #define MSG_NO_MOVE "No move."
        #define MSG_PART_RELEASE "Partial Release"
        #define MSG_KILLED "KILLED. "
+       #define MSG_STOPPED "STOPPED. "
        #define MSG_PREHEAT_PLA " Preheat PLA"
        #define MSG_PREHEAT_ABS " Preheat ABS"
        #define MSG_STEPPER_RELEASED "Released."
        #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"
        #define MSG_COUNT_X " Count X:"
        #define MSG_ERR_KILLED "Printer halted. kill() called !!"
+       #define MSG_ERR_STOPPED "Printer stopped deu to errors. Fix the error and use M999 to restart!"
        #define MSG_RESEND "Resend:"
        #define MSG_UNKNOWN_COMMAND "Unknown command:\""
        #define MSG_ACTIVE_EXTRUDER "Active Extruder: "
index 8aedf269b68e3d583e7e0d7d33ecfd5fe23680fb..0529b534afd7f56ea055a9090084c7e0b88d31de 100644 (file)
@@ -51,8 +51,8 @@ int current_raw_bed = 0;
   float pid_setpoint[EXTRUDERS] = { 0.0 };
   
   float Kp=DEFAULT_Kp;
-  float Ki=DEFAULT_Ki;
-  float Kd=DEFAULT_Kd;
+  float Ki=(DEFAULT_Ki*PID_dT);
+  float Kd=(DEFAULT_Kd/PID_dT);
   #ifdef PID_ADD_EXTRUSION_RATE
     float Kc=DEFAULT_Kc;
   #endif
@@ -708,22 +708,28 @@ void disable_heater()
 
 void max_temp_error(uint8_t e) {
   digitalWrite(heater_pin_map[e], 0);
-  SERIAL_ERROR_START;
-  SERIAL_ERRORLN(e);
-  SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
+  if(IsStopped() == false) {
+    SERIAL_ERROR_START;
+    SERIAL_ERRORLN(e);
+    SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
+  }
 }
 
 void min_temp_error(uint8_t e) {
   digitalWrite(heater_pin_map[e], 0);
-  SERIAL_ERROR_START;
-  SERIAL_ERRORLN(e);
-  SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
+  if(IsStopped() == false) {
+    SERIAL_ERROR_START;
+    SERIAL_ERRORLN(e);
+    SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
+  }
 }
 
 void bed_max_temp_error(void) {
   digitalWrite(HEATER_BED_PIN, 0);
-  SERIAL_ERROR_START;
-  SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
+  if(IsStopped() == false) {
+    SERIAL_ERROR_START;
+    SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
+  }
 }
 
 #define HEAT_INTERVAL 250
@@ -956,7 +962,7 @@ ISR(TIMER0_COMPB_vect)
           max_temp_error(e);
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
           {
-            kill();;
+            Stop();;
           }
           #endif
        }
@@ -965,7 +971,7 @@ ISR(TIMER0_COMPB_vect)
           min_temp_error(e);
           #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
           {
-            kill();
+            Stop();
           }
           #endif
        }
@@ -975,7 +981,7 @@ ISR(TIMER0_COMPB_vect)
     if(current_raw_bed >= bed_maxttemp) {
        target_raw_bed = 0;
        bed_max_temp_error();
-       kill();
+       Stop();
     }
 #endif
   }