heater: fix residency compare.
labs requires a signed int.
This commit is contained in:
parent
9860d2850f
commit
093d20481e
|
|
@ -269,7 +269,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare where we're at to where we should be
|
// compare where we're at to where we should be
|
||||||
if (labs(current_temp - heaters_runtime[h].sane_temperature) > TEMP_HYSTERESIS) {
|
if (labs((int16_t)(current_temp - heaters_runtime[h].sane_temperature)) > TEMP_HYSTERESIS) {
|
||||||
// no change, or change in wrong direction for a long time- heater is broken!
|
// no change, or change in wrong direction for a long time- heater is broken!
|
||||||
pid_output = 0;
|
pid_output = 0;
|
||||||
sersendf_P(PSTR("!! heater %d or temp sensor %d broken- temp is %d.%dC, target is %d.%dC, didn't reach %d.%dC in %d0 milliseconds\n"), h, t, current_temp >> 2, (current_temp & 3) * 25, target_temp >> 2, (target_temp & 3) * 25, heaters_runtime[h].sane_temperature >> 2, (heaters_runtime[h].sane_temperature & 3) * 25, heaters_runtime[h].sanity_counter);
|
sersendf_P(PSTR("!! heater %d or temp sensor %d broken- temp is %d.%dC, target is %d.%dC, didn't reach %d.%dC in %d0 milliseconds\n"), h, t, current_temp >> 2, (current_temp & 3) * 25, target_temp >> 2, (target_temp & 3) * 25, heaters_runtime[h].sane_temperature >> 2, (heaters_runtime[h].sane_temperature & 3) * 25, heaters_runtime[h].sanity_counter);
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ void temp_sensor_tick() {
|
||||||
}
|
}
|
||||||
temp_sensors_runtime[i].last_read_temp = temp;
|
temp_sensors_runtime[i].last_read_temp = temp;
|
||||||
|
|
||||||
if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) {
|
if (labs((int16_t)(temp - temp_sensors_runtime[i].target_temp)) < TEMP_HYSTERESIS) {
|
||||||
if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME)
|
if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME)
|
||||||
temp_sensors_runtime[i].temp_residency++;
|
temp_sensors_runtime[i].temp_residency++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
heater.c
2
heater.c
|
|
@ -269,7 +269,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare where we're at to where we should be
|
// compare where we're at to where we should be
|
||||||
if (labs(current_temp - heaters_runtime[h].sane_temperature) > TEMP_HYSTERESIS) {
|
if (labs((int16_t)(current_temp - heaters_runtime[h].sane_temperature)) > TEMP_HYSTERESIS) {
|
||||||
// no change, or change in wrong direction for a long time- heater is broken!
|
// no change, or change in wrong direction for a long time- heater is broken!
|
||||||
pid_output = 0;
|
pid_output = 0;
|
||||||
sersendf_P(PSTR("!! heater %d or temp sensor %d broken- temp is %d.%dC, target is %d.%dC, didn't reach %d.%dC in %d0 milliseconds\n"), h, t, current_temp >> 2, (current_temp & 3) * 25, target_temp >> 2, (target_temp & 3) * 25, heaters_runtime[h].sane_temperature >> 2, (heaters_runtime[h].sane_temperature & 3) * 25, heaters_runtime[h].sanity_counter);
|
sersendf_P(PSTR("!! heater %d or temp sensor %d broken- temp is %d.%dC, target is %d.%dC, didn't reach %d.%dC in %d0 milliseconds\n"), h, t, current_temp >> 2, (current_temp & 3) * 25, target_temp >> 2, (target_temp & 3) * 25, heaters_runtime[h].sane_temperature >> 2, (heaters_runtime[h].sane_temperature & 3) * 25, heaters_runtime[h].sanity_counter);
|
||||||
|
|
|
||||||
2
temp.c
2
temp.c
|
|
@ -269,7 +269,7 @@ void temp_sensor_tick() {
|
||||||
}
|
}
|
||||||
temp_sensors_runtime[i].last_read_temp = temp;
|
temp_sensors_runtime[i].last_read_temp = temp;
|
||||||
|
|
||||||
if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) {
|
if (labs((int16_t)(temp - temp_sensors_runtime[i].target_temp)) < TEMP_HYSTERESIS) {
|
||||||
if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME)
|
if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME)
|
||||||
temp_sensors_runtime[i].temp_residency++;
|
temp_sensors_runtime[i].temp_residency++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue