Temp: have heater update on 250ms intervals.

Thermal managers (PID, bang-bang, etc.) assume they're being
ticked on 250ms intervals. In reality, they were being updated on
each temperature reading, which was between 10ms and 250ms. This
caused thermal management to malfunction.

https://github.com/Traumflug/Teacup_Firmware/issues/211
This commit is contained in:
Robert Konklewski 2016-04-18 12:59:10 +02:00 committed by Markus Hitter
parent 803ff6e8b3
commit 8e977d50ce
3 changed files with 19 additions and 4 deletions

View File

@ -84,6 +84,8 @@ static void clock_250ms(void) {
}
}
temp_heater_tick();
ifclock(clock_flag_1s) {
#ifdef DISPLAY
display_clock();

19
temp.c
View File

@ -393,10 +393,6 @@ void temp_sensor_tick() {
temp_sensors_runtime[i].temp_residency = 0;
}
if (temp_sensors[i].heater < NUM_HEATERS) {
heater_tick(temp_sensors[i].heater, temp_sensors[i].temp_type, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp);
}
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR("DU temp: {%d %d %d.%d}"), i,
temp_sensors_runtime[i].last_read_temp,
@ -407,6 +403,21 @@ void temp_sensor_tick() {
sersendf_P(PSTR("\n"));
}
/**
Called every 250ms from clock.c. Update heaters for all sensors.
*/
void temp_heater_tick() {
temp_sensor_t i;
for (i = 0; i < NUM_TEMP_SENSORS; i++) {
if (temp_sensors[i].heater < NUM_HEATERS) {
heater_tick(temp_sensors[i].heater, temp_sensors[i].temp_type,
temp_sensors_runtime[i].last_read_temp,
temp_sensors_runtime[i].target_temp);
}
}
}
/**
* Report whether all temp sensors in use are reading their target
* temperatures. Used for M116 and friends.

2
temp.h
View File

@ -36,6 +36,8 @@ void temp_init(void);
void temp_sensor_tick(void);
void temp_heater_tick(void);
uint8_t temp_achieved(void);
void temp_set(temp_sensor_t index, uint16_t temperature);