|
@@ -47,12 +47,12 @@
|
47
|
47
|
#include "../lcd/extui/ui_api.h"
|
48
|
48
|
#endif
|
49
|
49
|
|
50
|
|
-#if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865
|
|
50
|
+#if HAS_MAX31865
|
51
|
51
|
#include <Adafruit_MAX31865.h>
|
52
|
|
- #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS)
|
|
52
|
+ #if TEMP_SENSOR_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS)
|
53
|
53
|
#define MAX31865_CS_PIN MAX6675_SS_PIN
|
54
|
54
|
#endif
|
55
|
|
- #if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2)
|
|
55
|
+ #if TEMP_SENSOR_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2)
|
56
|
56
|
#define MAX31865_CS2_PIN MAX6675_SS2_PIN
|
57
|
57
|
#endif
|
58
|
58
|
#ifndef MAX31865_MOSI_PIN
|
|
@@ -64,16 +64,16 @@
|
64
|
64
|
#ifndef MAX31865_SCK_PIN
|
65
|
65
|
#define MAX31865_SCK_PIN MAX6675_SCK_PIN
|
66
|
66
|
#endif
|
67
|
|
- #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
|
68
|
|
- #define HAS_MAX31865 1
|
|
67
|
+ #if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
|
|
68
|
+ #define HAS_MAX31865_TEMP 1
|
69
|
69
|
Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN
|
70
|
70
|
#if MAX31865_CS_PIN != MAX6675_SS_PIN
|
71
|
71
|
, MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK
|
72
|
72
|
#endif
|
73
|
73
|
);
|
74
|
74
|
#endif
|
75
|
|
- #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
|
76
|
|
- #define HAS_MAX31865 1
|
|
75
|
+ #if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
|
|
76
|
+ #define HAS_MAX31865_TEMP 1
|
77
|
77
|
Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN
|
78
|
78
|
#if MAX31865_CS2_PIN != MAX6675_SS2_PIN
|
79
|
79
|
, MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK
|
|
@@ -82,11 +82,11 @@
|
82
|
82
|
#endif
|
83
|
83
|
#endif
|
84
|
84
|
|
85
|
|
-#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO)
|
86
|
|
- #define MAX6675_SEPARATE_SPI 1
|
|
85
|
+#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
|
|
86
|
+ #define THERMO_SEPARATE_SPI 1
|
87
|
87
|
#endif
|
88
|
88
|
|
89
|
|
-#if MAX6675_SEPARATE_SPI
|
|
89
|
+#if THERMO_SEPARATE_SPI
|
90
|
90
|
#include "../libs/private_spi.h"
|
91
|
91
|
#endif
|
92
|
92
|
|
|
@@ -132,20 +132,20 @@
|
132
|
132
|
#include "./servo.h"
|
133
|
133
|
#endif
|
134
|
134
|
|
135
|
|
-#if ANY(HEATER_0_USES_THERMISTOR, HEATER_1_USES_THERMISTOR, HEATER_2_USES_THERMISTOR, HEATER_3_USES_THERMISTOR, \
|
136
|
|
- HEATER_4_USES_THERMISTOR, HEATER_5_USES_THERMISTOR, HEATER_6_USES_THERMISTOR, HEATER_7_USES_THERMISTOR )
|
|
135
|
+#if ANY(TEMP_SENSOR_0_IS_THERMISTOR, TEMP_SENSOR_1_IS_THERMISTOR, TEMP_SENSOR_2_IS_THERMISTOR, TEMP_SENSOR_3_IS_THERMISTOR, \
|
|
136
|
+ TEMP_SENSOR_4_IS_THERMISTOR, TEMP_SENSOR_5_IS_THERMISTOR, TEMP_SENSOR_6_IS_THERMISTOR, TEMP_SENSOR_7_IS_THERMISTOR )
|
137
|
137
|
#define HAS_HOTEND_THERMISTOR 1
|
138
|
138
|
#endif
|
139
|
139
|
|
140
|
140
|
#if HAS_HOTEND_THERMISTOR
|
141
|
141
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
142
|
|
- static const temp_entry_t* heater_ttbl_map[2] = { HEATER_0_TEMPTABLE, HEATER_1_TEMPTABLE };
|
143
|
|
- static constexpr uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
|
|
142
|
+ static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 };
|
|
143
|
+ static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN };
|
144
|
144
|
#else
|
145
|
|
- #define NEXT_TEMPTABLE(N) ,HEATER_##N##_TEMPTABLE
|
146
|
|
- #define NEXT_TEMPTABLE_LEN(N) ,HEATER_##N##_TEMPTABLE_LEN
|
147
|
|
- static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
|
148
|
|
- static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
|
|
145
|
+ #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N
|
|
146
|
+ #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN
|
|
147
|
+ static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
|
|
148
|
+ static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
|
149
|
149
|
#endif
|
150
|
150
|
#endif
|
151
|
151
|
|
|
@@ -285,10 +285,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
|
285
|
285
|
bed_info_t Temperature::temp_bed; // = { 0 }
|
286
|
286
|
// Init min and max temp with extreme values to prevent false errors during startup
|
287
|
287
|
#ifdef BED_MINTEMP
|
288
|
|
- int16_t Temperature::mintemp_raw_BED = HEATER_BED_RAW_LO_TEMP;
|
|
288
|
+ int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP;
|
289
|
289
|
#endif
|
290
|
290
|
#ifdef BED_MAXTEMP
|
291
|
|
- int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP;
|
|
291
|
+ int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
|
292
|
292
|
#endif
|
293
|
293
|
TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
|
294
|
294
|
IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
|
|
@@ -303,10 +303,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
|
303
|
303
|
millis_t next_cool_check_ms_2 = 0;
|
304
|
304
|
float old_temp = 9999;
|
305
|
305
|
#ifdef CHAMBER_MINTEMP
|
306
|
|
- int16_t Temperature::mintemp_raw_CHAMBER = HEATER_CHAMBER_RAW_LO_TEMP;
|
|
306
|
+ int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP;
|
307
|
307
|
#endif
|
308
|
308
|
#ifdef CHAMBER_MAXTEMP
|
309
|
|
- int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP;
|
|
309
|
+ int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
|
310
|
310
|
#endif
|
311
|
311
|
#if WATCH_CHAMBER
|
312
|
312
|
chamber_watch_t Temperature::watch_chamber{0};
|
|
@@ -347,18 +347,18 @@ volatile bool Temperature::raw_temps_ready = false;
|
347
|
347
|
lpq_ptr_t Temperature::lpq_ptr = 0;
|
348
|
348
|
#endif
|
349
|
349
|
|
350
|
|
-#define TEMPDIR(N) ((HEATER_##N##_RAW_LO_TEMP) < (HEATER_##N##_RAW_HI_TEMP) ? 1 : -1)
|
|
350
|
+#define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1)
|
351
|
351
|
|
352
|
352
|
#if HAS_HOTEND
|
353
|
353
|
// Init mintemp and maxtemp with extreme values to prevent false errors during startup
|
354
|
|
- constexpr temp_range_t sensor_heater_0 { HEATER_0_RAW_LO_TEMP, HEATER_0_RAW_HI_TEMP, 0, 16383 },
|
355
|
|
- sensor_heater_1 { HEATER_1_RAW_LO_TEMP, HEATER_1_RAW_HI_TEMP, 0, 16383 },
|
356
|
|
- sensor_heater_2 { HEATER_2_RAW_LO_TEMP, HEATER_2_RAW_HI_TEMP, 0, 16383 },
|
357
|
|
- sensor_heater_3 { HEATER_3_RAW_LO_TEMP, HEATER_3_RAW_HI_TEMP, 0, 16383 },
|
358
|
|
- sensor_heater_4 { HEATER_4_RAW_LO_TEMP, HEATER_4_RAW_HI_TEMP, 0, 16383 },
|
359
|
|
- sensor_heater_5 { HEATER_5_RAW_LO_TEMP, HEATER_5_RAW_HI_TEMP, 0, 16383 },
|
360
|
|
- sensor_heater_6 { HEATER_6_RAW_LO_TEMP, HEATER_6_RAW_HI_TEMP, 0, 16383 },
|
361
|
|
- sensor_heater_7 { HEATER_7_RAW_LO_TEMP, HEATER_7_RAW_HI_TEMP, 0, 16383 };
|
|
354
|
+ constexpr temp_range_t sensor_heater_0 { TEMP_SENSOR_0_RAW_LO_TEMP, TEMP_SENSOR_0_RAW_HI_TEMP, 0, 16383 },
|
|
355
|
+ sensor_heater_1 { TEMP_SENSOR_1_RAW_LO_TEMP, TEMP_SENSOR_1_RAW_HI_TEMP, 0, 16383 },
|
|
356
|
+ sensor_heater_2 { TEMP_SENSOR_2_RAW_LO_TEMP, TEMP_SENSOR_2_RAW_HI_TEMP, 0, 16383 },
|
|
357
|
+ sensor_heater_3 { TEMP_SENSOR_3_RAW_LO_TEMP, TEMP_SENSOR_3_RAW_HI_TEMP, 0, 16383 },
|
|
358
|
+ sensor_heater_4 { TEMP_SENSOR_4_RAW_LO_TEMP, TEMP_SENSOR_4_RAW_HI_TEMP, 0, 16383 },
|
|
359
|
+ sensor_heater_5 { TEMP_SENSOR_5_RAW_LO_TEMP, TEMP_SENSOR_5_RAW_HI_TEMP, 0, 16383 },
|
|
360
|
+ sensor_heater_6 { TEMP_SENSOR_6_RAW_LO_TEMP, TEMP_SENSOR_6_RAW_HI_TEMP, 0, 16383 },
|
|
361
|
+ sensor_heater_7 { TEMP_SENSOR_7_RAW_LO_TEMP, TEMP_SENSOR_7_RAW_HI_TEMP, 0, 16383 };
|
362
|
362
|
|
363
|
363
|
temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0, sensor_heater_1, sensor_heater_2, sensor_heater_3, sensor_heater_4, sensor_heater_5, sensor_heater_6, sensor_heater_7);
|
364
|
364
|
#endif
|
|
@@ -1083,13 +1083,13 @@ void Temperature::manage_heater() {
|
1083
|
1083
|
updateTemperaturesFromRawValues(); // also resets the watchdog
|
1084
|
1084
|
|
1085
|
1085
|
#if DISABLED(IGNORE_THERMOCOUPLE_ERRORS)
|
1086
|
|
- #if HEATER_0_USES_MAX6675
|
1087
|
|
- if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
|
1088
|
|
- if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
|
|
1086
|
+ #if TEMP_SENSOR_0_IS_MAX_TC
|
|
1087
|
+ if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0);
|
|
1088
|
+ if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0);
|
1089
|
1089
|
#endif
|
1090
|
|
- #if HEATER_1_USES_MAX6675
|
1091
|
|
- if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
|
1092
|
|
- if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
|
|
1090
|
+ #if TEMP_SENSOR_1_IS_MAX_TC
|
|
1091
|
+ if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1);
|
|
1092
|
+ if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1);
|
1093
|
1093
|
#endif
|
1094
|
1094
|
#endif
|
1095
|
1095
|
|
|
@@ -1373,36 +1373,39 @@ void Temperature::manage_heater() {
|
1373
|
1373
|
|
1374
|
1374
|
void Temperature::reset_user_thermistors() {
|
1375
|
1375
|
user_thermistor_t default_user_thermistor[USER_THERMISTORS] = {
|
1376
|
|
- #if HEATER_0_USER_THERMISTOR
|
|
1376
|
+ #if TEMP_SENSOR_0_IS_CUSTOM
|
1377
|
1377
|
{ true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 },
|
1378
|
1378
|
#endif
|
1379
|
|
- #if HEATER_1_USER_THERMISTOR
|
|
1379
|
+ #if TEMP_SENSOR_1_IS_CUSTOM
|
1380
|
1380
|
{ true, 0, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 },
|
1381
|
1381
|
#endif
|
1382
|
|
- #if HEATER_2_USER_THERMISTOR
|
|
1382
|
+ #if TEMP_SENSOR_2_IS_CUSTOM
|
1383
|
1383
|
{ true, 0, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 },
|
1384
|
1384
|
#endif
|
1385
|
|
- #if HEATER_3_USER_THERMISTOR
|
|
1385
|
+ #if TEMP_SENSOR_3_IS_CUSTOM
|
1386
|
1386
|
{ true, 0, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 },
|
1387
|
1387
|
#endif
|
1388
|
|
- #if HEATER_4_USER_THERMISTOR
|
|
1388
|
+ #if TEMP_SENSOR_4_IS_CUSTOM
|
1389
|
1389
|
{ true, 0, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 },
|
1390
|
1390
|
#endif
|
1391
|
|
- #if HEATER_5_USER_THERMISTOR
|
|
1391
|
+ #if TEMP_SENSOR_5_IS_CUSTOM
|
1392
|
1392
|
{ true, 0, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 },
|
1393
|
1393
|
#endif
|
1394
|
|
- #if HEATER_6_USER_THERMISTOR
|
|
1394
|
+ #if TEMP_SENSOR_6_IS_CUSTOM
|
1395
|
1395
|
{ true, 0, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 },
|
1396
|
1396
|
#endif
|
1397
|
|
- #if HEATER_7_USER_THERMISTOR
|
|
1397
|
+ #if TEMP_SENSOR_7_IS_CUSTOM
|
1398
|
1398
|
{ true, 0, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 },
|
1399
|
1399
|
#endif
|
1400
|
|
- #if HEATER_BED_USER_THERMISTOR
|
|
1400
|
+ #if TEMP_SENSOR_BED_IS_CUSTOM
|
1401
|
1401
|
{ true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 },
|
1402
|
1402
|
#endif
|
1403
|
|
- #if HEATER_CHAMBER_USER_THERMISTOR
|
|
1403
|
+ #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
|
1404
|
1404
|
{ true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }
|
1405
|
1405
|
#endif
|
|
1406
|
+ #if TEMP_SENSOR_PROBE_IS_CUSTOM
|
|
1407
|
+ { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }
|
|
1408
|
+ #endif
|
1406
|
1409
|
};
|
1407
|
1410
|
COPY(user_thermistor, default_user_thermistor);
|
1408
|
1411
|
}
|
|
@@ -1423,16 +1426,17 @@ void Temperature::manage_heater() {
|
1423
|
1426
|
SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9);
|
1424
|
1427
|
SERIAL_ECHOPGM(" ; ");
|
1425
|
1428
|
serialprintPGM(
|
1426
|
|
- TERN_(HEATER_0_USER_THERMISTOR, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :)
|
1427
|
|
- TERN_(HEATER_1_USER_THERMISTOR, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :)
|
1428
|
|
- TERN_(HEATER_2_USER_THERMISTOR, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :)
|
1429
|
|
- TERN_(HEATER_3_USER_THERMISTOR, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :)
|
1430
|
|
- TERN_(HEATER_4_USER_THERMISTOR, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :)
|
1431
|
|
- TERN_(HEATER_5_USER_THERMISTOR, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :)
|
1432
|
|
- TERN_(HEATER_6_USER_THERMISTOR, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :)
|
1433
|
|
- TERN_(HEATER_7_USER_THERMISTOR, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :)
|
1434
|
|
- TERN_(HEATER_BED_USER_THERMISTOR, t_index == CTI_BED ? PSTR("BED") :)
|
1435
|
|
- TERN_(HEATER_CHAMBER_USER_THERMISTOR, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
|
|
1429
|
+ TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :)
|
|
1430
|
+ TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :)
|
|
1431
|
+ TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :)
|
|
1432
|
+ TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :)
|
|
1433
|
+ TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :)
|
|
1434
|
+ TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :)
|
|
1435
|
+ TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :)
|
|
1436
|
+ TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :)
|
|
1437
|
+ TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :)
|
|
1438
|
+ TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
|
|
1439
|
+ TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :)
|
1436
|
1440
|
nullptr
|
1437
|
1441
|
);
|
1438
|
1442
|
SERIAL_EOL();
|
|
@@ -1498,85 +1502,85 @@ void Temperature::manage_heater() {
|
1498
|
1502
|
|
1499
|
1503
|
switch (e) {
|
1500
|
1504
|
case 0:
|
1501
|
|
- #if HEATER_0_USER_THERMISTOR
|
|
1505
|
+ #if TEMP_SENSOR_0_IS_CUSTOM
|
1502
|
1506
|
return user_thermistor_to_deg_c(CTI_HOTEND_0, raw);
|
1503
|
|
- #elif HEATER_0_USES_MAX6675
|
1504
|
|
- return TERN(MAX6675_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25);
|
1505
|
|
- #elif HEATER_0_USES_AD595
|
|
1507
|
+ #elif TEMP_SENSOR_0_IS_MAX_TC
|
|
1508
|
+ return TERN(TEMP_SENSOR_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25);
|
|
1509
|
+ #elif TEMP_SENSOR_0_IS_AD595
|
1506
|
1510
|
return TEMP_AD595(raw);
|
1507
|
|
- #elif HEATER_0_USES_AD8495
|
|
1511
|
+ #elif TEMP_SENSOR_0_IS_AD8495
|
1508
|
1512
|
return TEMP_AD8495(raw);
|
1509
|
1513
|
#else
|
1510
|
1514
|
break;
|
1511
|
1515
|
#endif
|
1512
|
1516
|
case 1:
|
1513
|
|
- #if HEATER_1_USER_THERMISTOR
|
|
1517
|
+ #if TEMP_SENSOR_1_IS_CUSTOM
|
1514
|
1518
|
return user_thermistor_to_deg_c(CTI_HOTEND_1, raw);
|
1515
|
|
- #elif HEATER_1_USES_MAX6675
|
1516
|
|
- return TERN(MAX6675_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25);
|
1517
|
|
- #elif HEATER_1_USES_AD595
|
|
1519
|
+ #elif TEMP_SENSOR_1_IS_MAX_TC
|
|
1520
|
+ return TERN(TEMP_SENSOR_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25);
|
|
1521
|
+ #elif TEMP_SENSOR_1_IS_AD595
|
1518
|
1522
|
return TEMP_AD595(raw);
|
1519
|
|
- #elif HEATER_1_USES_AD8495
|
|
1523
|
+ #elif TEMP_SENSOR_1_IS_AD8495
|
1520
|
1524
|
return TEMP_AD8495(raw);
|
1521
|
1525
|
#else
|
1522
|
1526
|
break;
|
1523
|
1527
|
#endif
|
1524
|
1528
|
case 2:
|
1525
|
|
- #if HEATER_2_USER_THERMISTOR
|
|
1529
|
+ #if TEMP_SENSOR_2_IS_CUSTOM
|
1526
|
1530
|
return user_thermistor_to_deg_c(CTI_HOTEND_2, raw);
|
1527
|
|
- #elif HEATER_2_USES_AD595
|
|
1531
|
+ #elif TEMP_SENSOR_2_IS_AD595
|
1528
|
1532
|
return TEMP_AD595(raw);
|
1529
|
|
- #elif HEATER_2_USES_AD8495
|
|
1533
|
+ #elif TEMP_SENSOR_2_IS_AD8495
|
1530
|
1534
|
return TEMP_AD8495(raw);
|
1531
|
1535
|
#else
|
1532
|
1536
|
break;
|
1533
|
1537
|
#endif
|
1534
|
1538
|
case 3:
|
1535
|
|
- #if HEATER_3_USER_THERMISTOR
|
|
1539
|
+ #if TEMP_SENSOR_3_IS_CUSTOM
|
1536
|
1540
|
return user_thermistor_to_deg_c(CTI_HOTEND_3, raw);
|
1537
|
|
- #elif HEATER_3_USES_AD595
|
|
1541
|
+ #elif TEMP_SENSOR_3_IS_AD595
|
1538
|
1542
|
return TEMP_AD595(raw);
|
1539
|
|
- #elif HEATER_3_USES_AD8495
|
|
1543
|
+ #elif TEMP_SENSOR_3_IS_AD8495
|
1540
|
1544
|
return TEMP_AD8495(raw);
|
1541
|
1545
|
#else
|
1542
|
1546
|
break;
|
1543
|
1547
|
#endif
|
1544
|
1548
|
case 4:
|
1545
|
|
- #if HEATER_4_USER_THERMISTOR
|
|
1549
|
+ #if TEMP_SENSOR_4_IS_CUSTOM
|
1546
|
1550
|
return user_thermistor_to_deg_c(CTI_HOTEND_4, raw);
|
1547
|
|
- #elif HEATER_4_USES_AD595
|
|
1551
|
+ #elif TEMP_SENSOR_4_IS_AD595
|
1548
|
1552
|
return TEMP_AD595(raw);
|
1549
|
|
- #elif HEATER_4_USES_AD8495
|
|
1553
|
+ #elif TEMP_SENSOR_4_IS_AD8495
|
1550
|
1554
|
return TEMP_AD8495(raw);
|
1551
|
1555
|
#else
|
1552
|
1556
|
break;
|
1553
|
1557
|
#endif
|
1554
|
1558
|
case 5:
|
1555
|
|
- #if HEATER_5_USER_THERMISTOR
|
|
1559
|
+ #if TEMP_SENSOR_5_IS_CUSTOM
|
1556
|
1560
|
return user_thermistor_to_deg_c(CTI_HOTEND_5, raw);
|
1557
|
|
- #elif HEATER_5_USES_AD595
|
|
1561
|
+ #elif TEMP_SENSOR_5_IS_AD595
|
1558
|
1562
|
return TEMP_AD595(raw);
|
1559
|
|
- #elif HEATER_5_USES_AD8495
|
|
1563
|
+ #elif TEMP_SENSOR_5_IS_AD8495
|
1560
|
1564
|
return TEMP_AD8495(raw);
|
1561
|
1565
|
#else
|
1562
|
1566
|
break;
|
1563
|
1567
|
#endif
|
1564
|
1568
|
case 6:
|
1565
|
|
- #if HEATER_6_USER_THERMISTOR
|
|
1569
|
+ #if TEMP_SENSOR_6_IS_CUSTOM
|
1566
|
1570
|
return user_thermistor_to_deg_c(CTI_HOTEND_6, raw);
|
1567
|
|
- #elif HEATER_6_USES_AD595
|
|
1571
|
+ #elif TEMP_SENSOR_6_IS_AD595
|
1568
|
1572
|
return TEMP_AD595(raw);
|
1569
|
|
- #elif HEATER_6_USES_AD8495
|
|
1573
|
+ #elif TEMP_SENSOR_6_IS_AD8495
|
1570
|
1574
|
return TEMP_AD8495(raw);
|
1571
|
1575
|
#else
|
1572
|
1576
|
break;
|
1573
|
1577
|
#endif
|
1574
|
1578
|
case 7:
|
1575
|
|
- #if HEATER_7_USER_THERMISTOR
|
|
1579
|
+ #if TEMP_SENSOR_7_IS_CUSTOM
|
1576
|
1580
|
return user_thermistor_to_deg_c(CTI_HOTEND_7, raw);
|
1577
|
|
- #elif HEATER_7_USES_AD595
|
|
1581
|
+ #elif TEMP_SENSOR_7_IS_AD595
|
1578
|
1582
|
return TEMP_AD595(raw);
|
1579
|
|
- #elif HEATER_7_USES_AD8495
|
|
1583
|
+ #elif TEMP_SENSOR_7_IS_AD8495
|
1580
|
1584
|
return TEMP_AD8495(raw);
|
1581
|
1585
|
#else
|
1582
|
1586
|
break;
|
|
@@ -1598,13 +1602,13 @@ void Temperature::manage_heater() {
|
1598
|
1602
|
// Derived from RepRap FiveD extruder::getTemperature()
|
1599
|
1603
|
// For bed temperature measurement.
|
1600
|
1604
|
float Temperature::analog_to_celsius_bed(const int raw) {
|
1601
|
|
- #if HEATER_BED_USER_THERMISTOR
|
|
1605
|
+ #if TEMP_SENSOR_BED_IS_CUSTOM
|
1602
|
1606
|
return user_thermistor_to_deg_c(CTI_BED, raw);
|
1603
|
|
- #elif HEATER_BED_USES_THERMISTOR
|
1604
|
|
- SCAN_THERMISTOR_TABLE(BED_TEMPTABLE, BED_TEMPTABLE_LEN);
|
1605
|
|
- #elif HEATER_BED_USES_AD595
|
|
1607
|
+ #elif TEMP_SENSOR_BED_IS_THERMISTOR
|
|
1608
|
+ SCAN_THERMISTOR_TABLE(TEMPTABLE_BED, TEMPTABLE_BED_LEN);
|
|
1609
|
+ #elif TEMP_SENSOR_BED_IS_AD595
|
1606
|
1610
|
return TEMP_AD595(raw);
|
1607
|
|
- #elif HEATER_BED_USES_AD8495
|
|
1611
|
+ #elif TEMP_SENSOR_BED_IS_AD8495
|
1608
|
1612
|
return TEMP_AD8495(raw);
|
1609
|
1613
|
#else
|
1610
|
1614
|
UNUSED(raw);
|
|
@@ -1617,13 +1621,13 @@ void Temperature::manage_heater() {
|
1617
|
1621
|
// Derived from RepRap FiveD extruder::getTemperature()
|
1618
|
1622
|
// For chamber temperature measurement.
|
1619
|
1623
|
float Temperature::analog_to_celsius_chamber(const int raw) {
|
1620
|
|
- #if HEATER_CHAMBER_USER_THERMISTOR
|
|
1624
|
+ #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
|
1621
|
1625
|
return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
|
1622
|
|
- #elif HEATER_CHAMBER_USES_THERMISTOR
|
1623
|
|
- SCAN_THERMISTOR_TABLE(CHAMBER_TEMPTABLE, CHAMBER_TEMPTABLE_LEN);
|
1624
|
|
- #elif HEATER_CHAMBER_USES_AD595
|
|
1626
|
+ #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
|
|
1627
|
+ SCAN_THERMISTOR_TABLE(TEMPTABLE_CHAMBER, TEMPTABLE_CHAMBER_LEN);
|
|
1628
|
+ #elif TEMP_SENSOR_CHAMBER_IS_AD595
|
1625
|
1629
|
return TEMP_AD595(raw);
|
1626
|
|
- #elif HEATER_CHAMBER_USES_AD8495
|
|
1630
|
+ #elif TEMP_SENSOR_CHAMBER_IS_AD8495
|
1627
|
1631
|
return TEMP_AD8495(raw);
|
1628
|
1632
|
#else
|
1629
|
1633
|
UNUSED(raw);
|
|
@@ -1636,13 +1640,13 @@ void Temperature::manage_heater() {
|
1636
|
1640
|
// Derived from RepRap FiveD extruder::getTemperature()
|
1637
|
1641
|
// For probe temperature measurement.
|
1638
|
1642
|
float Temperature::analog_to_celsius_probe(const int raw) {
|
1639
|
|
- #if HEATER_PROBE_USER_THERMISTOR
|
|
1643
|
+ #if TEMP_SENSOR_PROBE_IS_CUSTOM
|
1640
|
1644
|
return user_thermistor_to_deg_c(CTI_PROBE, raw);
|
1641
|
|
- #elif HEATER_PROBE_USES_THERMISTOR
|
1642
|
|
- SCAN_THERMISTOR_TABLE(PROBE_TEMPTABLE, PROBE_TEMPTABLE_LEN);
|
1643
|
|
- #elif HEATER_PROBE_USES_AD595
|
|
1645
|
+ #elif TEMP_SENSOR_PROBE_IS_THERMISTOR
|
|
1646
|
+ SCAN_THERMISTOR_TABLE(TEMPTABLE_PROBE, TEMPTABLE_PROBE_LEN);
|
|
1647
|
+ #elif TEMP_SENSOR_PROBE_IS_AD595
|
1644
|
1648
|
return TEMP_AD595(raw);
|
1645
|
|
- #elif HEATER_PROBE_USES_AD8495
|
|
1649
|
+ #elif TEMP_SENSOR_PROBE_IS_AD8495
|
1646
|
1650
|
return TEMP_AD8495(raw);
|
1647
|
1651
|
#else
|
1648
|
1652
|
UNUSED(raw);
|
|
@@ -1658,8 +1662,8 @@ void Temperature::manage_heater() {
|
1658
|
1662
|
* as it would block the stepper routine.
|
1659
|
1663
|
*/
|
1660
|
1664
|
void Temperature::updateTemperaturesFromRawValues() {
|
1661
|
|
- TERN_(HEATER_0_USES_MAX6675, temp_hotend[0].raw = READ_MAX6675(0));
|
1662
|
|
- TERN_(HEATER_1_USES_MAX6675, temp_hotend[1].raw = READ_MAX6675(1));
|
|
1665
|
+ TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0));
|
|
1666
|
+ TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1));
|
1663
|
1667
|
#if HAS_HOTEND
|
1664
|
1668
|
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
|
1665
|
1669
|
#endif
|
|
@@ -1676,9 +1680,9 @@ void Temperature::updateTemperaturesFromRawValues() {
|
1676
|
1680
|
raw_temps_ready = false;
|
1677
|
1681
|
}
|
1678
|
1682
|
|
1679
|
|
-#if MAX6675_SEPARATE_SPI
|
|
1683
|
+#if THERMO_SEPARATE_SPI
|
1680
|
1684
|
template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin> SoftSPI<MisoPin, MosiPin, SckPin> SPIclass<MisoPin, MosiPin, SckPin>::softSPI;
|
1681
|
|
- SPIclass<MAX6675_DO_PIN, SD_MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
|
|
1685
|
+ SPIclass<MAX6675_DO_PIN, SD_MOSI_PIN, MAX6675_SCK_PIN> max_tc_spi;
|
1682
|
1686
|
#endif
|
1683
|
1687
|
|
1684
|
1688
|
// Init fans according to whether they're native PWM or Software PWM
|
|
@@ -1715,8 +1719,8 @@ void Temperature::updateTemperaturesFromRawValues() {
|
1715
|
1719
|
*/
|
1716
|
1720
|
void Temperature::init() {
|
1717
|
1721
|
|
1718
|
|
- TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
|
1719
|
|
- TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE));
|
|
1722
|
+ TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
|
|
1723
|
+ TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE));
|
1720
|
1724
|
|
1721
|
1725
|
#if EARLY_WATCHDOG
|
1722
|
1726
|
// Flag that the thermalManager should be running
|
|
@@ -1726,7 +1730,7 @@ void Temperature::init() {
|
1726
|
1730
|
|
1727
|
1731
|
#if MB(RUMBA)
|
1728
|
1732
|
// Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
|
1729
|
|
- #define _AD(N) (HEATER_##N##_USES_AD595 || HEATER_##N##_USES_AD8495)
|
|
1733
|
+ #define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495)
|
1730
|
1734
|
#if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
|
1731
|
1735
|
MCUCR = _BV(JTD);
|
1732
|
1736
|
MCUCR = _BV(JTD);
|
|
@@ -1734,11 +1738,11 @@ void Temperature::init() {
|
1734
|
1738
|
#endif
|
1735
|
1739
|
|
1736
|
1740
|
// Thermistor activation by MCU pin
|
1737
|
|
- #if PIN_EXISTS(TEMP_0_TR_ENABLE_PIN)
|
1738
|
|
- OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(HEATER_0_USES_MAX6675));
|
|
1741
|
+ #if PIN_EXISTS(TEMP_0_TR_ENABLE)
|
|
1742
|
+ OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC));
|
1739
|
1743
|
#endif
|
1740
|
|
- #if PIN_EXISTS(TEMP_1_TR_ENABLE_PIN)
|
1741
|
|
- OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(HEATER_1_USES_MAX6675));
|
|
1744
|
+ #if PIN_EXISTS(TEMP_1_TR_ENABLE)
|
|
1745
|
+ OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC));
|
1742
|
1746
|
#endif
|
1743
|
1747
|
|
1744
|
1748
|
#if BOTH(PIDTEMP, PID_EXTRUSION_SCALING)
|
|
@@ -1815,7 +1819,7 @@ void Temperature::init() {
|
1815
|
1819
|
INIT_FAN_PIN(CONTROLLER_FAN_PIN);
|
1816
|
1820
|
#endif
|
1817
|
1821
|
|
1818
|
|
- TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init());
|
|
1822
|
+ TERN_(THERMO_SEPARATE_SPI, max_tc_spi.init());
|
1819
|
1823
|
|
1820
|
1824
|
HAL_adc_init();
|
1821
|
1825
|
|
|
@@ -1914,19 +1918,19 @@ void Temperature::init() {
|
1914
|
1918
|
#if HAS_HOTEND
|
1915
|
1919
|
|
1916
|
1920
|
#define _TEMP_MIN_E(NR) do{ \
|
1917
|
|
- const int16_t tmin = _MAX(HEATER_ ##NR## _MINTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 0, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MINTEMP_IND].celsius))); \
|
|
1921
|
+ const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
|
1918
|
1922
|
temp_range[NR].mintemp = tmin; \
|
1919
|
1923
|
while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
|
1920
|
1924
|
temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
|
1921
|
1925
|
}while(0)
|
1922
|
1926
|
#define _TEMP_MAX_E(NR) do{ \
|
1923
|
|
- const int16_t tmax = _MIN(HEATER_ ##NR## _MAXTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 2000, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MAXTEMP_IND].celsius) - 1)); \
|
|
1927
|
+ const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
|
1924
|
1928
|
temp_range[NR].maxtemp = tmax; \
|
1925
|
1929
|
while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
|
1926
|
1930
|
temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
|
1927
|
1931
|
}while(0)
|
1928
|
1932
|
|
1929
|
|
- #define _MINMAX_TEST(N,M) (HOTENDS > N && THERMISTOR_HEATER_##N && THERMISTOR_HEATER_##N != 998 && THERMISTOR_HEATER_##N != 999 && defined(HEATER_##N##_##M##TEMP))
|
|
1933
|
+ #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## THERMISTOR_ID && TEMP_SENSOR_ ##N## THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP))
|
1930
|
1934
|
|
1931
|
1935
|
#if _MINMAX_TEST(0, MIN)
|
1932
|
1936
|
_TEMP_MIN_E(0);
|
|
@@ -2221,105 +2225,106 @@ void Temperature::disable_all_heaters() {
|
2221
|
2225
|
|
2222
|
2226
|
#endif
|
2223
|
2227
|
|
2224
|
|
-#if HAS_MAX6675
|
|
2228
|
+#if HAS_MAX_TC
|
2225
|
2229
|
|
2226
|
2230
|
#ifndef THERMOCOUPLE_MAX_ERRORS
|
2227
|
2231
|
#define THERMOCOUPLE_MAX_ERRORS 15
|
2228
|
2232
|
#endif
|
2229
|
2233
|
|
2230
|
|
- int Temperature::read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex/*=0*/)) {
|
|
2234
|
+ int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) {
|
2231
|
2235
|
#define MAX6675_HEAT_INTERVAL 250UL
|
2232
|
2236
|
|
2233
|
|
- #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855
|
2234
|
|
- static uint32_t max6675_temp = 2000;
|
2235
|
|
- #define MAX6675_ERROR_MASK 7
|
2236
|
|
- #define MAX6675_DISCARD_BITS 18
|
2237
|
|
- #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
2238
|
|
- #elif HAS_MAX31865
|
2239
|
|
- static uint16_t max6675_temp = 2000; // From datasheet 16 bits D15-D0
|
2240
|
|
- #define MAX6675_ERROR_MASK 1 // D0 Bit not used
|
2241
|
|
- #define MAX6675_DISCARD_BITS 1 // Data is in D15-D1
|
2242
|
|
- #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
|
2237
|
+ #if HAS_MAX31855
|
|
2238
|
+ static uint32_t max_tc_temp = 2000;
|
|
2239
|
+ #define MAX_TC_ERROR_MASK 7
|
|
2240
|
+ #define MAX_TC_DISCARD_BITS 18
|
|
2241
|
+ #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
|
2242
|
+ #elif HAS_MAX31865_TEMP
|
|
2243
|
+ static uint16_t max_tc_temp = 2000; // From datasheet 16 bits D15-D0
|
|
2244
|
+ #define MAX_TC_ERROR_MASK 1 // D0 Bit not used
|
|
2245
|
+ #define MAX_TC_DISCARD_BITS 1 // Data is in D15-D1
|
|
2246
|
+ #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
|
2243
|
2247
|
#else
|
2244
|
|
- static uint16_t max6675_temp = 2000;
|
2245
|
|
- #define MAX6675_ERROR_MASK 4
|
2246
|
|
- #define MAX6675_DISCARD_BITS 3
|
2247
|
|
- #define MAX6675_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16
|
|
2248
|
+ static uint16_t max_tc_temp = 2000;
|
|
2249
|
+ #define MAX_TC_ERROR_MASK 4
|
|
2250
|
+ #define MAX_TC_DISCARD_BITS 3
|
|
2251
|
+ #define MAX_TC_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16
|
2248
|
2252
|
#endif
|
2249
|
2253
|
|
2250
|
|
- #if HAS_MULTI_6675
|
|
2254
|
+ #if HAS_MULTI_MAX_TC
|
2251
|
2255
|
// Needed to return the correct temp when this is called between readings
|
2252
|
|
- static uint16_t max6675_temp_previous[COUNT_6675] = { 0 };
|
2253
|
|
- #define MAX6675_TEMP(I) max6675_temp_previous[I]
|
2254
|
|
- #define MAX6675_SEL(A,B) (hindex ? (B) : (A))
|
|
2256
|
+ static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
|
|
2257
|
+ #define THERMO_TEMP(I) max_tc_temp_previous[I]
|
|
2258
|
+ #define THERMO_SEL(A,B) (hindex ? (B) : (A))
|
2255
|
2259
|
#define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0)
|
2256
|
2260
|
#define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0)
|
2257
|
2261
|
#else
|
2258
|
2262
|
constexpr uint8_t hindex = 0;
|
2259
|
|
- #define MAX6675_TEMP(I) max6675_temp
|
2260
|
|
- #if MAX6675_1_IS_MAX31865
|
2261
|
|
- #define MAX6675_SEL(A,B) B
|
|
2263
|
+ #define THERMO_TEMP(I) max_tc_temp
|
|
2264
|
+ #if TEMP_SENSOR_1_IS_MAX31865
|
|
2265
|
+ #define THERMO_SEL(A,B) B
|
2262
|
2266
|
#else
|
2263
|
|
- #define MAX6675_SEL(A,B) A
|
|
2267
|
+ #define THERMO_SEL(A,B) A
|
2264
|
2268
|
#endif
|
2265
|
|
- #if HEATER_0_USES_MAX6675
|
|
2269
|
+ #if TEMP_SENSOR_0_IS_MAX6675
|
2266
|
2270
|
#define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V)
|
2267
|
2271
|
#define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN)
|
2268
|
2272
|
#else
|
2269
|
2273
|
#define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V)
|
2270
|
2274
|
#define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN)
|
2271
|
2275
|
#endif
|
|
2276
|
+
|
2272
|
2277
|
#endif
|
2273
|
2278
|
|
2274
|
|
- static uint8_t max6675_errors[COUNT_6675] = { 0 };
|
|
2279
|
+ static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 };
|
2275
|
2280
|
|
2276
|
2281
|
// Return last-read value between readings
|
2277
|
|
- static millis_t next_max6675_ms[COUNT_6675] = { 0 };
|
|
2282
|
+ static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 };
|
2278
|
2283
|
millis_t ms = millis();
|
2279
|
|
- if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex));
|
2280
|
|
- next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL;
|
|
2284
|
+ if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex));
|
|
2285
|
+ next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL;
|
2281
|
2286
|
|
2282
|
|
- #if HAS_MAX31865
|
2283
|
|
- Adafruit_MAX31865 &maxref = MAX6675_SEL(max31865_0, max31865_1);
|
2284
|
|
- const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16;
|
|
2287
|
+ #if HAS_MAX31865_TEMP
|
|
2288
|
+ Adafruit_MAX31865 &maxref = THERMO_SEL(max31865_0, max31865_1);
|
|
2289
|
+ const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16;
|
2285
|
2290
|
#endif
|
2286
|
2291
|
|
2287
|
2292
|
//
|
2288
|
2293
|
// TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used.
|
2289
|
2294
|
//
|
2290
|
|
- #if !MAX6675_SEPARATE_SPI
|
|
2295
|
+ #if !THERMO_SEPARATE_SPI
|
2291
|
2296
|
spiBegin();
|
2292
|
|
- spiInit(MAX6675_SPEED_BITS);
|
|
2297
|
+ spiInit(MAX_TC_SPEED_BITS);
|
2293
|
2298
|
#endif
|
2294
|
2299
|
|
2295
|
|
- MAX6675_WRITE(LOW); // enable TT_MAX6675
|
2296
|
|
- DELAY_NS(100); // Ensure 100ns delay
|
|
2300
|
+ MAX6675_WRITE(LOW); // enable TT_MAX6675
|
|
2301
|
+ DELAY_NS(100); // Ensure 100ns delay
|
2297
|
2302
|
|
2298
|
2303
|
// Read a big-endian temperature value
|
2299
|
|
- max6675_temp = 0;
|
2300
|
|
- for (uint8_t i = sizeof(max6675_temp); i--;) {
|
2301
|
|
- max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec());
|
2302
|
|
- if (i > 0) max6675_temp <<= 8; // shift left if not the last byte
|
|
2304
|
+ max_tc_temp = 0;
|
|
2305
|
+ for (uint8_t i = sizeof(max_tc_temp); i--;) {
|
|
2306
|
+ max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec());
|
|
2307
|
+ if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte
|
2303
|
2308
|
}
|
2304
|
2309
|
|
2305
|
2310
|
MAX6675_WRITE(HIGH); // disable TT_MAX6675
|
2306
|
2311
|
|
2307
|
|
- const uint8_t fault_31865 = TERN1(HAS_MAX31865, maxref.readFault());
|
|
2312
|
+ const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, maxref.readFault());
|
2308
|
2313
|
|
2309
|
|
- if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) {
|
2310
|
|
- max6675_errors[hindex]++;
|
2311
|
|
- if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
|
|
2314
|
+ if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max_tc_temp & MAX_TC_ERROR_MASK) && fault_31865) {
|
|
2315
|
+ max_tc_errors[hindex]++;
|
|
2316
|
+ if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
|
2312
|
2317
|
SERIAL_ERROR_START();
|
2313
|
2318
|
SERIAL_ECHOPGM("Temp measurement error! ");
|
2314
|
|
- #if MAX6675_ERROR_MASK == 7
|
|
2319
|
+ #if MAX_TC_ERROR_MASK == 7
|
2315
|
2320
|
SERIAL_ECHOPGM("MAX31855 ");
|
2316
|
|
- if (max6675_temp & 1)
|
|
2321
|
+ if (max_tc_temp & 1)
|
2317
|
2322
|
SERIAL_ECHOLNPGM("Open Circuit");
|
2318
|
|
- else if (max6675_temp & 2)
|
|
2323
|
+ else if (max_tc_temp & 2)
|
2319
|
2324
|
SERIAL_ECHOLNPGM("Short to GND");
|
2320
|
|
- else if (max6675_temp & 4)
|
|
2325
|
+ else if (max_tc_temp & 4)
|
2321
|
2326
|
SERIAL_ECHOLNPGM("Short to VCC");
|
2322
|
|
- #elif HAS_MAX31865
|
|
2327
|
+ #elif HAS_MAX31865_TEMP
|
2323
|
2328
|
if (fault_31865) {
|
2324
|
2329
|
maxref.clearFault();
|
2325
|
2330
|
SERIAL_ECHOPAIR("MAX31865 Fault :(", fault_31865, ") >>");
|
|
@@ -2341,43 +2346,43 @@ void Temperature::disable_all_heaters() {
|
2341
|
2346
|
#endif
|
2342
|
2347
|
|
2343
|
2348
|
// Thermocouple open
|
2344
|
|
- max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX);
|
|
2349
|
+ max_tc_temp = 4 * THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX);
|
2345
|
2350
|
}
|
2346
|
2351
|
else
|
2347
|
|
- max6675_temp >>= MAX6675_DISCARD_BITS;
|
|
2352
|
+ max_tc_temp >>= MAX_TC_DISCARD_BITS;
|
2348
|
2353
|
}
|
2349
|
2354
|
else {
|
2350
|
|
- max6675_temp >>= MAX6675_DISCARD_BITS;
|
2351
|
|
- max6675_errors[hindex] = 0;
|
|
2355
|
+ max_tc_temp >>= MAX_TC_DISCARD_BITS;
|
|
2356
|
+ max_tc_errors[hindex] = 0;
|
2352
|
2357
|
}
|
2353
|
2358
|
|
2354
|
|
- #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855
|
2355
|
|
- if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature
|
|
2359
|
+ #if HAS_MAX31855
|
|
2360
|
+ if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; // Support negative temperature
|
2356
|
2361
|
#endif
|
2357
|
2362
|
|
2358
|
2363
|
// Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES
|
2359
|
|
- TERN_(HAS_MAX31865, max6675_temp = max31865_ohms);
|
|
2364
|
+ TERN_(HAS_MAX31865_TEMP, max_tc_temp = max31865_ohms);
|
2360
|
2365
|
|
2361
|
|
- MAX6675_TEMP(hindex) = max6675_temp;
|
|
2366
|
+ THERMO_TEMP(hindex) = max_tc_temp;
|
2362
|
2367
|
|
2363
|
|
- return int(max6675_temp);
|
|
2368
|
+ return int(max_tc_temp);
|
2364
|
2369
|
}
|
2365
|
2370
|
|
2366
|
|
-#endif // HAS_MAX6675
|
|
2371
|
+#endif // HAS_MAX_TC
|
2367
|
2372
|
|
2368
|
2373
|
/**
|
2369
|
2374
|
* Update raw temperatures
|
2370
|
2375
|
*/
|
2371
|
2376
|
void Temperature::update_raw_temperatures() {
|
2372
|
2377
|
|
2373
|
|
- #if HAS_TEMP_ADC_0 && !HEATER_0_USES_MAX6675
|
|
2378
|
+ #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC
|
2374
|
2379
|
temp_hotend[0].update();
|
2375
|
2380
|
#endif
|
2376
|
2381
|
|
2377
|
2382
|
#if HAS_TEMP_ADC_1
|
2378
|
2383
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
2379
|
2384
|
redundant_temperature_raw = temp_hotend[1].acc;
|
2380
|
|
- #elif !HEATER_1_USES_MAX6675
|
|
2385
|
+ #elif !TEMP_SENSOR_1_IS_MAX_TC
|
2381
|
2386
|
temp_hotend[1].update();
|
2382
|
2387
|
#endif
|
2383
|
2388
|
#endif
|
|
@@ -2423,9 +2428,9 @@ void Temperature::readings_ready() {
|
2423
|
2428
|
#if HAS_HOTEND
|
2424
|
2429
|
|
2425
|
2430
|
static constexpr int8_t temp_dir[] = {
|
2426
|
|
- TERN(HEATER_0_USES_MAX6675, 0, TEMPDIR(0))
|
|
2431
|
+ TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0))
|
2427
|
2432
|
#if HAS_MULTI_HOTEND
|
2428
|
|
- , TERN(HEATER_1_USES_MAX6675, 0, TEMPDIR(1))
|
|
2433
|
+ , TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1))
|
2429
|
2434
|
#if HOTENDS > 2
|
2430
|
2435
|
#define _TEMPDIR(N) , TEMPDIR(N)
|
2431
|
2436
|
REPEAT_S(2, HOTENDS, _TEMPDIR)
|