Heat all the way to the setpoint.

This commit is contained in:
Chris Giacofei 2024-05-01 15:44:29 -04:00
parent c98aebc716
commit 9be0cabfe3
2 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,7 @@ thermoControl::thermoControl(double* current_temp, double* setpoint, double* pow
actual_temp = current_temp; actual_temp = current_temp;
hysteresis = 1.0; hysteresis = 1.0;
max_pwr_threshold = 5.0; max_pwr_threshold = 5.0;
isheating=false;
Serial.println("Controller Started"); Serial.println("Controller Started");
} }
@ -26,12 +27,14 @@ bool thermoControl::Compute() {
if (error >= max_pwr_threshold) { if (error >= max_pwr_threshold) {
*output_pwm = outMax; *output_pwm = outMax;
} else if (error > hysteresis) { isheating=true;
} else if (error > hysteresis || (error <= hysteresis && error > 0 && isheating)) {
*output_pwm = 100 * error / max_pwr_threshold; *output_pwm = 100 * error / max_pwr_threshold;
if (*output_pwm > 100) *output_pwm = 100; if (*output_pwm > 100) *output_pwm = 100;
if (*output_pwm < 0) *output_pwm = 0; isheating=true;
} else { } else {
*output_pwm = 0; *output_pwm = 0;
isheating=false;
} }
lastTime = now; lastTime = now;

View File

@ -17,6 +17,7 @@ class thermoControl {
int outMin; int outMin;
int SampleInterval; int SampleInterval;
unsigned long lastTime; unsigned long lastTime;
bool isheating;
modes OpMode; modes OpMode;
public: public: