Browse Source

🚸 Up to 3 MAX Thermocouples (#24898)

kurtis-potier-geofabrica 2 years ago
parent
commit
1b31a7cf2c
No account linked to committer's email address

+ 4
- 0
Marlin/Configuration.h View File

@@ -564,6 +564,10 @@
564 564
   #define MAX31865_SENSOR_OHMS_1      100
565 565
   #define MAX31865_CALIBRATION_OHMS_1 430
566 566
 #endif
567
+#if TEMP_SENSOR_IS_MAX_TC(2)
568
+  #define MAX31865_SENSOR_OHMS_2      100
569
+  #define MAX31865_CALIBRATION_OHMS_2 430
570
+#endif
567 571
 
568 572
 #if HAS_E_TEMP_SENSOR
569 573
   #define TEMP_RESIDENCY_TIME         10  // (seconds) Time to wait for hotend to "settle" in M109

+ 2
- 0
Marlin/Configuration_adv.h View File

@@ -175,6 +175,7 @@
175 175
 //#define TEMP_SENSOR_FORCE_HW_SPI                // Ignore SCK/MOSI/MISO pins; use CS and the default SPI bus.
176 176
 //#define MAX31865_SENSOR_WIRES_0 2               // (2-4) Number of wires for the probe connected to a MAX31865 board.
177 177
 //#define MAX31865_SENSOR_WIRES_1 2
178
+//#define MAX31865_SENSOR_WIRES_2 2
178 179
 
179 180
 //#define MAX31865_50HZ_FILTER                    // Use a 50Hz filter instead of the default 60Hz.
180 181
 //#define MAX31865_USE_READ_ERROR_DETECTION       // Treat value spikes (20°C delta in under 1s) as read errors.
@@ -185,6 +186,7 @@
185 186
 
186 187
 //#define MAX31865_WIRE_OHMS_0              0.95f // For 2-wire, set the wire resistances for more accurate readings.
187 188
 //#define MAX31865_WIRE_OHMS_1              0.0f
189
+//#define MAX31865_WIRE_OHMS_2              0.0f
188 190
 
189 191
 /**
190 192
  * Hephestos 2 24V heated bed upgrade kit.

+ 66
- 34
Marlin/src/inc/Conditionals_adv.h View File

@@ -262,26 +262,72 @@
262 262
   #undef HEATER_1_MAXTEMP
263 263
 #endif
264 264
 
265
+#if TEMP_SENSOR_IS_MAX_TC(2)
266
+  #if TEMP_SENSOR_2 == -5
267
+    #define TEMP_SENSOR_2_IS_MAX31865 1
268
+    #define TEMP_SENSOR_2_MAX_TC_TMIN    0
269
+    #define TEMP_SENSOR_2_MAX_TC_TMAX 1024
270
+    #ifndef MAX31865_SENSOR_WIRES_2
271
+      #define MAX31865_SENSOR_WIRES_2 2
272
+    #endif
273
+    #ifndef MAX31865_WIRE_OHMS_2
274
+      #define MAX31865_WIRE_OHMS_2 0.0f
275
+    #endif
276
+  #elif TEMP_SENSOR_2 == -3
277
+    #define TEMP_SENSOR_2_IS_MAX31855 1
278
+    #define TEMP_SENSOR_2_MAX_TC_TMIN -270
279
+    #define TEMP_SENSOR_2_MAX_TC_TMAX 1800
280
+  #elif TEMP_SENSOR_2 == -2
281
+    #define TEMP_SENSOR_2_IS_MAX6675 1
282
+    #define TEMP_SENSOR_2_MAX_TC_TMIN    0
283
+    #define TEMP_SENSOR_2_MAX_TC_TMAX 1024
284
+  #endif
285
+
286
+  #if TEMP_SENSOR_2 != TEMP_SENSOR_0
287
+    #if   TEMP_SENSOR_2 == -5
288
+      #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match."
289
+    #elif TEMP_SENSOR_2 == -3
290
+      #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match."
291
+    #elif TEMP_SENSOR_2 == -2
292
+      #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match."
293
+    #endif
294
+  #endif
295
+#elif TEMP_SENSOR_2 == -4
296
+  #define TEMP_SENSOR_2_IS_AD8495 1
297
+#elif TEMP_SENSOR_2 == -1
298
+  #define TEMP_SENSOR_2_IS_AD595 1
299
+#elif TEMP_SENSOR_2 > 0
300
+  #define TEMP_SENSOR_2_IS_THERMISTOR 1
301
+  #if TEMP_SENSOR_2 == 1000
302
+    #define TEMP_SENSOR_2_IS_CUSTOM 1
303
+  #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
304
+    #define TEMP_SENSOR_2_IS_DUMMY 1
305
+  #endif
306
+#else
307
+  #undef HEATER_2_MINTEMP
308
+  #undef HEATER_2_MAXTEMP
309
+#endif
310
+
265 311
 #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
266 312
   #if TEMP_SENSOR_REDUNDANT == -5
267
-    #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1)
268
-      #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
313
+    #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)
314
+      #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)."
269 315
     #endif
270 316
 
271 317
     #define TEMP_SENSOR_REDUNDANT_IS_MAX31865    1
272 318
     #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN    0
273 319
     #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024
274 320
   #elif TEMP_SENSOR_REDUNDANT == -3
275
-    #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1)
276
-      #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
321
+    #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)
322
+      #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)."
277 323
     #endif
278 324
 
279 325
     #define TEMP_SENSOR_REDUNDANT_IS_MAX31855    1
280 326
     #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270
281 327
     #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800
282 328
   #elif TEMP_SENSOR_REDUNDANT == -2
283
-    #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1)
284
-      #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
329
+    #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)
330
+      #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)."
285 331
     #endif
286 332
 
287 333
     #define TEMP_SENSOR_REDUNDANT_IS_MAX6675     1
@@ -302,15 +348,21 @@
302 348
     #ifndef MAX31865_SENSOR_WIRES_1
303 349
       #define MAX31865_SENSOR_WIRES_1 2
304 350
     #endif
351
+  #elif REDUNDANT_TEMP_MATCH(SOURCE, E2)
352
+    #define TEMP_SENSOR_2_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN
353
+    #define TEMP_SENSOR_2_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX
354
+    #ifndef MAX31865_SENSOR_WIRES_2
355
+      #define MAX31865_SENSOR_WIRES_2 2
356
+    #endif
305 357
   #endif
306 358
 
307
-  #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1)
359
+  #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) || (TEMP_SENSOR_IS_MAX_TC(2) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_2)
308 360
     #if   TEMP_SENSOR_REDUNDANT == -5
309
-      #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
361
+      #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match."
310 362
     #elif TEMP_SENSOR_REDUNDANT == -3
311
-      #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
363
+      #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match."
312 364
     #elif TEMP_SENSOR_REDUNDANT == -2
313
-      #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
365
+      #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match."
314 366
     #endif
315 367
   #endif
316 368
 #elif TEMP_SENSOR_REDUNDANT == -4
@@ -326,39 +378,19 @@
326 378
   #endif
327 379
 #endif
328 380
 
329
-#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
381
+#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(2) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
330 382
   #define HAS_MAX_TC 1
331 383
 #endif
332
-#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675
384
+#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_2_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675
333 385
   #define HAS_MAX6675 1
334 386
 #endif
335
-#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855
387
+#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_2_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855
336 388
   #define HAS_MAX31855 1
337 389
 #endif
338
-#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865
390
+#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_2_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865
339 391
   #define HAS_MAX31865 1
340 392
 #endif
341 393
 
342
-#if TEMP_SENSOR_2 == -4
343
-  #define TEMP_SENSOR_2_IS_AD8495 1
344
-#elif TEMP_SENSOR_2 == -3
345
-  #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
346
-#elif TEMP_SENSOR_2 == -2
347
-  #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
348
-#elif TEMP_SENSOR_2 == -1
349
-  #define TEMP_SENSOR_2_IS_AD595 1
350
-#elif TEMP_SENSOR_2 > 0
351
-  #define TEMP_SENSOR_2_IS_THERMISTOR 1
352
-  #if TEMP_SENSOR_2 == 1000
353
-    #define TEMP_SENSOR_2_IS_CUSTOM 1
354
-  #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
355
-    #define TEMP_SENSOR_2_IS_DUMMY 1
356
-  #endif
357
-#else
358
-  #undef HEATER_2_MINTEMP
359
-  #undef HEATER_2_MAXTEMP
360
-#endif
361
-
362 394
 #if TEMP_SENSOR_3 == -4
363 395
   #define TEMP_SENSOR_3_IS_AD8495 1
364 396
 #elif TEMP_SENSOR_3 == -3

+ 77
- 8
Marlin/src/inc/Conditionals_post.h View File

@@ -723,19 +723,19 @@
723 723
         #define TEMP_0_SCK_PIN MAX31855_SCK_PIN
724 724
       #endif
725 725
 
726
-    #elif TEMP_SENSOR_1_IS_MAX31865
727
-      #if !PIN_EXISTS(TEMP_1_MISO) // DO
726
+    #elif TEMP_SENSOR_0_IS_MAX31865
727
+      #if !PIN_EXISTS(TEMP_0_MISO) // DO
728 728
         #if PIN_EXISTS(MAX31865_MISO)
729
-          #define TEMP_1_MISO_PIN MAX31865_MISO_PIN
729
+          #define TEMP_0_MISO_PIN MAX31865_MISO_PIN
730 730
         #elif PIN_EXISTS(MAX31865_DO)
731
-          #define TEMP_1_MISO_PIN MAX31865_DO_PIN
731
+          #define TEMP_0_MISO_PIN MAX31865_DO_PIN
732 732
         #endif
733 733
       #endif
734
-      #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31865_SCK)
735
-        #define TEMP_1_SCK_PIN MAX31865_SCK_PIN
734
+      #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX31865_SCK)
735
+        #define TEMP_0_SCK_PIN MAX31865_SCK_PIN
736 736
       #endif
737
-      #if !PIN_EXISTS(TEMP_1_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only
738
-        #define TEMP_1_MOSI_PIN MAX31865_MOSI_PIN
737
+      #if !PIN_EXISTS(TEMP_0_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only
738
+        #define TEMP_0_MOSI_PIN MAX31865_MOSI_PIN
739 739
       #endif
740 740
     #endif
741 741
 
@@ -819,6 +819,75 @@
819 819
 
820 820
   #endif // TEMP_SENSOR_IS_MAX_TC(1)
821 821
 
822
+  #if TEMP_SENSOR_IS_MAX_TC(2) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2))
823
+
824
+    #if !PIN_EXISTS(TEMP_2_CS) // SS3, CS3
825
+      #if PIN_EXISTS(MAX6675_SS3)
826
+        #define TEMP_2_CS_PIN MAX6675_SS3_PIN
827
+      #elif PIN_EXISTS(MAX6675_CS)
828
+        #define TEMP_2_CS_PIN MAX6675_CS3_PIN
829
+      #elif PIN_EXISTS(MAX31855_SS3)
830
+        #define TEMP_2_CS_PIN MAX31855_SS3_PIN
831
+      #elif PIN_EXISTS(MAX31855_CS3)
832
+        #define TEMP_2_CS_PIN MAX31855_CS3_PIN
833
+      #elif PIN_EXISTS(MAX31865_SS3)
834
+        #define TEMP_2_CS_PIN MAX31865_SS3_PIN
835
+      #elif PIN_EXISTS(MAX31865_CS3)
836
+        #define TEMP_2_CS_PIN MAX31865_CS3_PIN
837
+      #endif
838
+    #endif
839
+
840
+    #if TEMP_SENSOR_2_IS_MAX6675
841
+      #if !PIN_EXISTS(TEMP_2_MISO) // DO
842
+        #if PIN_EXISTS(MAX6675_MISO)
843
+          #define TEMP_2_MISO_PIN MAX6675_MISO_PIN
844
+        #elif PIN_EXISTS(MAX6675_DO)
845
+          #define TEMP_2_MISO_PIN MAX6675_DO_PIN
846
+        #endif
847
+      #endif
848
+      #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX6675_SCK)
849
+        #define TEMP_2_SCK_PIN MAX6675_SCK_PIN
850
+      #endif
851
+
852
+    #elif TEMP_SENSOR_2_IS_MAX31855
853
+      #if !PIN_EXISTS(TEMP_2_MISO) // DO
854
+        #if PIN_EXISTS(MAX31855_MISO)
855
+          #define TEMP_2_MISO_PIN MAX31855_MISO_PIN
856
+        #elif PIN_EXISTS(MAX31855_DO)
857
+          #define TEMP_2_MISO_PIN MAX31855_DO_PIN
858
+        #endif
859
+      #endif
860
+      #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX31855_SCK)
861
+        #define TEMP_2_SCK_PIN MAX31855_SCK_PIN
862
+      #endif
863
+
864
+    #elif TEMP_SENSOR_2_IS_MAX31865
865
+      #if !PIN_EXISTS(TEMP_2_MISO) // DO
866
+        #if PIN_EXISTS(MAX31865_MISO)
867
+          #define TEMP_2_MISO_PIN MAX31865_MISO_PIN
868
+        #elif PIN_EXISTS(MAX31865_DO)
869
+          #define TEMP_2_MISO_PIN MAX31865_DO_PIN
870
+        #endif
871
+      #endif
872
+      #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX31865_SCK)
873
+        #define TEMP_2_SCK_PIN MAX31865_SCK_PIN
874
+      #endif
875
+      #if !PIN_EXISTS(TEMP_2_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only
876
+        #define TEMP_2_MOSI_PIN MAX31865_MOSI_PIN
877
+      #endif
878
+    #endif
879
+
880
+    // Software SPI - enable if MISO/SCK are defined.
881
+    #if PIN_EXISTS(TEMP_2_MISO) && PIN_EXISTS(TEMP_2_SCK) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI)
882
+      #if TEMP_SENSOR_2_IS_MAX31865 && !PIN_EXISTS(TEMP_2_MOSI)
883
+        #error "TEMP_SENSOR_2 MAX31865 requires TEMP_2_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_2_FORCE_HW_SPI."
884
+      #else
885
+        #define TEMP_SENSOR_2_HAS_SPI_PINS 1
886
+      #endif
887
+    #endif
888
+
889
+  #endif // TEMP_SENSOR_IS_MAX_TC(2)
890
+
822 891
   //
823 892
   // User-defined thermocouple libraries
824 893
   //

+ 15
- 8
Marlin/src/inc/SanityCheck.h View File

@@ -416,17 +416,17 @@
416 416
 #elif defined(CHDK)
417 417
   #error "CHDK is now CHDK_PIN."
418 418
 #elif ANY_PIN( \
419
-        MAX6675_SS, MAX6675_SS2, MAX6675_CS, MAX6675_CS2, \
420
-        MAX31855_SS, MAX31855_SS2, MAX31855_CS, MAX31855_CS2, \
421
-        MAX31865_SS, MAX31865_SS2, MAX31865_CS, MAX31865_CS2)
422
-  #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_CS_PIN, and MAX*_CS2_PIN are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN instead."
419
+        MAX6675_SS, MAX6675_SS2,  MAX6675_SS3, MAX6675_CS, MAX6675_CS2, MAX6675_CS3,\
420
+        MAX31855_SS, MAX31855_SS2, MAX31855_SS3, MAX31855_CS, MAX31855_CS2, MAX31855_CS3, \
421
+        MAX31865_SS, MAX31865_SS2, MAX31865_SS3, MAX31865_CS, MAX31865_CS2, MAX31865_CS3)
422
+  #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_SS3_PIN, MAX*_CS_PIN, MAX*_CS2_PIN, and MAX*_CS3_PIN, are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN/TEMP_2_CS_PIN instead."
423 423
 #elif ANY_PIN(MAX6675_SCK, MAX31855_SCK, MAX31865_SCK)
424
-  #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN instead."
424
+  #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN/TEMP_2_SCK_PIN instead."
425 425
 #elif ANY_PIN(MAX6675_MISO, MAX6675_DO, MAX31855_MISO, MAX31855_DO, MAX31865_MISO, MAX31865_DO)
426
-  #warning "MAX*_MISO_PIN and MAX*_DO_PIN are deprecated and will be removed in a future version. Please use TEMP_0_MISO_PIN/TEMP_1_MISO_PIN instead."
426
+  #warning "MAX*_MISO_PIN and MAX*_DO_PIN are deprecated and will be removed in a future version. Please use TEMP_0_MISO_PIN/TEMP_1_MISO_PIN/TEMP_2_MISO_PIN instead."
427 427
 #elif PIN_EXISTS(MAX31865_MOSI)
428
-  #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN instead."
429
-#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_DO_PIN, THERMO_SCK_PIN)
428
+  #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN/TEMP_2_MOSI_PIN instead."
429
+#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_CS3_PIN, THERMO_DO_PIN, THERMO_SCK_PIN)
430 430
   #error "THERMO_*_PIN is now TEMP_n_CS_PIN, TEMP_n_SCK_PIN, TEMP_n_MOSI_PIN, TEMP_n_MISO_PIN."
431 431
 #elif defined(MAX31865_SENSOR_OHMS)
432 432
   #error "MAX31865_SENSOR_OHMS is now MAX31865_SENSOR_OHMS_0."
@@ -2340,6 +2340,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
2340 2340
     #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1/TEMP_SENSOR_REDUNDANT is MAX31865."
2341 2341
   #endif
2342 2342
 #endif
2343
+#if TEMP_SENSOR_2_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && REDUNDANT_TEMP_MATCH(SOURCE, E2))
2344
+  #if !defined(MAX31865_SENSOR_WIRES_2) || !WITHIN(MAX31865_SENSOR_WIRES_2, 2, 4)
2345
+    #error "MAX31865_SENSOR_WIRES_2 must be defined as an integer between 2 and 4."
2346
+  #elif !defined(MAX31865_SENSOR_OHMS_2) || !defined(MAX31865_CALIBRATION_OHMS_2)
2347
+    #error "MAX31865_SENSOR_OHMS_2 and MAX31865_CALIBRATION_OHMS_2 must be set if TEMP_SENSOR_2/TEMP_SENSOR_REDUNDANT is MAX31865."
2348
+  #endif
2349
+#endif
2343 2350
 
2344 2351
 /**
2345 2352
  * Redundant temperature sensor config

+ 97
- 24
Marlin/src/module/temperature.cpp View File

@@ -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

Loading…
Cancel
Save