|
@@ -113,13 +113,16 @@
|
113
|
113
|
// 3. CS, MISO, and SCK pins w/ FORCE_HW_SPI: Hardware SPI on the default bus, ignoring MISO, SCK.
|
114
|
114
|
//
|
115
|
115
|
#if TEMP_SENSOR_IS_ANY_MAX_TC(0) && TEMP_SENSOR_0_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI)
|
116
|
|
- #define TEMP_SENSOR_0_USES_SW_SPI 1
|
|
116
|
+ #define TEMP_SENSOR_0_USES_SW_SPI 1
|
117
|
117
|
#endif
|
118
|
118
|
#if TEMP_SENSOR_IS_ANY_MAX_TC(1) && TEMP_SENSOR_1_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI)
|
119
|
|
- #define TEMP_SENSOR_1_USES_SW_SPI 1
|
|
119
|
+ #define TEMP_SENSOR_1_USES_SW_SPI 1
|
|
120
|
+#endif
|
|
121
|
+#if TEMP_SENSOR_IS_ANY_MAX_TC(2) && TEMP_SENSOR_2_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI)
|
|
122
|
+ #define TEMP_SENSOR_2_USES_SW_SPI 1
|
120
|
123
|
#endif
|
121
|
124
|
|
122
|
|
-#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES
|
|
125
|
+#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI || TEMP_SENSOR_2_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES
|
123
|
126
|
#include "../libs/private_spi.h"
|
124
|
127
|
#define HAS_MAXTC_SW_SPI 1
|
125
|
128
|
|
|
@@ -130,12 +133,18 @@
|
130
|
133
|
#if PIN_EXISTS(TEMP_0_MOSI)
|
131
|
134
|
#define SW_SPI_MOSI_PIN TEMP_0_MOSI_PIN
|
132
|
135
|
#endif
|
133
|
|
- #else
|
|
136
|
+ #elif TEMP_SENSOR_1_USES_SW_SPI
|
134
|
137
|
#define SW_SPI_SCK_PIN TEMP_1_SCK_PIN
|
135
|
138
|
#define SW_SPI_MISO_PIN TEMP_1_MISO_PIN
|
136
|
139
|
#if PIN_EXISTS(TEMP_1_MOSI)
|
137
|
140
|
#define SW_SPI_MOSI_PIN TEMP_1_MOSI_PIN
|
138
|
141
|
#endif
|
|
142
|
+ #elif TEMP_SENSOR_2_USES_SW_SPI
|
|
143
|
+ #define SW_SPI_SCK_PIN TEMP_2_SCK_PIN
|
|
144
|
+ #define SW_SPI_MISO_PIN TEMP_2_MISO_PIN
|
|
145
|
+ #if PIN_EXISTS(TEMP_2_MOSI)
|
|
146
|
+ #define SW_SPI_MOSI_PIN TEMP_2_MOSI_PIN
|
|
147
|
+ #endif
|
139
|
148
|
#endif
|
140
|
149
|
#ifndef SW_SPI_MOSI_PIN
|
141
|
150
|
#define SW_SPI_MOSI_PIN SD_MOSI_PIN
|
|
@@ -256,6 +265,9 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
256
|
265
|
#if TEMP_SENSOR_IS_MAX(1, 6675)
|
257
|
266
|
MAXTC_INIT(1, 6675);
|
258
|
267
|
#endif
|
|
268
|
+ #if TEMP_SENSOR_IS_MAX(2, 6675)
|
|
269
|
+ MAXTC_INIT(2, 6675);
|
|
270
|
+ #endif
|
259
|
271
|
#endif
|
260
|
272
|
|
261
|
273
|
#if HAS_MAX31855_LIBRARY
|
|
@@ -265,12 +277,16 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
265
|
277
|
#if TEMP_SENSOR_IS_MAX(1, 31855)
|
266
|
278
|
MAXTC_INIT(1, 31855);
|
267
|
279
|
#endif
|
|
280
|
+ #if TEMP_SENSOR_IS_MAX(2, 31855)
|
|
281
|
+ MAXTC_INIT(2, 31855);
|
|
282
|
+ #endif
|
268
|
283
|
#endif
|
269
|
284
|
|
270
|
285
|
// MAX31865 always uses a library, unlike '55 & 6675
|
271
|
286
|
#if HAS_MAX31865
|
272
|
287
|
#define _MAX31865_0_SW TEMP_SENSOR_0_USES_SW_SPI
|
273
|
288
|
#define _MAX31865_1_SW TEMP_SENSOR_1_USES_SW_SPI
|
|
289
|
+ #define _MAX31865_2_SW TEMP_SENSOR_2_USES_SW_SPI
|
274
|
290
|
|
275
|
291
|
#if TEMP_SENSOR_IS_MAX(0, 31865)
|
276
|
292
|
MAXTC_INIT(0, 31865);
|
|
@@ -278,9 +294,13 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
278
|
294
|
#if TEMP_SENSOR_IS_MAX(1, 31865)
|
279
|
295
|
MAXTC_INIT(1, 31865);
|
280
|
296
|
#endif
|
|
297
|
+ #if TEMP_SENSOR_IS_MAX(2, 31865)
|
|
298
|
+ MAXTC_INIT(2, 31865);
|
|
299
|
+ #endif
|
281
|
300
|
|
282
|
301
|
#undef _MAX31865_0_SW
|
283
|
302
|
#undef _MAX31865_1_SW
|
|
303
|
+ #undef _MAX31865_2_SW
|
284
|
304
|
#endif
|
285
|
305
|
|
286
|
306
|
#undef MAXTC_INIT
|
|
@@ -541,6 +561,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
541
|
561
|
#endif
|
542
|
562
|
|
543
|
563
|
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
|
564
|
+ #define MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR 1
|
544
|
565
|
uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
|
545
|
566
|
#endif
|
546
|
567
|
|
|
@@ -1866,6 +1887,10 @@ void Temperature::task() {
|
1866
|
1887
|
if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1);
|
1867
|
1888
|
if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1);
|
1868
|
1889
|
#endif
|
|
1890
|
+ #if TEMP_SENSOR_IS_MAX_TC(2)
|
|
1891
|
+ if (degHotend(2) > _MIN(HEATER_2_MAXTEMP, TEMP_SENSOR_2_MAX_TC_TMAX - 1.0)) max_temp_error(H_E2);
|
|
1892
|
+ if (degHotend(2) < _MAX(HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + .01)) min_temp_error(H_E2);
|
|
1893
|
+ #endif
|
1869
|
1894
|
#if TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
|
1870
|
1895
|
if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT);
|
1871
|
1896
|
if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT);
|
|
@@ -2112,6 +2137,15 @@ void Temperature::task() {
|
2112
|
2137
|
case 2:
|
2113
|
2138
|
#if TEMP_SENSOR_2_IS_CUSTOM
|
2114
|
2139
|
return user_thermistor_to_deg_c(CTI_HOTEND_2, raw);
|
|
2140
|
+ #elif TEMP_SENSOR_IS_MAX_TC(2)
|
|
2141
|
+ #if TEMP_SENSOR_0_IS_MAX31865
|
|
2142
|
+ return TERN(LIB_INTERNAL_MAX31865,
|
|
2143
|
+ max31865_2.temperature(raw),
|
|
2144
|
+ max31865_2.temperature(MAX31865_SENSOR_OHMS_2, MAX31865_CALIBRATION_OHMS_2)
|
|
2145
|
+ );
|
|
2146
|
+ #else
|
|
2147
|
+ return (int16_t)raw * 0.25;
|
|
2148
|
+ #endif
|
2115
|
2149
|
#elif TEMP_SENSOR_2_IS_AD595
|
2116
|
2150
|
return TEMP_AD595(raw);
|
2117
|
2151
|
#elif TEMP_SENSOR_2_IS_AD8495
|
|
@@ -2281,6 +2315,8 @@ void Temperature::task() {
|
2281
|
2315
|
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25);
|
2282
|
2316
|
#elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)
|
2283
|
2317
|
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25);
|
|
2318
|
+ #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2)
|
|
2319
|
+ return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_2.temperature(raw), (int16_t)raw * 0.25);
|
2284
|
2320
|
#elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR
|
2285
|
2321
|
SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN);
|
2286
|
2322
|
#elif TEMP_SENSOR_REDUNDANT_IS_AD595
|
|
@@ -2316,6 +2352,9 @@ void Temperature::updateTemperaturesFromRawValues() {
|
2316
|
2352
|
#if TEMP_SENSOR_IS_MAX_TC(1)
|
2317
|
2353
|
temp_hotend[1].setraw(READ_MAX_TC(1));
|
2318
|
2354
|
#endif
|
|
2355
|
+ #if TEMP_SENSOR_IS_MAX_TC(2)
|
|
2356
|
+ temp_hotend[2].setraw(READ_MAX_TC(2));
|
|
2357
|
+ #endif
|
2319
|
2358
|
#if TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
|
2320
|
2359
|
temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)));
|
2321
|
2360
|
#endif
|
|
@@ -2347,9 +2386,14 @@ void Temperature::updateTemperaturesFromRawValues() {
|
2347
|
2386
|
#else
|
2348
|
2387
|
, TEMPDIR(1)
|
2349
|
2388
|
#endif
|
2350
|
|
- #if HOTENDS > 2
|
|
2389
|
+ #if TEMP_SENSOR_IS_ANY_MAX_TC(2)
|
|
2390
|
+ , 0
|
|
2391
|
+ #else
|
|
2392
|
+ , TEMPDIR(2)
|
|
2393
|
+ #endif
|
|
2394
|
+ #if HOTENDS > 3
|
2351
|
2395
|
#define _TEMPDIR(N) , TEMPDIR(N)
|
2352
|
|
- REPEAT_S(2, HOTENDS, _TEMPDIR)
|
|
2396
|
+ REPEAT_S(3, HOTENDS, _TEMPDIR)
|
2353
|
2397
|
#endif
|
2354
|
2398
|
#endif
|
2355
|
2399
|
};
|
|
@@ -2362,15 +2406,12 @@ void Temperature::updateTemperaturesFromRawValues() {
|
2362
|
2406
|
|
2363
|
2407
|
const bool heater_on = temp_hotend[e].target > 0;
|
2364
|
2408
|
if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) {
|
2365
|
|
- #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
2366
|
|
- if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
|
2367
|
|
- #endif
|
2368
|
|
- min_temp_error((heater_id_t)e);
|
|
2409
|
+ if (TERN1(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, ++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED))
|
|
2410
|
+ min_temp_error((heater_id_t)e);
|
|
2411
|
+ }
|
|
2412
|
+ else {
|
|
2413
|
+ TERN_(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, consecutive_low_temperature_error[e] = 0);
|
2369
|
2414
|
}
|
2370
|
|
- #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
|
2371
|
|
- else
|
2372
|
|
- consecutive_low_temperature_error[e] = 0;
|
2373
|
|
- #endif
|
2374
|
2415
|
}
|
2375
|
2416
|
|
2376
|
2417
|
#endif // HAS_HOTEND
|
|
@@ -2432,6 +2473,9 @@ void Temperature::init() {
|
2432
|
2473
|
#if TEMP_SENSOR_IS_ANY_MAX_TC(1) && PIN_EXISTS(TEMP_1_CS)
|
2433
|
2474
|
OUT_WRITE(TEMP_1_CS_PIN, HIGH);
|
2434
|
2475
|
#endif
|
|
2476
|
+ #if TEMP_SENSOR_IS_ANY_MAX_TC(2) && PIN_EXISTS(TEMP_2_CS)
|
|
2477
|
+ OUT_WRITE(TEMP_2_CS_PIN, HIGH);
|
|
2478
|
+ #endif
|
2435
|
2479
|
|
2436
|
2480
|
// Setup objects for library-based polling of MAX TCs
|
2437
|
2481
|
#if HAS_MAXTC_LIBRARIES
|
|
@@ -2459,6 +2503,18 @@ void Temperature::init() {
|
2459
|
2503
|
OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1, MAX31865_WIRE_OHMS_1)
|
2460
|
2504
|
);
|
2461
|
2505
|
#endif
|
|
2506
|
+
|
|
2507
|
+ #if TEMP_SENSOR_IS_MAX(2, 6675) && HAS_MAX6675_LIBRARY
|
|
2508
|
+ max6675_2.begin();
|
|
2509
|
+ #elif TEMP_SENSOR_IS_MAX(2, 31855) && HAS_MAX31855_LIBRARY
|
|
2510
|
+ max31855_2.begin();
|
|
2511
|
+ #elif TEMP_SENSOR_IS_MAX(2, 31865)
|
|
2512
|
+ max31865_2.begin(
|
|
2513
|
+ MAX31865_WIRES(MAX31865_SENSOR_WIRES_2) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
|
|
2514
|
+ OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_2, MAX31865_CALIBRATION_OHMS_2, MAX31865_WIRE_OHMS_2)
|
|
2515
|
+ );
|
|
2516
|
+ #endif
|
|
2517
|
+
|
2462
|
2518
|
#undef MAX31865_WIRES
|
2463
|
2519
|
#undef _MAX31865_WIRES
|
2464
|
2520
|
#endif
|
|
@@ -2491,6 +2547,15 @@ void Temperature::init() {
|
2491
|
2547
|
#endif
|
2492
|
2548
|
));
|
2493
|
2549
|
#endif
|
|
2550
|
+ #if PIN_EXISTS(TEMP_2_TR_ENABLE)
|
|
2551
|
+ OUT_WRITE(TEMP_2_TR_ENABLE_PIN, (
|
|
2552
|
+ #if TEMP_SENSOR_IS_ANY_MAX_TC(2)
|
|
2553
|
+ HIGH
|
|
2554
|
+ #else
|
|
2555
|
+ LOW
|
|
2556
|
+ #endif
|
|
2557
|
+ ));
|
|
2558
|
+ #endif
|
2494
|
2559
|
|
2495
|
2560
|
#if ENABLED(MPCTEMP)
|
2496
|
2561
|
HOTEND_LOOP() temp_hotend[e].modeled_block_temp = NAN;
|
|
@@ -3009,25 +3074,29 @@ void Temperature::disable_all_heaters() {
|
3009
|
3074
|
// Needed to return the correct temp when this is called between readings
|
3010
|
3075
|
static raw_adc_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
|
3011
|
3076
|
#define THERMO_TEMP(I) max_tc_temp_previous[I]
|
3012
|
|
- #define THERMO_SEL(A,B) (hindex ? (B) : (A))
|
3013
|
|
- #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0)
|
|
3077
|
+ #define THERMO_SEL(A,B,C) (hindex > 1 ? (C) : hindex == 1 ? (B) : (A))
|
|
3078
|
+ #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; case 2: WRITE(TEMP_2_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0)
|
3014
|
3079
|
#else
|
3015
|
3080
|
// When we have only 1 max tc, THERMO_SEL will pick the appropriate sensor
|
3016
|
3081
|
// variable, and MAXTC_*() macros will be hardcoded to the correct CS pin.
|
3017
|
3082
|
constexpr uint8_t hindex = 0;
|
3018
|
3083
|
#define THERMO_TEMP(I) max_tc_temp
|
3019
|
3084
|
#if TEMP_SENSOR_IS_ANY_MAX_TC(0)
|
3020
|
|
- #define THERMO_SEL(A,B) A
|
|
3085
|
+ #define THERMO_SEL(A,B,C) A
|
3021
|
3086
|
#define MAXTC_CS_WRITE(V) WRITE(TEMP_0_CS_PIN, V)
|
3022
|
|
- #else
|
3023
|
|
- #define THERMO_SEL(A,B) B
|
|
3087
|
+ #elif TEMP_SENSOR_IS_ANY_MAX_TC(1)
|
|
3088
|
+ #define THERMO_SEL(A,B,C) B
|
3024
|
3089
|
#define MAXTC_CS_WRITE(V) WRITE(TEMP_1_CS_PIN, V)
|
|
3090
|
+ #elif TEMP_SENSOR_IS_ANY_MAX_TC(2)
|
|
3091
|
+ #define THERMO_SEL(A,B,C) C
|
|
3092
|
+ #define MAXTC_CS_WRITE(V) WRITE(TEMP_2_CS_PIN, V)
|
3025
|
3093
|
#endif
|
3026
|
3094
|
#endif
|
3027
|
3095
|
|
3028
|
3096
|
static TERN(HAS_MAX31855, uint32_t, uint16_t) max_tc_temp = THERMO_SEL(
|
3029
|
3097
|
TEMP_SENSOR_0_MAX_TC_TMAX,
|
3030
|
|
- TEMP_SENSOR_1_MAX_TC_TMAX
|
|
3098
|
+ TEMP_SENSOR_1_MAX_TC_TMAX,
|
|
3099
|
+ TEMP_SENSOR_2_MAX_TC_TMAX
|
3031
|
3100
|
);
|
3032
|
3101
|
|
3033
|
3102
|
static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 };
|
|
@@ -3062,17 +3131,17 @@ void Temperature::disable_all_heaters() {
|
3062
|
3131
|
MAXTC_CS_WRITE(HIGH); // Disable MAXTC
|
3063
|
3132
|
#else
|
3064
|
3133
|
#if HAS_MAX6675_LIBRARY
|
3065
|
|
- MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1);
|
|
3134
|
+ MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1, max6675_2);
|
3066
|
3135
|
max_tc_temp = max6675ref.readRaw16();
|
3067
|
3136
|
#endif
|
3068
|
3137
|
|
3069
|
3138
|
#if HAS_MAX31855_LIBRARY
|
3070
|
|
- MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1);
|
|
3139
|
+ MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1, max31855_2);
|
3071
|
3140
|
max_tc_temp = max855ref.readRaw32();
|
3072
|
3141
|
#endif
|
3073
|
3142
|
|
3074
|
3143
|
#if HAS_MAX31865
|
3075
|
|
- MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1);
|
|
3144
|
+ MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1, max31865_2);
|
3076
|
3145
|
max_tc_temp = TERN(LIB_INTERNAL_MAX31865, max865ref.readRaw(), max865ref.readRTD_with_Fault());
|
3077
|
3146
|
#endif
|
3078
|
3147
|
#endif
|
|
@@ -3117,7 +3186,7 @@ void Temperature::disable_all_heaters() {
|
3117
|
3186
|
#endif
|
3118
|
3187
|
|
3119
|
3188
|
// Set thermocouple above max temperature (TMAX)
|
3120
|
|
- max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1);
|
|
3189
|
+ max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX, TEMP_SENSOR_2_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1);
|
3121
|
3190
|
}
|
3122
|
3191
|
}
|
3123
|
3192
|
else {
|
|
@@ -3155,6 +3224,10 @@ void Temperature::update_raw_temperatures() {
|
3155
|
3224
|
temp_hotend[1].update();
|
3156
|
3225
|
#endif
|
3157
|
3226
|
|
|
3227
|
+ #if HAS_TEMP_ADC_2 && !TEMP_SENSOR_IS_MAX_TC(2)
|
|
3228
|
+ temp_hotend[2].update();
|
|
3229
|
+ #endif
|
|
3230
|
+
|
3158
|
3231
|
#if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
|
3159
|
3232
|
temp_redundant.update();
|
3160
|
3233
|
#endif
|