Fixes issue with "temp errors"
This branch stops the false error message that were being produce from occurring and being sent to SERIAL_PORT. See https://github.com/MarlinFirmware/Marlin/issues/19994#issue-734104840. Added a new ability that when the Adafruit MAX31865 board is checked for faults, the code will now display which of the seven (7) possible faults it found on the SERIAL_PORT with an appropriate error message. Before it just displayed "Error: temp measurement error MAX6675", which does not indicate the fault condition of the Adafruit MAX31865. After a fault is found and message is displayed, the code will clear the fault on the board. Fixed the incorrect temperature being displayed by the Adafruit MAX31865 board connected to TEMP_SENSOR_1. This error was caused by the fact that Marlin never instantiated and object for the second Adafruit MAX31865 which meant it was never initialized and the raw data being produced by the board was never getting converted because Marlin did not handle the data coming from the board and convert it to Celsius. The wrong temperature value was read ~2047 at room temperature. Marlin did display the correct temperature for the first Adafruit MAX31865 connected to TEMP_SENSOR_0. Added a new ability that allows the user to use a (PT100 on E0 and a PT1000 on E1) OR (PT1000 on E0 and a PT100 on E1). To do this I updated the MAX31865_SENSOR_OHMS to MAX31865_SENSOR_OHMS_0. I also updated MAX31865_CALIBRATION_OHMS to MAX31865_CALIBRATION_OHMS_0. I then added two additional Marlin variables which are used for TEMP_SENSOR_1 called MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1. With these four Marlin variables, the user can now use a PT100 and a PT1000 on the printer at the same time. Added a check in SanityCheck.h that check to ensure that MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 are set if TEMP_SENSOR_1 is using the MAX31865 board. See https://github.com/MarlinFirmware/Marlin/issues/19994#issue-734104840. This branch fixes the "temp errors" being sent to the SERIAL_PORT. Feature request fullfilled: https://github.com/MarlinFirmware/Marlin/issues/19663#issue-717855237
This commit is contained in:
parent
6ccb4b93b1
commit
b2bd547a27
2 changed files with 89 additions and 9 deletions
|
|
@ -1814,8 +1814,12 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
|
||||||
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
|
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MAX6675_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS) && defined(MAX31865_CALIBRATION_OHMS))
|
#if MAX6675_IS_MAX31865 && (!defined(MAX31865_SENSOR_OHMS_0) || !defined(MAX31865_CALIBRATION_OHMS_0)) //ga
|
||||||
#error "MAX31865_SENSOR_OHMS and MAX31865_CALIBRATION_OHMS must be set in Configuration.h when using a MAX31865 temperature sensor."
|
#error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set in Configuration.h when using a MAX31865 temperature sensor on TEMP_SENSOR_0."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MAX6675_IS_MAX31865 && (!defined(MAX31865_SENSOR_OHMS_1) || !defined(MAX31865_CALIBRATION_OHMS_1)) && TEMP_SENSOR_1 == -5 //ga
|
||||||
|
#error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set in Configuration.h when using a MAX31865 temperature sensor on TEMP_SENSOR_1."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,11 @@
|
||||||
#ifndef MAX31865_CS_PIN
|
#ifndef MAX31865_CS_PIN
|
||||||
#define MAX31865_CS_PIN MAX6675_SS_PIN // HW:49 SW:65 for example
|
#define MAX31865_CS_PIN MAX6675_SS_PIN // HW:49 SW:65 for example
|
||||||
#endif
|
#endif
|
||||||
|
#if TEMP_SENSOR_1 == -5
|
||||||
|
#ifndef MAX31865_CS2_PIN
|
||||||
|
#define MAX31865_CS2_PIN MAX6675_SS2_PIN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#ifndef MAX31865_MOSI_PIN
|
#ifndef MAX31865_MOSI_PIN
|
||||||
#define MAX31865_MOSI_PIN MOSI_PIN // 63
|
#define MAX31865_MOSI_PIN MOSI_PIN // 63
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -58,13 +63,24 @@
|
||||||
#ifndef MAX31865_SCK_PIN
|
#ifndef MAX31865_SCK_PIN
|
||||||
#define MAX31865_SCK_PIN MAX6675_SCK_PIN // 40
|
#define MAX31865_SCK_PIN MAX6675_SCK_PIN // 40
|
||||||
#endif
|
#endif
|
||||||
Adafruit_MAX31865 max31865 = Adafruit_MAX31865(MAX31865_CS_PIN
|
Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN //ga
|
||||||
#if MAX31865_CS_PIN != MAX6675_SS_PIN
|
#if MAX31865_CS_PIN != MAX6675_SS_PIN
|
||||||
, MAX31865_MOSI_PIN // For software SPI also set MOSI/MISO/SCK
|
, MAX31865_MOSI_PIN // For software SPI also set MOSI/MISO/SCK
|
||||||
, MAX31865_MISO_PIN
|
, MAX31865_MISO_PIN
|
||||||
, MAX31865_SCK_PIN
|
, MAX31865_SCK_PIN
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
#if TEMP_SENSOR_1 == -5 //ga
|
||||||
|
#if MAX31865_CS2_PIN
|
||||||
|
Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN
|
||||||
|
#if MAX31865_CS2_PIN != MAX6675_SS2_PIN
|
||||||
|
, MAX31865_MOSI_PIN // For software SPI also set MOSI/MISO/SCK
|
||||||
|
, MAX31865_MISO_PIN
|
||||||
|
, MAX31865_SCK_PIN
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX6675_SEPARATE_SPI (EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO))
|
#define MAX6675_SEPARATE_SPI (EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO))
|
||||||
|
|
@ -1473,7 +1489,7 @@ void Temperature::manage_heater() {
|
||||||
#elif HEATER_0_USES_MAX6675
|
#elif HEATER_0_USES_MAX6675
|
||||||
return (
|
return (
|
||||||
#if MAX6675_IS_MAX31865
|
#if MAX6675_IS_MAX31865
|
||||||
max31865.temperature(MAX31865_SENSOR_OHMS, MAX31865_CALIBRATION_OHMS)
|
max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) //ga
|
||||||
#else
|
#else
|
||||||
raw * 0.25
|
raw * 0.25
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1489,7 +1505,13 @@ void Temperature::manage_heater() {
|
||||||
#if HEATER_1_USER_THERMISTOR
|
#if HEATER_1_USER_THERMISTOR
|
||||||
return user_thermistor_to_deg_c(CTI_HOTEND_1, raw);
|
return user_thermistor_to_deg_c(CTI_HOTEND_1, raw);
|
||||||
#elif HEATER_1_USES_MAX6675
|
#elif HEATER_1_USES_MAX6675
|
||||||
return raw * 0.25;
|
return (
|
||||||
|
#if TEMP_SENSOR_1 == -5
|
||||||
|
max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) //ga
|
||||||
|
#else
|
||||||
|
raw * 0.25
|
||||||
|
#endif
|
||||||
|
);
|
||||||
#elif HEATER_1_USES_AD595
|
#elif HEATER_1_USES_AD595
|
||||||
return TEMP_AD595(raw);
|
return TEMP_AD595(raw);
|
||||||
#elif HEATER_1_USES_AD8495
|
#elif HEATER_1_USES_AD8495
|
||||||
|
|
@ -1691,7 +1713,11 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||||
*/
|
*/
|
||||||
void Temperature::init() {
|
void Temperature::init() {
|
||||||
|
|
||||||
TERN_(MAX6675_IS_MAX31865, max31865.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
|
TERN_(MAX6675_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE //ga
|
||||||
|
|
||||||
|
#if TEMP_SENSOR_1 == -5
|
||||||
|
TERN_(MAX6675_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE //ga
|
||||||
|
#endif
|
||||||
|
|
||||||
#if EARLY_WATCHDOG
|
#if EARLY_WATCHDOG
|
||||||
// Flag that the thermalManager should be running
|
// Flag that the thermalManager should be running
|
||||||
|
|
@ -2221,6 +2247,11 @@ void Temperature::disable_all_heaters() {
|
||||||
#define MAX6675_ERROR_MASK 7
|
#define MAX6675_ERROR_MASK 7
|
||||||
#define MAX6675_DISCARD_BITS 18
|
#define MAX6675_DISCARD_BITS 18
|
||||||
#define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
#define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
||||||
|
#elif ENABLED(MAX6675_IS_MAX31865) //ga
|
||||||
|
static uint16_t max6675_temp = 2000; //from datasheet 16 bits D15-D0
|
||||||
|
#define MAX6675_ERROR_MASK 1 //D0 Bit not used
|
||||||
|
#define MAX6675_DISCARD_BITS 1 //data is in D15-D1
|
||||||
|
#define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
||||||
#else
|
#else
|
||||||
static uint16_t max6675_temp = 2000;
|
static uint16_t max6675_temp = 2000;
|
||||||
#define MAX6675_ERROR_MASK 4
|
#define MAX6675_ERROR_MASK 4
|
||||||
|
|
@ -2242,8 +2273,16 @@ void Temperature::disable_all_heaters() {
|
||||||
|
|
||||||
next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL;
|
next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL;
|
||||||
|
|
||||||
#if MAX6675_IS_MAX31865
|
#if COUNT_6675 == 1 && MAX6675_IS_MAX31865
|
||||||
max6675_temp = int(max31865.temperature(MAX31865_SENSOR_OHMS, MAX31865_CALIBRATION_OHMS));
|
max6675_temp = int(max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0)); //ga
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if COUNT_6675 > 1 && MAX6675_IS_MAX31865
|
||||||
|
#if hindex == 0
|
||||||
|
max6675_temp = int(max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0)); //ga
|
||||||
|
#elif hindex == 1
|
||||||
|
max6675_temp = int(max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -2285,7 +2324,18 @@ void Temperature::disable_all_heaters() {
|
||||||
|
|
||||||
WRITE_MAX6675(HIGH); // disable TT_MAX6675
|
WRITE_MAX6675(HIGH); // disable TT_MAX6675
|
||||||
|
|
||||||
if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK)) {
|
uint8_t fault = 1;
|
||||||
|
#if (COUNT_6675 == 1 && ENABLED(MAX6675_IS_MAX31865))
|
||||||
|
fault = max31865_0.readFault();
|
||||||
|
#elif ENABLED(MAX6675_IS_MAX31865)
|
||||||
|
#if hindex == 0
|
||||||
|
fault = max31865_0.readFault(); //ga
|
||||||
|
#elif hindex == 1
|
||||||
|
fault = max31865_1.readFault();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault) { //ga
|
||||||
max6675_errors[hindex] += 1;
|
max6675_errors[hindex] += 1;
|
||||||
if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
|
if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
|
|
@ -2298,6 +2348,32 @@ void Temperature::disable_all_heaters() {
|
||||||
SERIAL_ECHOLNPGM("Short to GND");
|
SERIAL_ECHOLNPGM("Short to GND");
|
||||||
else if (max6675_temp & 4)
|
else if (max6675_temp & 4)
|
||||||
SERIAL_ECHOLNPGM("Short to VCC");
|
SERIAL_ECHOLNPGM("Short to VCC");
|
||||||
|
#elif MAX6675_ERROR_MASK == 1 //ga
|
||||||
|
if (fault) {
|
||||||
|
SERIAL_ECHOPAIR("MAX31865 Fault :(", fault, ") >>");
|
||||||
|
if (fault & MAX31865_FAULT_HIGHTHRESH)
|
||||||
|
SERIAL_ECHOLNPGM("RTD High Threshold");
|
||||||
|
else if (fault & MAX31865_FAULT_LOWTHRESH)
|
||||||
|
SERIAL_ECHOLNPGM("RTD Low Threshold");
|
||||||
|
else if (fault & MAX31865_FAULT_REFINLOW)
|
||||||
|
SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias");
|
||||||
|
else if (fault & MAX31865_FAULT_REFINHIGH)
|
||||||
|
SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open");
|
||||||
|
else if (fault & MAX31865_FAULT_RTDINLOW)
|
||||||
|
SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open");
|
||||||
|
else if (fault & MAX31865_FAULT_OVUV)
|
||||||
|
SERIAL_ECHOLNPGM("Under/Over voltage");
|
||||||
|
|
||||||
|
#if COUNT_6675 == 1
|
||||||
|
max31865_0.clearFault();
|
||||||
|
#else
|
||||||
|
#if hindex == 0
|
||||||
|
max31865_0.clearFault();
|
||||||
|
#elif hindex == 1
|
||||||
|
max31865_1.clearFault();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
SERIAL_ECHOLNPGM("MAX6675");
|
SERIAL_ECHOLNPGM("MAX6675");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue