Browse Source

fixed bug with adjusting ki in realtime.

Bernhard Kubicek 13 years ago
parent
commit
c57906b627
4 changed files with 34 additions and 22 deletions
  1. 4
    4
      Marlin/Configuration.h
  2. 22
    18
      Marlin/Marlin.pde
  3. 7
    0
      Marlin/temperature.cpp
  4. 1
    0
      Marlin/temperature.h

+ 4
- 4
Marlin/Configuration.h View File

95
   // PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
95
   // PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
96
   // usually further manual tunine is necessary.
96
   // usually further manual tunine is necessary.
97
 
97
 
98
-  #define PID_CRITIAL_GAIN 3000
99
-  #define PID_SWING_AT_CRITIAL 45 //seconds
98
+  #define PID_CRITIAL_GAIN 50
99
+  #define PID_SWING_AT_CRITIAL 47 //seconds
100
   
100
   
101
-  #define PID_PI    //no differentail term
102
-  //#define PID_PID //normal PID
101
+  //#define PID_PI    //no differentail term
102
+  #define PID_PID //normal PID
103
 
103
 
104
   #ifdef PID_PID
104
   #ifdef PID_PID
105
     //PID according to Ziegler-Nichols method
105
     //PID according to Ziegler-Nichols method

+ 22
- 18
Marlin/Marlin.pde View File

898
 
898
 
899
     #ifdef PIDTEMP
899
     #ifdef PIDTEMP
900
     case 301: // M301
900
     case 301: // M301
901
-      if(code_seen('P')) Kp = code_value();
902
-      if(code_seen('I')) Ki = code_value()*PID_dT;
903
-      if(code_seen('D')) Kd = code_value()/PID_dT;
904
-      #ifdef PID_ADD_EXTRUSION_RATE
905
-      if(code_seen('C')) Kc = code_value();
906
-      #endif
907
-      SERIAL_PROTOCOL("ok p:");
908
-      SERIAL_PROTOCOL(Kp);
909
-      SERIAL_PROTOCOL(" i:");
910
-      SERIAL_PROTOCOL(Ki/PID_dT);
911
-      SERIAL_PROTOCOL(" d:");
912
-      SERIAL_PROTOCOL(Kd*PID_dT);
913
-      #ifdef PID_ADD_EXTRUSION_RATE
914
-      SERIAL_PROTOCOL(" c:");
915
-      SERIAL_PROTOCOL(Kc*PID_dT);
916
-      #endif
917
-      SERIAL_PROTOCOLLN("");
918
-      
901
+      {
902
+        
903
+       
904
+        if(code_seen('P')) Kp = code_value();
905
+        if(code_seen('I')) Ki = code_value()*PID_dT;
906
+        if(code_seen('D')) Kd = code_value()/PID_dT;
907
+        #ifdef PID_ADD_EXTRUSION_RATE
908
+        if(code_seen('C')) Kc = code_value();
909
+        #endif
910
+        updatePID();
911
+        SERIAL_PROTOCOL("ok p:");
912
+        SERIAL_PROTOCOL(Kp);
913
+        SERIAL_PROTOCOL(" i:");
914
+        SERIAL_PROTOCOL(Ki/PID_dT);
915
+        SERIAL_PROTOCOL(" d:");
916
+        SERIAL_PROTOCOL(Kd*PID_dT);
917
+        #ifdef PID_ADD_EXTRUSION_RATE
918
+        SERIAL_PROTOCOL(" c:");
919
+        SERIAL_PROTOCOL(Kc*PID_dT);
920
+        #endif
921
+        SERIAL_PROTOCOLLN("");
922
+      }
919
       break;
923
       break;
920
     #endif //PIDTEMP
924
     #endif //PIDTEMP
921
     case 400: // finish all moves
925
     case 400: // finish all moves

+ 7
- 0
Marlin/temperature.cpp View File

111
 //=============================functions         ============================
111
 //=============================functions         ============================
112
 //===========================================================================
112
 //===========================================================================
113
   
113
   
114
+void updatePID()
115
+{
116
+#ifdef PIDTEMP
117
+  temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;
118
+#endif
119
+}
120
+  
114
 void manage_heater()
121
 void manage_heater()
115
 {
122
 {
116
   #ifdef USE_WATCHDOG
123
   #ifdef USE_WATCHDOG

+ 1
- 0
Marlin/temperature.h View File

87
 
87
 
88
 void disable_heater();
88
 void disable_heater();
89
 void setWatch();
89
 void setWatch();
90
+void updatePID();
90
 
91
 
91
 #endif
92
 #endif
92
 
93
 

Loading…
Cancel
Save