Ignore spurious MAX31855K / 6675 thermocouple errors (#18039)
This commit is contained in:
parent
7b2a056656
commit
60bed3434b
2 changed files with 50 additions and 23 deletions
|
@ -39,6 +39,19 @@
|
||||||
//=============================Thermal Settings ============================
|
//=============================Thermal Settings ============================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thermocouple sensors are quite sensitive to noise. Any noise induced in
|
||||||
|
* the sensor wires, such as by stepper motor wires run in parallel to them,
|
||||||
|
* may result in the thermocouple sensor reporting spurious errors. This
|
||||||
|
* value is the number of errors which can occur in a row before the error
|
||||||
|
* is reported. This allows us to ignore intermittent error conditions while
|
||||||
|
* still detecting an actual failure, which should result in a continuous
|
||||||
|
* stream of errors from the sensor.
|
||||||
|
*
|
||||||
|
* Set this value to 0 to fail on the first error to occur.
|
||||||
|
*/
|
||||||
|
#define THERMOCOUPLE_MAX_ERRORS 15
|
||||||
|
|
||||||
//
|
//
|
||||||
// Custom Thermistor 1000 parameters
|
// Custom Thermistor 1000 parameters
|
||||||
//
|
//
|
||||||
|
|
|
@ -2060,6 +2060,10 @@ void Temperature::disable_all_heaters() {
|
||||||
|
|
||||||
#if HAS_MAX6675
|
#if HAS_MAX6675
|
||||||
|
|
||||||
|
#ifndef THERMOCOUPLE_MAX_ERRORS
|
||||||
|
#define THERMOCOUPLE_MAX_ERRORS 15
|
||||||
|
#endif
|
||||||
|
|
||||||
int Temperature::read_max6675(
|
int Temperature::read_max6675(
|
||||||
#if COUNT_6675 > 1
|
#if COUNT_6675 > 1
|
||||||
const uint8_t hindex
|
const uint8_t hindex
|
||||||
|
@ -2072,6 +2076,8 @@ void Temperature::disable_all_heaters() {
|
||||||
static uint16_t max6675_temp_previous[COUNT_6675] = { 0 };
|
static uint16_t max6675_temp_previous[COUNT_6675] = { 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static uint8_t max6675_errors[COUNT_6675] = { 0 };
|
||||||
|
|
||||||
#define MAX6675_HEAT_INTERVAL 250UL
|
#define MAX6675_HEAT_INTERVAL 250UL
|
||||||
|
|
||||||
#if ENABLED(MAX6675_IS_MAX31855)
|
#if ENABLED(MAX6675_IS_MAX31855)
|
||||||
|
@ -2144,6 +2150,8 @@ void Temperature::disable_all_heaters() {
|
||||||
WRITE_MAX6675(HIGH); // disable TT_MAX6675
|
WRITE_MAX6675(HIGH); // disable TT_MAX6675
|
||||||
|
|
||||||
if (max6675_temp & MAX6675_ERROR_MASK) {
|
if (max6675_temp & MAX6675_ERROR_MASK) {
|
||||||
|
max6675_errors[hindex] += 1;
|
||||||
|
if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ECHOPGM("Temp measurement error! ");
|
SERIAL_ECHOPGM("Temp measurement error! ");
|
||||||
#if MAX6675_ERROR_MASK == 7
|
#if MAX6675_ERROR_MASK == 7
|
||||||
|
@ -2169,8 +2177,14 @@ void Temperature::disable_all_heaters() {
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
max6675_temp >>= MAX6675_DISCARD_BITS;
|
max6675_temp >>= MAX6675_DISCARD_BITS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
max6675_temp >>= MAX6675_DISCARD_BITS;
|
||||||
|
max6675_errors[hindex] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLED(MAX6675_IS_MAX31855)
|
#if ENABLED(MAX6675_IS_MAX31855)
|
||||||
if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature
|
if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature
|
||||||
|
|
Reference in a new issue