Commit 43a5e682 authored by MagoKimbra's avatar MagoKimbra

Merge remote-tracking branch 'refs/remotes/origin/master' into dev

parents 292cd03a a2c58bb2
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_H1 " H1" #define MSG_H1 " H1"
#define MSG_H2 " H2" #define MSG_H2 " H2"
#define MSG_H3 " H3" #define MSG_H3 " H3"
......
...@@ -100,14 +100,15 @@ unsigned char soft_pwm_bed; ...@@ -100,14 +100,15 @@ unsigned char soft_pwm_bed;
enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway }; enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway };
void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc); void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
static TRState thermal_runaway_state_machine[4] = { TRReset, TRReset, TRReset, TRReset }; static TRState thermal_runaway_state_machine[HOTENDS] = { TRReset };
static millis_t thermal_runaway_timer[4]; // = {0,0,0,0}; static millis_t thermal_runaway_timer[HOTENDS] = { 0 };
#endif #endif
#if ENABLED(THERMAL_PROTECTION_BED) && TEMP_SENSOR_BED != 0 #if ENABLED(THERMAL_PROTECTION_BED) && TEMP_SENSOR_BED != 0
static TRState thermal_runaway_bed_state_machine = TRReset; static TRState thermal_runaway_bed_state_machine = TRReset;
static millis_t thermal_runaway_bed_timer; static millis_t thermal_runaway_bed_timer;
#endif #endif
#endif #endif
#if HAS(POWER_CONSUMPTION_SENSOR) #if HAS(POWER_CONSUMPTION_SENSOR)
int current_raw_powconsumption = 0; //Holds measured power consumption int current_raw_powconsumption = 0; //Holds measured power consumption
static unsigned long raw_powconsumption_value = 0; static unsigned long raw_powconsumption_value = 0;
...@@ -1321,6 +1322,9 @@ void disable_all_heaters() { ...@@ -1321,6 +1322,9 @@ void disable_all_heaters() {
for (int i = 0; i < HOTENDS; i++) setTargetHotend(0, i); for (int i = 0; i < HOTENDS; i++) setTargetHotend(0, i);
setTargetBed(0); setTargetBed(0);
// If all heaters go down then for sure our print job has stopped
print_job_timer.stop();
#define DISABLE_HEATER(NR) { \ #define DISABLE_HEATER(NR) { \
target_temperature[NR] = 0; \ target_temperature[NR] = 0; \
soft_pwm[NR] = 0; \ soft_pwm[NR] = 0; \
...@@ -1355,59 +1359,61 @@ void disable_all_heaters() { ...@@ -1355,59 +1359,61 @@ void disable_all_heaters() {
} }
#if ENABLED(HEATER_0_USES_MAX6675) #if ENABLED(HEATER_0_USES_MAX6675)
#define MAX6675_HEAT_INTERVAL 250u #define MAX6675_HEAT_INTERVAL 250u
static millis_t next_max6675_ms = 0;
int max6675_temp = 2000;
static int read_max6675() { #if ENABLED(MAX6675_IS_MAX31855)
uint32_t max6675_temp = 2000;
#define MAX6675_ERROR_MASK 7
#define MAX6675_DISCARD_BITS 18
#else
uint16_t max6675_temp = 2000;
#define MAX6675_ERROR_MASK 4
#define MAX6675_DISCARD_BITS 3
#endif
millis_t ms = millis(); int Temperature::read_max6675() {
if (ms < next_max6675_ms) static millis_t next_max6675_ms = 0;
return max6675_temp;
next_max6675_ms = ms + MAX6675_HEAT_INTERVAL; millis_t ms = millis();
max6675_temp = 0; if (PENDING(ms, next_max6675_ms)) return (int)max6675_temp;
#ifdef PRR next_max6675_ms = ms + MAX6675_HEAT_INTERVAL;
CBI(PRR, PRSPI);
#elif defined(PRR0)
CBI(PRR0, PRSPI);
#endif
CBI(
#ifdef PRR
PRR
#elif defined(PRR0)
PRR0
#endif
, PRSPI);
SPCR = _BV(MSTR) | _BV(SPE) | _BV(SPR0); SPCR = _BV(MSTR) | _BV(SPE) | _BV(SPR0);
// enable TT_MAX6675 WRITE(MAX6675_SS, 0); // enable TT_MAX6675
WRITE(MAX6675_SS, 0);
// ensure 100ns delay - a bit extra is fine // ensure 100ns delay - a bit extra is fine
asm("nop"); // 50ns on 20Mhz, 62.5ns on 16Mhz asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
asm("nop"); // 50ns on 20Mhz, 62.5ns on 16Mhz asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
// read MSB // Read a big-endian temperature value
SPDR = 0; max6675_temp = 0;
for (; !TEST(SPSR, SPIF);); for (uint8_t i = sizeof(max6675_temp); i--;) {
max6675_temp = SPDR; SPDR = 0;
max6675_temp <<= 8; for (;!TEST(SPSR, SPIF););
max6675_temp |= SPDR;
// read LSB if (i > 0) max6675_temp <<= 8; // shift left if not the last byte
SPDR = 0;
for (; !TEST(SPSR, SPIF););
max6675_temp |= SPDR;
// disable TT_MAX6675
WRITE(MAX6675_SS, 1);
if (max6675_temp & 4) {
// thermocouple open
max6675_temp = 4000;
}
else {
max6675_temp = max6675_temp >> 3;
} }
return max6675_temp; WRITE(MAX6675_SS, 1); // disable TT_MAX6675
if (max6675_temp & MAX6675_ERROR_MASK)
max6675_temp = 4000; // thermocouple open
else
max6675_temp >>= MAX6675_DISCARD_BITS;
return (int)max6675_temp;
} }
#endif // HEATER_0_USES_MAX6675 #endif // HEATER_0_USES_MAX6675
......
...@@ -127,13 +127,23 @@ FORCE_INLINE float degTargetBed() { return target_temperature_bed; } ...@@ -127,13 +127,23 @@ FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
void start_watching_heater(int h = 0); void start_watching_heater(int h = 0);
#endif #endif
#if ENABLED(THERMAL_PROTECTION_BED)
void start_watching_bed();
#endif
FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t hotend) { FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t hotend) {
target_temperature[HOTEND_ARG] = celsius; target_temperature[HOTEND_ARG] = celsius;
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
start_watching_heater(HOTEND_ARG); start_watching_heater(HOTEND_ARG);
#endif #endif
} }
FORCE_INLINE void setTargetBed(const float& celsius) { target_temperature_bed = celsius; }
FORCE_INLINE void setTargetBed(const float& celsius) {
target_temperature_bed = celsius;
#if ENABLED(THERMAL_PROTECTION_BED)
start_watching_bed();
#endif
}
FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; } FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; }
FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment