Better PID defaults

parent df6dc807
......@@ -220,14 +220,14 @@
// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
// setting this to anything other than 255 enables a form of PWM to the bed,
// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPCOOLER)
#define MAX_COOLER_POWER 255 // limits duty cycle to bed; 255=full current
#define MAX_COOLER_POWER 200 // limits duty cycle to bed; 255=full current, save PEC life by setting max to 200
#define PID_COOLER_INTEGRAL_DRIVE_MAX MAX_COOLER_POWER // limit for the integral term
// 120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
// from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_coolerKp 10.00
#define DEFAULT_coolerKi .023
#define DEFAULT_coolerKd 305.4
#define DEFAULT_coolerKp 40.00
#define DEFAULT_coolerKi .3
#define DEFAULT_coolerKd 50.4
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
......
......@@ -812,10 +812,10 @@ float get_pid_output(int h) {
#if ENABLED(PIDTEMPCOOLER)
float get_pid_output_cooler() {
float pid_output;
float pid_output;
#if ENABLED(PID_OPENLOOP)
pid_output = constrain(target_temperature_cooler, 0, MAX_COOLER_POWER);
#else
#else
//pid_error_cooler = target_temperature_cooler - current_temperature_cooler;
pid_error_cooler = current_temperature_cooler - target_temperature_cooler;
pTerm_cooler = coolerKp * pid_error_cooler;
......@@ -826,7 +826,7 @@ float get_pid_output(int h) {
//dTerm_cooler = K2 * coolerKd * (current_temperature_cooler - temp_dState_cooler) + K1 * dTerm_cooler;
dTerm_cooler = K2 * coolerKd * (temp_dState_cooler - current_temperature_cooler) + K1 * dTerm_cooler;
temp_dState_cooler = current_temperature_cooler;
pid_output = pTerm_cooler + iTerm_cooler - dTerm_cooler;
if (pid_output > MAX_COOLER_POWER) {
if (pid_error_cooler > 0) temp_iState_cooler -= pid_error_cooler; // conditional un-integration
......@@ -836,7 +836,6 @@ float get_pid_output(int h) {
if (pid_error_cooler < 0) temp_iState_cooler -= pid_error_cooler; // conditional un-integration
pid_output = 0;
}
#endif // PID_OPENLOOP
#if ENABLED(PID_COOLER_DEBUG)
......@@ -848,8 +847,9 @@ float get_pid_output(int h) {
ECHO_EMV(" dTerm ", dTerm_cooler);
#endif //PID_COOLER_DEBUG
return pid_output;
}
#endif
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment