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:
parent
be6ca4c857
commit
d753e2ca7f
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
55
heater.c
55
heater.c
|
|
@ -78,35 +78,38 @@ 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;
|
||||
|
||||
#ifdef HEATER_SANITY_CHECK
|
||||
// 0 is a "sane" temperature when we're trying to cool down.
|
||||
heaters_runtime[i].sane_temperature = 0;
|
||||
#endif
|
||||
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;
|
||||
#endif
|
||||
|
||||
#ifndef BANG_BANG
|
||||
#ifdef EECONFIG
|
||||
// Read factors from EEPROM.
|
||||
heaters_pid[i].p_factor =
|
||||
eeprom_read_dword((uint32_t *)&EE_factors[i].EE_p_factor);
|
||||
heaters_pid[i].i_factor =
|
||||
eeprom_read_dword((uint32_t *)&EE_factors[i].EE_i_factor);
|
||||
heaters_pid[i].d_factor =
|
||||
eeprom_read_dword((uint32_t *)&EE_factors[i].EE_d_factor);
|
||||
heaters_pid[i].i_limit =
|
||||
eeprom_read_word((uint16_t *)&EE_factors[i].EE_i_limit);
|
||||
#ifndef BANG_BANG
|
||||
#ifdef EECONFIG
|
||||
// Read factors from EEPROM.
|
||||
heaters_pid[i].p_factor =
|
||||
eeprom_read_dword((uint32_t *)&EE_factors[i].EE_p_factor);
|
||||
heaters_pid[i].i_factor =
|
||||
eeprom_read_dword((uint32_t *)&EE_factors[i].EE_i_factor);
|
||||
heaters_pid[i].d_factor =
|
||||
eeprom_read_dword((uint32_t *)&EE_factors[i].EE_d_factor);
|
||||
heaters_pid[i].i_limit =
|
||||
eeprom_read_word((uint16_t *)&EE_factors[i].EE_i_limit);
|
||||
|
||||
if (crc_block(&heaters_pid[i].p_factor, 14) !=
|
||||
eeprom_read_word((uint16_t *)&EE_factors[i].crc))
|
||||
#endif /* EECONFIG */
|
||||
{
|
||||
heaters_pid[i].p_factor = DEFAULT_P;
|
||||
heaters_pid[i].i_factor = DEFAULT_I;
|
||||
heaters_pid[i].d_factor = DEFAULT_D;
|
||||
heaters_pid[i].i_limit = DEFAULT_I_LIMIT;
|
||||
}
|
||||
#endif /* BANG_BANG */
|
||||
if (crc_block(&heaters_pid[i].p_factor, 14) !=
|
||||
eeprom_read_word((uint16_t *)&EE_factors[i].crc))
|
||||
#endif /* EECONFIG */
|
||||
{
|
||||
heaters_pid[i].p_factor = DEFAULT_P;
|
||||
heaters_pid[i].i_factor = DEFAULT_I;
|
||||
heaters_pid[i].d_factor = DEFAULT_D;
|
||||
heaters_pid[i].i_limit = DEFAULT_I_LIMIT;
|
||||
}
|
||||
#endif /* BANG_BANG */
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief run heater PID algorithm
|
||||
|
|
|
|||
2
heater.h
2
heater.h
|
|
@ -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
3
temp.c
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue