|
@ -134,8 +134,8 @@ void PID_autotune(float temp) |
|
|
long t_high; |
|
|
long t_high; |
|
|
long t_low; |
|
|
long t_low; |
|
|
|
|
|
|
|
|
long bias=127; |
|
|
long bias=PID_MAX/2; |
|
|
long d = 127; |
|
|
long d = PID_MAX/2; |
|
|
float Ku, Tu; |
|
|
float Ku, Tu; |
|
|
float Kp, Ki, Kd; |
|
|
float Kp, Ki, Kd; |
|
|
float max, min; |
|
|
float max, min; |
|
@ -144,7 +144,7 @@ void PID_autotune(float temp) |
|
|
|
|
|
|
|
|
disable_heater(); // switch off all heaters.
|
|
|
disable_heater(); // switch off all heaters.
|
|
|
|
|
|
|
|
|
soft_pwm[0] = 255>>1; |
|
|
soft_pwm[0] = PID_MAX/2; |
|
|
|
|
|
|
|
|
for(;;) { |
|
|
for(;;) { |
|
|
|
|
|
|
|
@ -172,8 +172,8 @@ void PID_autotune(float temp) |
|
|
t_low=t2 - t1; |
|
|
t_low=t2 - t1; |
|
|
if(cycles > 0) { |
|
|
if(cycles > 0) { |
|
|
bias += (d*(t_high - t_low))/(t_low + t_high); |
|
|
bias += (d*(t_high - t_low))/(t_low + t_high); |
|
|
bias = constrain(bias, 20 ,235); |
|
|
bias = constrain(bias, 20 ,PID_MAX-20); |
|
|
if(bias > 127) d = 254 - bias; |
|
|
if(bias > PID_MAX/2) d = PID_MAX - 1 - bias; |
|
|
else d = bias; |
|
|
else d = bias; |
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias); |
|
|
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias); |
|
|