// 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
#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