lots of other files in extruder desynced, needed to wrap an ifdef around heater_print

This commit is contained in:
Michael Moon 2011-02-28 09:18:06 +11:00
parent 3647c6f1a9
commit 815ff7ba19
6 changed files with 47 additions and 27 deletions

View File

@ -57,6 +57,10 @@
#include "arduino_1280.h"
#endif /* __AVR_ATmega1280__ */
#if defined (__AVR_ATmega2560__)
#include "arduino_1280.h" //2560 has the same pins and ports so we can reuse the 1280 file.
#endif
#ifndef DIO0_PIN
#error pins for this chip not defined in arduino.h! If you write an appropriate pin definition and have this firmware work on your chip, please tell us via the forum thread
#endif

View File

@ -3,12 +3,18 @@
#include <stdint.h>
#ifdef DEBUG
#define DEBUG_PID 1
#define DEBUG_DDA 2
#define DEBUG_POSITION 4
#else
// by setting these to zero, the compiler should optimise the relevant code out
#define DEBUG_PID 0
#define DEBUG_DDA 0
#define DEBUG_POSITION 0
#endif
#define DEBUG_ECHO 0
#define DEBUG_ECHO 128
extern volatile uint8_t debug_flags;

View File

@ -6,10 +6,12 @@
#include "arduino.h"
#include "debug.h"
#include "temp.h"
#include "crc.h"
#ifndef EXTRUDER
#include "sersendf.h"
#endif
#include "temp.h"
typedef struct {
volatile uint8_t *heater_port;
@ -59,6 +61,7 @@ typedef struct {
int32_t EE_i_factor;
int32_t EE_d_factor;
int16_t EE_i_limit;
uint16_t crc;
} EE_factor;
EE_factor EEMEM EE_factors[NUM_HEATERS];
@ -101,7 +104,8 @@ void heater_init() {
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 ((heaters_pid[i].p_factor == 0) && (heaters_pid[i].i_factor == 0) && (heaters_pid[i].d_factor == 0) && (heaters_pid[i].i_limit == 0)) {
// if ((heaters_pid[i].p_factor == 0) && (heaters_pid[i].i_factor == 0) && (heaters_pid[i].d_factor == 0) && (heaters_pid[i].i_limit == 0)) {
if (crc_block(&heaters_pid[i].p_factor, 14) != eeprom_read_word((uint16_t *) &EE_factors[i].crc)) {
heaters_pid[i].p_factor = DEFAULT_P;
heaters_pid[i].i_factor = DEFAULT_I;
heaters_pid[i].d_factor = DEFAULT_D;
@ -119,6 +123,7 @@ void heater_save_settings() {
eeprom_write_dword((uint32_t *) &EE_factors[i].EE_i_factor, heaters_pid[i].i_factor);
eeprom_write_dword((uint32_t *) &EE_factors[i].EE_d_factor, heaters_pid[i].d_factor);
eeprom_write_word((uint16_t *) &EE_factors[i].EE_i_limit, heaters_pid[i].i_limit);
eeprom_write_word((uint16_t *) &EE_factors[i].crc, crc_block(&heaters_pid[i].p_factor, 14));
}
#endif /* BANG_BANG */
}
@ -178,9 +183,9 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta
#endif
#else
if (current_temp >= target_temp)
pid_output = BANG_BANG_ON;
else
pid_output = BANG_BANG_OFF;
else
pid_output = BANG_BANG_ON;
#endif
#ifdef HEATER_SANITY_CHECK
@ -308,3 +313,9 @@ void pid_set_i_limit(heater_t index, int32_t i_limit) {
heaters_pid[index].i_limit = i_limit;
#endif /* BANG_BANG */
}
#ifndef EXTRUDER
void heater_print(uint16_t i) {
sersendf_P(PSTR("P:%ld I:%ld D:%ld Ilim:%u crc:%u "), heaters_pid[i].p_factor, heaters_pid[i].i_factor, heaters_pid[i].d_factor, heaters_pid[i].i_limit, crc_block(&heaters_pid[i].p_factor, 14));
}
#endif

View File

@ -31,4 +31,6 @@ void pid_set_i(heater_t index, int32_t i);
void pid_set_d(heater_t index, int32_t d);
void pid_set_i_limit(heater_t index, int32_t i_limit);
void heater_print(uint16_t i);
#endif /* _HEATER_H */

View File

@ -15,24 +15,15 @@
#include "intercom.h"
#endif
typedef enum {
TT_THERMISTOR,
TT_MAX6675,
TT_AD595,
TT_PT100,
TT_INTERCOM,
TT_DUMMY,
} temp_types;
typedef enum {
PRESENT,
TCOPEN
} temp_flags_enum;
typedef struct {
uint8_t temp_type;
temp_type_t temp_type;
uint8_t temp_pin;
uint8_t heater_index;
heater_t heater;
} temp_sensor_definition_t;
#undef DEFINE_TEMP_SENSOR
@ -95,6 +86,9 @@ void temp_init() {
send_temperature(0, 0);
break;
#endif
default: /* prevent compiler warning */
break;
}
}
}
@ -241,8 +235,6 @@ void temp_sensor_tick() {
case TT_INTERCOM:
temp = read_temperature(temp_sensors[i].temp_pin);
start_send();
temp_sensors_runtime[i].next_read_time = 0;
break;
@ -261,6 +253,9 @@ void temp_sensor_tick() {
break;
#endif /* TEMP_DUMMY */
default: /* prevent compiler warning */
break;
}
temp_sensors_runtime[i].last_read_temp = temp;
@ -272,8 +267,8 @@ void temp_sensor_tick() {
temp_sensors_runtime[i].temp_residency = 0;
}
if (temp_sensors[i].heater_index < NUM_HEATERS) {
heater_tick(temp_sensors[i].heater_index, i, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp);
if (temp_sensors[i].heater < NUM_HEATERS) {
heater_tick(temp_sensors[i].heater, i, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp);
}
}
}

View File

@ -314,6 +314,8 @@ void pid_set_i_limit(heater_t index, int32_t i_limit) {
#endif /* BANG_BANG */
}
#ifndef EXTRUDER
void heater_print(uint16_t i) {
sersendf_P(PSTR("P:%ld I:%ld D:%ld Ilim:%u crc:%u "), heaters_pid[i].p_factor, heaters_pid[i].i_factor, heaters_pid[i].d_factor, heaters_pid[i].i_limit, crc_block(&heaters_pid[i].p_factor, 14));
}
#endif