|
|
@ -2060,6 +2060,10 @@ void Temperature::disable_all_heaters() { |
|
|
|
|
|
|
|
#if HAS_MAX6675 |
|
|
|
|
|
|
|
#ifndef THERMOCOUPLE_MAX_ERRORS |
|
|
|
#define THERMOCOUPLE_MAX_ERRORS 15 |
|
|
|
#endif |
|
|
|
|
|
|
|
int Temperature::read_max6675( |
|
|
|
#if COUNT_6675 > 1 |
|
|
|
const uint8_t hindex |
|
|
@ -2071,6 +2075,8 @@ void Temperature::disable_all_heaters() { |
|
|
|
// Needed to return the correct temp when this is called too soon
|
|
|
|
static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; |
|
|
|
#endif |
|
|
|
|
|
|
|
static uint8_t max6675_errors[COUNT_6675] = { 0 }; |
|
|
|
|
|
|
|
#define MAX6675_HEAT_INTERVAL 250UL |
|
|
|
|
|
|
@ -2144,33 +2150,41 @@ void Temperature::disable_all_heaters() { |
|
|
|
WRITE_MAX6675(HIGH); // disable TT_MAX6675
|
|
|
|
|
|
|
|
if (max6675_temp & MAX6675_ERROR_MASK) { |
|
|
|
SERIAL_ERROR_START(); |
|
|
|
SERIAL_ECHOPGM("Temp measurement error! "); |
|
|
|
#if MAX6675_ERROR_MASK == 7 |
|
|
|
SERIAL_ECHOPGM("MAX31855 "); |
|
|
|
if (max6675_temp & 1) |
|
|
|
SERIAL_ECHOLNPGM("Open Circuit"); |
|
|
|
else if (max6675_temp & 2) |
|
|
|
SERIAL_ECHOLNPGM("Short to GND"); |
|
|
|
else if (max6675_temp & 4) |
|
|
|
SERIAL_ECHOLNPGM("Short to VCC"); |
|
|
|
#else |
|
|
|
SERIAL_ECHOLNPGM("MAX6675"); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Thermocouple open
|
|
|
|
max6675_temp = 4 * ( |
|
|
|
#if COUNT_6675 > 1 |
|
|
|
hindex ? HEATER_1_MAX6675_TMAX : HEATER_0_MAX6675_TMAX |
|
|
|
#elif ENABLED(HEATER_1_USES_MAX6675) |
|
|
|
HEATER_1_MAX6675_TMAX |
|
|
|
max6675_errors[hindex] += 1; |
|
|
|
if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { |
|
|
|
SERIAL_ERROR_START(); |
|
|
|
SERIAL_ECHOPGM("Temp measurement error! "); |
|
|
|
#if MAX6675_ERROR_MASK == 7 |
|
|
|
SERIAL_ECHOPGM("MAX31855 "); |
|
|
|
if (max6675_temp & 1) |
|
|
|
SERIAL_ECHOLNPGM("Open Circuit"); |
|
|
|
else if (max6675_temp & 2) |
|
|
|
SERIAL_ECHOLNPGM("Short to GND"); |
|
|
|
else if (max6675_temp & 4) |
|
|
|
SERIAL_ECHOLNPGM("Short to VCC"); |
|
|
|
#else |
|
|
|
HEATER_0_MAX6675_TMAX |
|
|
|
SERIAL_ECHOLNPGM("MAX6675"); |
|
|
|
#endif |
|
|
|
); |
|
|
|
|
|
|
|
// Thermocouple open
|
|
|
|
max6675_temp = 4 * ( |
|
|
|
#if COUNT_6675 > 1 |
|
|
|
hindex ? HEATER_1_MAX6675_TMAX : HEATER_0_MAX6675_TMAX |
|
|
|
#elif ENABLED(HEATER_1_USES_MAX6675) |
|
|
|
HEATER_1_MAX6675_TMAX |
|
|
|
#else |
|
|
|
HEATER_0_MAX6675_TMAX |
|
|
|
#endif |
|
|
|
); |
|
|
|
} |
|
|
|
else { |
|
|
|
max6675_temp >>= MAX6675_DISCARD_BITS; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else { |
|
|
|
max6675_temp >>= MAX6675_DISCARD_BITS; |
|
|
|
max6675_errors[hindex] = 0; |
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(MAX6675_IS_MAX31855) |
|
|
|
if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature
|
|
|
|