ARM: enable temperature control.

Postponed until now to allow better testing of heaters earlier.

Also made pid_init() to handle all heaters at once.
This commit is contained in:
Markus Hitter 2015-08-10 15:07:15 +02:00
parent be6ca4c857
commit d753e2ca7f
5 changed files with 34 additions and 33 deletions

View File

@ -173,9 +173,7 @@ void heater_init() {
#include "config_wrapper.h"
#undef DEFINE_HEATER
#if 0
pid_init(i);
#endif /* 0 */
pid_init();
}
/** Set PWM output.

View File

@ -191,7 +191,6 @@ void heater_init() {
}
}
pid_init(i);
}
// set all heater pins to output
@ -201,6 +200,8 @@ void heater_init() {
WRITE(pin, invert ? 1 : 0);
#include "config_wrapper.h"
#undef DEFINE_HEATER
pid_init();
}
/** \brief manually set PWM output

View File

@ -78,8 +78,10 @@ heater_runtime_t heaters_runtime[NUM_HEATERS];
\param i Index of the heater to initialise by Teacup numbering.
*/
void pid_init(heater_t i) {
void pid_init() {
uint8_t i;
for (i = 0; i < NUM_HEATERS; i++) {
#ifdef HEATER_SANITY_CHECK
// 0 is a "sane" temperature when we're trying to cool down.
heaters_runtime[i].sane_temperature = 0;
@ -107,6 +109,7 @@ void pid_init(heater_t i) {
heaters_pid[i].i_limit = DEFAULT_I_LIMIT;
}
#endif /* BANG_BANG */
}
}
/** \brief run heater PID algorithm

View File

@ -69,7 +69,7 @@ typedef struct {
extern heater_runtime_t heaters_runtime[];
void heater_init(void);
void pid_init(heater_t index);
void pid_init(void);
void heater_set(heater_t index, uint8_t value);
void heater_tick(heater_t h, temp_type_t type, uint16_t current_temp, uint16_t target_temp);

3
temp.c
View File

@ -122,6 +122,7 @@ void temp_init() {
/// called every 10ms from clock.c - check all temp sensors that are ready for checking
void temp_sensor_tick() {
temp_sensor_t i = 0;
for (; i < NUM_TEMP_SENSORS; i++) {
if (temp_sensors_runtime[i].next_read_time) {
temp_sensors_runtime[i].next_read_time--;
@ -297,9 +298,7 @@ void temp_sensor_tick() {
}
if (temp_sensors[i].heater < NUM_HEATERS) {
#ifndef __ARMEL_NOTYET__
heater_tick(temp_sensors[i].heater, temp_sensors[i].temp_type, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp);
#endif /* __ARMEL_NOTYET__ */
}
if (DEBUG_PID && (debug_flags & DEBUG_PID))