|
|
@ -141,7 +141,7 @@ static volatile bool temp_meas_ready = false;
|
|
|
|
// Init min and max temp with extreme values to prevent false errors during startup
|
|
|
|
// Init min and max temp with extreme values to prevent false errors during startup
|
|
|
|
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
|
|
|
|
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
|
|
|
|
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
|
|
|
|
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
|
|
|
|
static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0, 0, 0, 0 );
|
|
|
|
static int minttemp[EXTRUDERS] = { 0 };
|
|
|
|
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383, 16383 );
|
|
|
|
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383, 16383 );
|
|
|
|
//static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; /* No bed mintemp error implemented?!? */
|
|
|
|
//static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; /* No bed mintemp error implemented?!? */
|
|
|
|
#ifdef BED_MAXTEMP
|
|
|
|
#ifdef BED_MAXTEMP
|
|
|
@ -161,8 +161,8 @@ static float analog2tempBed(int raw);
|
|
|
|
static void updateTemperaturesFromRawValues();
|
|
|
|
static void updateTemperaturesFromRawValues();
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WATCH_TEMP_PERIOD
|
|
|
|
#ifdef WATCH_TEMP_PERIOD
|
|
|
|
int watch_start_temp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0,0);
|
|
|
|
int watch_start_temp[EXTRUDERS] = { 0 };
|
|
|
|
unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0,0);
|
|
|
|
unsigned long watchmillis[EXTRUDERS] = { 0 };
|
|
|
|
#endif //WATCH_TEMP_PERIOD
|
|
|
|
#endif //WATCH_TEMP_PERIOD
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SOFT_PWM_SCALE
|
|
|
|
#ifndef SOFT_PWM_SCALE
|
|
|
@ -576,12 +576,6 @@ void manage_heater() {
|
|
|
|
|
|
|
|
|
|
|
|
updateTemperaturesFromRawValues();
|
|
|
|
updateTemperaturesFromRawValues();
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HEATER_0_USES_MAX6675
|
|
|
|
|
|
|
|
float ct = current_temperature[0];
|
|
|
|
|
|
|
|
if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
|
|
|
|
|
|
|
|
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
|
|
|
|
|
|
|
|
#endif //HEATER_0_USES_MAX6675
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long ms = millis();
|
|
|
|
unsigned long ms = millis();
|
|
|
|
|
|
|
|
|
|
|
|
// Loop through all extruders
|
|
|
|
// Loop through all extruders
|
|
|
@ -1060,28 +1054,28 @@ void disable_heater() {
|
|
|
|
for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);
|
|
|
|
for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);
|
|
|
|
setTargetBed(0);
|
|
|
|
setTargetBed(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DISABLE_HEATER(NR) { \
|
|
|
|
|
|
|
|
target_temperature[NR] = 0; \
|
|
|
|
|
|
|
|
soft_pwm[NR] = 0; \
|
|
|
|
|
|
|
|
WRITE_HEATER_ ## NR (LOW); \
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_TEMP_0
|
|
|
|
#if HAS_TEMP_0
|
|
|
|
target_temperature[0] = 0;
|
|
|
|
target_temperature[0] = 0;
|
|
|
|
soft_pwm[0] = 0;
|
|
|
|
soft_pwm[0] = 0;
|
|
|
|
WRITE_HEATER_0P(LOW); // If HEATERS_PARALLEL should apply, change to WRITE_HEATER_0
|
|
|
|
WRITE_HEATER_0P(LOW); // Should HEATERS_PARALLEL apply here? Then change to DISABLE_HEATER(0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1 && HAS_TEMP_1
|
|
|
|
#if EXTRUDERS > 1 && HAS_TEMP_1
|
|
|
|
target_temperature[1] = 0;
|
|
|
|
DISABLE_HEATER(1);
|
|
|
|
soft_pwm[1] = 0;
|
|
|
|
|
|
|
|
WRITE_HEATER_1(LOW);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 2 && HAS_TEMP_2
|
|
|
|
#if EXTRUDERS > 2 && HAS_TEMP_2
|
|
|
|
target_temperature[2] = 0;
|
|
|
|
DISABLE_HEATER(2);
|
|
|
|
soft_pwm[2] = 0;
|
|
|
|
|
|
|
|
WRITE_HEATER_2(LOW);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 3 && HAS_TEMP_3
|
|
|
|
#if EXTRUDERS > 3 && HAS_TEMP_3
|
|
|
|
target_temperature[3] = 0;
|
|
|
|
DISABLE_HEATER(3);
|
|
|
|
soft_pwm[3] = 0;
|
|
|
|
|
|
|
|
WRITE_HEATER_3(LOW);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
#if HAS_TEMP_BED
|
|
|
@ -1172,9 +1166,15 @@ enum TempState {
|
|
|
|
// Timer 0 is shared with millies
|
|
|
|
// Timer 0 is shared with millies
|
|
|
|
//
|
|
|
|
//
|
|
|
|
ISR(TIMER0_COMPB_vect) {
|
|
|
|
ISR(TIMER0_COMPB_vect) {
|
|
|
|
|
|
|
|
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
|
|
|
|
|
|
#define TEMP_SENSOR_COUNT 2
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define TEMP_SENSOR_COUNT EXTRUDERS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//these variables are only accesible from the ISR, but static, so they don't lose their value
|
|
|
|
//these variables are only accesible from the ISR, but static, so they don't lose their value
|
|
|
|
static unsigned char temp_count = 0;
|
|
|
|
static unsigned char temp_count = 0;
|
|
|
|
static unsigned long raw_temp_value[EXTRUDERS] = { 0 };
|
|
|
|
static unsigned long raw_temp_value[TEMP_SENSOR_COUNT] = { 0 };
|
|
|
|
static unsigned long raw_temp_bed_value = 0;
|
|
|
|
static unsigned long raw_temp_bed_value = 0;
|
|
|
|
static TempState temp_state = StartupDelay;
|
|
|
|
static TempState temp_state = StartupDelay;
|
|
|
|
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
|
|
|
|
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
|
|
|
@ -1390,6 +1390,7 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
temp_state = PrepareTemp_BED;
|
|
|
|
temp_state = PrepareTemp_BED;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case PrepareTemp_BED:
|
|
|
|
case PrepareTemp_BED:
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
START_ADC(TEMP_BED_PIN);
|
|
|
|
START_ADC(TEMP_BED_PIN);
|
|
|
@ -1403,6 +1404,7 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
temp_state = PrepareTemp_1;
|
|
|
|
temp_state = PrepareTemp_1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case PrepareTemp_1:
|
|
|
|
case PrepareTemp_1:
|
|
|
|
#if HAS_TEMP_1
|
|
|
|
#if HAS_TEMP_1
|
|
|
|
START_ADC(TEMP_1_PIN);
|
|
|
|
START_ADC(TEMP_1_PIN);
|
|
|
@ -1416,6 +1418,7 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
temp_state = PrepareTemp_2;
|
|
|
|
temp_state = PrepareTemp_2;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case PrepareTemp_2:
|
|
|
|
case PrepareTemp_2:
|
|
|
|
#if HAS_TEMP_2
|
|
|
|
#if HAS_TEMP_2
|
|
|
|
START_ADC(TEMP_2_PIN);
|
|
|
|
START_ADC(TEMP_2_PIN);
|
|
|
@ -1429,6 +1432,7 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
temp_state = PrepareTemp_3;
|
|
|
|
temp_state = PrepareTemp_3;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case PrepareTemp_3:
|
|
|
|
case PrepareTemp_3:
|
|
|
|
#if HAS_TEMP_3
|
|
|
|
#if HAS_TEMP_3
|
|
|
|
START_ADC(TEMP_3_PIN);
|
|
|
|
START_ADC(TEMP_3_PIN);
|
|
|
@ -1442,6 +1446,7 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
temp_state = Prepare_FILWIDTH;
|
|
|
|
temp_state = Prepare_FILWIDTH;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Prepare_FILWIDTH:
|
|
|
|
case Prepare_FILWIDTH:
|
|
|
|
#if HAS_FILAMENT_SENSOR
|
|
|
|
#if HAS_FILAMENT_SENSOR
|
|
|
|
START_ADC(FILWIDTH_PIN);
|
|
|
|
START_ADC(FILWIDTH_PIN);
|
|
|
@ -1460,6 +1465,7 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
temp_state = PrepareTemp_0;
|
|
|
|
temp_state = PrepareTemp_0;
|
|
|
|
temp_count++;
|
|
|
|
temp_count++;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case StartupDelay:
|
|
|
|
case StartupDelay:
|
|
|
|
temp_state = PrepareTemp_0;
|
|
|
|
temp_state = PrepareTemp_0;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -1497,49 +1503,50 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
|
|
|
|
|
|
|
|
temp_meas_ready = true;
|
|
|
|
temp_meas_ready = true;
|
|
|
|
temp_count = 0;
|
|
|
|
temp_count = 0;
|
|
|
|
for (int i = 0; i < EXTRUDERS; i++) raw_temp_value[i] = 0;
|
|
|
|
for (int i = 0; i < TEMP_SENSOR_COUNT; i++) raw_temp_value[i] = 0;
|
|
|
|
raw_temp_bed_value = 0;
|
|
|
|
raw_temp_bed_value = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HEATER_0_USES_MAX6675
|
|
|
|
|
|
|
|
float ct = current_temperature[0];
|
|
|
|
|
|
|
|
if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
|
|
|
|
|
|
|
|
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
|
|
|
|
|
|
|
|
#else
|
|
|
|
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
|
|
|
|
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
|
|
|
|
#define GE0 <=
|
|
|
|
#define GE0 <=
|
|
|
|
#define LE0 >=
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define GE0 >=
|
|
|
|
#define GE0 >=
|
|
|
|
#define LE0 <=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (current_temperature_raw[0] GE0 maxttemp_raw[0]) max_temp_error(0);
|
|
|
|
if (current_temperature_raw[0] GE0 maxttemp_raw[0]) max_temp_error(0);
|
|
|
|
if (current_temperature_raw[0] LE0 minttemp_raw[0]) min_temp_error(0);
|
|
|
|
if (minttemp_raw[0] GE0 current_temperature_raw[0]) min_temp_error(0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
#if HEATER_1_RAW_LO_TEMP > HEATER_1_RAW_HI_TEMP
|
|
|
|
#if HEATER_1_RAW_LO_TEMP > HEATER_1_RAW_HI_TEMP
|
|
|
|
#define GE1 <=
|
|
|
|
#define GE1 <=
|
|
|
|
#define LE1 >=
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define GE1 >=
|
|
|
|
#define GE1 >=
|
|
|
|
#define LE1 <=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (current_temperature_raw[1] GE1 maxttemp_raw[1]) max_temp_error(1);
|
|
|
|
if (current_temperature_raw[1] GE1 maxttemp_raw[1]) max_temp_error(1);
|
|
|
|
if (current_temperature_raw[1] LE1 minttemp_raw[1]) min_temp_error(1);
|
|
|
|
if (minttemp_raw[1] GE0 current_temperature_raw[1]) min_temp_error(1);
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 2
|
|
|
|
#if EXTRUDERS > 2
|
|
|
|
#if HEATER_2_RAW_LO_TEMP > HEATER_2_RAW_HI_TEMP
|
|
|
|
#if HEATER_2_RAW_LO_TEMP > HEATER_2_RAW_HI_TEMP
|
|
|
|
#define GE2 <=
|
|
|
|
#define GE2 <=
|
|
|
|
#define LE2 >=
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define GE2 >=
|
|
|
|
#define GE2 >=
|
|
|
|
#define LE2 <=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (current_temperature_raw[2] GE2 maxttemp_raw[2]) max_temp_error(2);
|
|
|
|
if (current_temperature_raw[2] GE2 maxttemp_raw[2]) max_temp_error(2);
|
|
|
|
if (current_temperature_raw[2] LE2 minttemp_raw[2]) min_temp_error(2);
|
|
|
|
if (minttemp_raw[2] GE0 current_temperature_raw[2]) min_temp_error(2);
|
|
|
|
|
|
|
|
|
|
|
|
#if EXTRUDERS > 3
|
|
|
|
#if EXTRUDERS > 3
|
|
|
|
#if HEATER_3_RAW_LO_TEMP > HEATER_3_RAW_HI_TEMP
|
|
|
|
#if HEATER_3_RAW_LO_TEMP > HEATER_3_RAW_HI_TEMP
|
|
|
|
#define GE3 <=
|
|
|
|
#define GE3 <=
|
|
|
|
#define LE3 >=
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define GE3 >=
|
|
|
|
#define GE3 >=
|
|
|
|
#define LE3 <=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (current_temperature_raw[3] GE3 maxttemp_raw[3]) max_temp_error(3);
|
|
|
|
if (current_temperature_raw[3] GE3 maxttemp_raw[3]) max_temp_error(3);
|
|
|
|
if (current_temperature_raw[3] LE3 minttemp_raw[3]) min_temp_error(3);
|
|
|
|
if (minttemp_raw[3] GE0 current_temperature_raw[3]) min_temp_error(3);
|
|
|
|
|
|
|
|
|
|
|
|
#endif // EXTRUDERS > 3
|
|
|
|
#endif // EXTRUDERS > 3
|
|
|
|
#endif // EXTRUDERS > 2
|
|
|
|
#endif // EXTRUDERS > 2
|
|
|
|
#endif // EXTRUDERS > 1
|
|
|
|
#endif // EXTRUDERS > 1
|
|
|
@ -1547,10 +1554,8 @@ ISR(TIMER0_COMPB_vect) {
|
|
|
|
#if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0)
|
|
|
|
#if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0)
|
|
|
|
#if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP
|
|
|
|
#if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP
|
|
|
|
#define GEBED <=
|
|
|
|
#define GEBED <=
|
|
|
|
#define LEBED >=
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define GEBED >=
|
|
|
|
#define GEBED >=
|
|
|
|
#define LEBED <=
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (current_temperature_bed_raw GEBED bed_maxttemp_raw) {
|
|
|
|
if (current_temperature_bed_raw GEBED bed_maxttemp_raw) {
|
|
|
|
target_temperature_bed = 0;
|
|
|
|
target_temperature_bed = 0;
|
|
|
|