chiark / gitweb /
fixed bug with adjusting ki in realtime.
authorBernhard Kubicek <kubicek@gmx.at>
Sun, 13 Nov 2011 20:43:26 +0000 (21:43 +0100)
committerBernhard Kubicek <kubicek@gmx.at>
Sun, 13 Nov 2011 20:43:26 +0000 (21:43 +0100)
Marlin/Configuration.h
Marlin/Marlin.pde
Marlin/temperature.cpp
Marlin/temperature.h

index 8661ae438e78afd285434d87752b0b730f3fb0a5..5b15dd0a47753687b24e022ea76a497bff765220 100644 (file)
   // PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
   // usually further manual tunine is necessary.
 
-  #define PID_CRITIAL_GAIN 3000
-  #define PID_SWING_AT_CRITIAL 45 //seconds
+  #define PID_CRITIAL_GAIN 50
+  #define PID_SWING_AT_CRITIAL 47 //seconds
   
-  #define PID_PI    //no differentail term
-  //#define PID_PID //normal PID
+  //#define PID_PI    //no differentail term
+  #define PID_PID //normal PID
 
   #ifdef PID_PID
     //PID according to Ziegler-Nichols method
index e15f025514da5309d1e867bb08dc45333766c473..84f07b3e68dcd5ef90db5e1cf6abd48cd72ac2e8 100644 (file)
@@ -898,24 +898,28 @@ inline void process_commands()
 
     #ifdef PIDTEMP
     case 301: // M301
-      if(code_seen('P')) Kp = code_value();
-      if(code_seen('I')) Ki = code_value()*PID_dT;
-      if(code_seen('D')) Kd = code_value()/PID_dT;
-      #ifdef PID_ADD_EXTRUSION_RATE
-      if(code_seen('C')) Kc = code_value();
-      #endif
-      SERIAL_PROTOCOL("ok p:");
-      SERIAL_PROTOCOL(Kp);
-      SERIAL_PROTOCOL(" i:");
-      SERIAL_PROTOCOL(Ki/PID_dT);
-      SERIAL_PROTOCOL(" d:");
-      SERIAL_PROTOCOL(Kd*PID_dT);
-      #ifdef PID_ADD_EXTRUSION_RATE
-      SERIAL_PROTOCOL(" c:");
-      SERIAL_PROTOCOL(Kc*PID_dT);
-      #endif
-      SERIAL_PROTOCOLLN("");
-      
+      {
+        
+       
+        if(code_seen('P')) Kp = code_value();
+        if(code_seen('I')) Ki = code_value()*PID_dT;
+        if(code_seen('D')) Kd = code_value()/PID_dT;
+        #ifdef PID_ADD_EXTRUSION_RATE
+        if(code_seen('C')) Kc = code_value();
+        #endif
+        updatePID();
+        SERIAL_PROTOCOL("ok p:");
+        SERIAL_PROTOCOL(Kp);
+        SERIAL_PROTOCOL(" i:");
+        SERIAL_PROTOCOL(Ki/PID_dT);
+        SERIAL_PROTOCOL(" d:");
+        SERIAL_PROTOCOL(Kd*PID_dT);
+        #ifdef PID_ADD_EXTRUSION_RATE
+        SERIAL_PROTOCOL(" c:");
+        SERIAL_PROTOCOL(Kc*PID_dT);
+        #endif
+        SERIAL_PROTOCOLLN("");
+      }
       break;
     #endif //PIDTEMP
     case 400: // finish all moves
index 8ea8ee008ff9dba460f027409c3bf01e84138c32..ac299399dc1049236c31e09b5b2e430dc514e223 100644 (file)
@@ -111,6 +111,13 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
 //=============================functions         ============================\r
 //===========================================================================\r
   \r
+void updatePID()\r
+{\r
+#ifdef PIDTEMP\r
+  temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;\r
+#endif\r
+}\r
+  \r
 void manage_heater()\r
 {\r
   #ifdef USE_WATCHDOG\r
index 9c4b59a241c077e171d492eb44c7488509102adc..0f0de985f4e3ad3429a54d887fa1c2f89deab48f 100644 (file)
@@ -87,6 +87,7 @@ inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMP
 \r
 void disable_heater();\r
 void setWatch();\r
+void updatePID();\r
 \r
 #endif\r
 \r