heater.c: Limit PID I term with conditional integration.
This commit is contained in:
parent
4ccca52367
commit
707c4f35de
16
heater.c
16
heater.c
|
|
@ -328,11 +328,17 @@ void heater_tick(heater_t h, temp_type_t type, uint16_t current_temp, uint16_t t
|
|||
) / PID_SCALE
|
||||
);
|
||||
|
||||
// rebase and limit factors
|
||||
if (pid_output_intermed > 255)
|
||||
pid_output = 255;
|
||||
else if (pid_output_intermed < 0)
|
||||
pid_output = 0;
|
||||
// rebase and limit factors
|
||||
if (pid_output_intermed > 255) {
|
||||
if (t_error > 0)
|
||||
heaters_runtime[h].heater_i -= t_error; // un-integrate
|
||||
pid_output = 255;
|
||||
}
|
||||
else if (pid_output_intermed < 0) {
|
||||
if (t_error < 0)
|
||||
heaters_runtime[h].heater_i -= t_error; // un-integrate
|
||||
pid_output = 0;
|
||||
}
|
||||
else
|
||||
pid_output = pid_output_intermed & 0xFF;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue