Browse Source

More redundant temp sensor changes. (After testing and debugging by reifsnderb)

Erik van der Zalm 12 years ago
parent
commit
5090c56651
5 changed files with 196 additions and 175 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 3
    3
      Marlin/Configuration_adv.h
  3. 2
    2
      Marlin/Marlin_main.cpp
  4. 169
    158
      Marlin/pins.h
  5. 20
    10
      Marlin/temperature.cpp

+ 2
- 2
Marlin/Configuration.h View File

@@ -93,8 +93,8 @@
93 93
 #define TEMP_SENSOR_BED 0
94 94
 
95 95
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
96
-#define TEMP_SENSOR_1_AS_REDUNDANT 
97
-#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 5
96
+//#define TEMP_SENSOR_1_AS_REDUNDANT 
97
+#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
98 98
 
99 99
 // Actual temperature must be close to target for this long before M109 returns success
100 100
 #define TEMP_RESIDENCY_TIME 10  // (seconds)

+ 3
- 3
Marlin/Configuration_adv.h View File

@@ -318,6 +318,9 @@ const unsigned int dropsegments=5; //everything with less than this number of st
318 318
 //===========================================================================
319 319
 //=============================  Define Defines  ============================
320 320
 //===========================================================================
321
+#if EXTRUDERS > 1 && defined TEMP_SENSOR_1_AS_REDUNDANT
322
+  #error "You cannot use  TEMP_SENSOR_1_AS_REDUNDANT if EXTRUDERS > 1"
323
+#endif
321 324
 
322 325
 #if TEMP_SENSOR_0 > 0
323 326
   #define THERMISTORHEATER_0 TEMP_SENSOR_0
@@ -367,8 +370,5 @@ const unsigned int dropsegments=5; //everything with less than this number of st
367 370
   #undef BED_MAXTEMP
368 371
 #endif
369 372
 
370
-#if EXTRUDERS > 1 && defined TEMP_SENSOR_1_AS_REDUNDANT
371
-  #error "You cannot use  TEMP_SENSOR_1_AS_REDUNDANT if EXTRUDERS > 1"
372
-#endif
373 373
 
374 374
 #endif //__CONFIGURATION_ADV_H

+ 2
- 2
Marlin/Marlin_main.cpp View File

@@ -1055,7 +1055,7 @@ void process_commands()
1055 1055
     case 105 : // M105
1056 1056
       if(setTargetedHotend(105)){
1057 1057
         break;
1058
-      }
1058
+        }
1059 1059
       #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
1060 1060
         SERIAL_PROTOCOLPGM("ok T:");
1061 1061
         SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
@@ -2278,4 +2278,4 @@ bool setTargetedHotend(int code){
2278 2278
     }
2279 2279
   }
2280 2280
   return false;
2281
-}
2281
+}

+ 169
- 158
Marlin/pins.h View File

@@ -313,189 +313,200 @@
313 313
 
314 314
 #if MOTHERBOARD == 33 || MOTHERBOARD == 34
315 315
 
316
-#define LARGE_FLASH        true
316
+  #define LARGE_FLASH        true
317
+
318
+  #define X_STEP_PIN         54
319
+  #define X_DIR_PIN          55
320
+  #define X_ENABLE_PIN       38
321
+  #define X_MIN_PIN           3
322
+  #define X_MAX_PIN           2
323
+
324
+  #define Y_STEP_PIN         60
325
+  #define Y_DIR_PIN          61
326
+  #define Y_ENABLE_PIN       56
327
+  #define Y_MIN_PIN          14
328
+  #define Y_MAX_PIN          15
329
+
330
+  #define Z_STEP_PIN         46
331
+  #define Z_DIR_PIN          48
332
+  #define Z_ENABLE_PIN       62
333
+  #define Z_MIN_PIN          18
334
+  #define Z_MAX_PIN          19
335
+
336
+  #define Z2_STEP_PIN        36
337
+  #define Z2_DIR_PIN         34
338
+  #define Z2_ENABLE_PIN      30
339
+
340
+  #define E0_STEP_PIN        26
341
+  #define E0_DIR_PIN         28
342
+  #define E0_ENABLE_PIN      24
343
+
344
+  #define E1_STEP_PIN        36
345
+  #define E1_DIR_PIN         34
346
+  #define E1_ENABLE_PIN      30
347
+
348
+  #define SDPOWER            -1
349
+  #define SDSS               53
350
+  #define LED_PIN            13
351
+
352
+  #if MOTHERBOARD == 33
353
+    #define FAN_PIN            9 // (Sprinter config)
354
+  #else
355
+    #define FAN_PIN            4 // IO pin. Buffer needed
356
+  #endif
317 357
 
318
-#define X_STEP_PIN         54
319
-#define X_DIR_PIN          55
320
-#define X_ENABLE_PIN       38
321
-#define X_MIN_PIN           3
322
-#define X_MAX_PIN           2
358
+  #define PS_ON_PIN          12
323 359
 
324
-#define Y_STEP_PIN         60
325
-#define Y_DIR_PIN          61
326
-#define Y_ENABLE_PIN       56
327
-#define Y_MIN_PIN          14
328
-#define Y_MAX_PIN          15
360
+  #if defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
361
+    #define KILL_PIN           41
362
+  #else
363
+    #define KILL_PIN           -1
364
+  #endif
329 365
 
330
-#define Z_STEP_PIN         46
331
-#define Z_DIR_PIN          48
332
-#define Z_ENABLE_PIN       62
333
-#define Z_MIN_PIN          18
334
-#define Z_MAX_PIN          19
366
+  #define HEATER_0_PIN       10   // EXTRUDER 1
335 367
 
336
-#define Z2_STEP_PIN        36
337
-#define Z2_DIR_PIN         34
338
-#define Z2_ENABLE_PIN      30
368
+  #if MOTHERBOARD == 33
369
+    #define HEATER_1_PIN       -1
370
+  #else
371
+    #define HEATER_1_PIN       9    // EXTRUDER 2 (FAN On Sprinter)
372
+  #endif
339 373
 
340
-#define E0_STEP_PIN        26
341
-#define E0_DIR_PIN         28
342
-#define E0_ENABLE_PIN      24
374
+  #define HEATER_2_PIN       -1
375
+  #define TEMP_0_PIN         13   // ANALOG NUMBERING
376
+  #define TEMP_1_PIN         15   // ANALOG NUMBERING
377
+  #define TEMP_2_PIN         -1   // ANALOG NUMBERING
378
+  #define HEATER_BED_PIN     8    // BED
379
+  #define TEMP_BED_PIN       14   // ANALOG NUMBERING
343 380
 
344
-#define E1_STEP_PIN        36
345
-#define E1_DIR_PIN         34
346
-#define E1_ENABLE_PIN      30
347 381
 
348
-#define SDPOWER            -1
349
-#define SDSS               53
350
-#define LED_PIN            13
351 382
 
352
-#if MOTHERBOARD == 33
353
-#define FAN_PIN            9 // (Sprinter config)
354
-#else
355
-#define FAN_PIN            4 // IO pin. Buffer needed
356
-#endif
357
-#define PS_ON_PIN          12
383
+  #ifdef NUM_SERVOS
384
+    #define SERVO0_PIN         11
358 385
 
359
-#if defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
360
-#define KILL_PIN           41
361
-#else
362
-#define KILL_PIN           -1
363
-#endif
386
+    #if NUM_SERVOS > 1
387
+      #define SERVO1_PIN         6
388
+    #endif
364 389
 
365
-#define HEATER_0_PIN       10   // EXTRUDER 1
366
-#if MOTHERBOARD == 33
367
-#define HEATER_1_PIN       -1
368
-#else
369
-#define HEATER_1_PIN       9    // EXTRUDER 2 (FAN On Sprinter)
370
-#endif
371
-#define HEATER_2_PIN       -1
372
-#define TEMP_0_PIN         13   // ANALOG NUMBERING
373
-#define TEMP_1_PIN         15   // ANALOG NUMBERING
374
-#define TEMP_2_PIN         -1   // ANALOG NUMBERING
375
-#define HEATER_BED_PIN     8    // BED
376
-#define TEMP_BED_PIN       14   // ANALOG NUMBERING
390
+    #if NUM_SERVOS > 2
391
+      #define SERVO2_PIN         5
392
+    #endif
377 393
 
378
-#ifdef NUM_SERVOS
379
-  #define SERVO0_PIN         11
380
-  #if NUM_SERVOS > 1
381
-  #define SERVO1_PIN         6
382
-  #endif
383
-  #if NUM_SERVOS > 2
384
-  #define SERVO2_PIN         5
385
-  #endif
386
-  #if NUM_SERVOS > 2
387
-  #define SERVO3_PIN         4
394
+    #if NUM_SERVOS > 2
395
+      #define SERVO3_PIN         4
396
+    #endif
388 397
   #endif
389
-#endif
390 398
 
391
-#ifdef ULTRA_LCD
399
+  #ifdef ULTRA_LCD
392 400
 
393
-  #ifdef NEWPANEL
394
-    #define LCD_PINS_RS 16 
395
-    #define LCD_PINS_ENABLE 17
396
-    #define LCD_PINS_D4 23
397
-    #define LCD_PINS_D5 25
398
-    #define LCD_PINS_D6 27
399
-    #define LCD_PINS_D7 29
400
-
401
-    #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
402
-      #define BEEPER 37
401
+    #ifdef NEWPANEL
402
+      #define LCD_PINS_RS 16 
403
+      #define LCD_PINS_ENABLE 17
404
+      #define LCD_PINS_D4 23
405
+      #define LCD_PINS_D5 25
406
+      #define LCD_PINS_D6 27
407
+      #define LCD_PINS_D7 29
403 408
 
404
-      #define BTN_EN1 31
405
-      #define BTN_EN2 33
406
-      #define BTN_ENC 35
409
+      #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
410
+        #define BEEPER 37
407 411
 
408
-      #define SDCARDDETECT 49
409
-    #else
410
-      //arduino pin which triggers an piezzo beeper
411
-      #define BEEPER 33  // Beeper on AUX-4
412
-
413
-      //buttons are directly attached using AUX-2
414
-      #ifdef REPRAPWORLD_KEYPAD
415
-        #define BTN_EN1 64 // encoder
416
-        #define BTN_EN2 59 // encoder
417
-        #define BTN_ENC 63 // enter button
418
-        #define SHIFT_OUT 40 // shift register
419
-        #define SHIFT_CLK 44 // shift register
420
-        #define SHIFT_LD 42 // shift register
421
-      #else
422
-        #define BTN_EN1 37
423
-        #define BTN_EN2 35
424
-        #define BTN_ENC 31  //the click
425
-      #endif
412
+        #define BTN_EN1 31
413
+        #define BTN_EN2 33
414
+        #define BTN_ENC 35
426 415
 
427
-      #ifdef G3D_PANEL
428 416
         #define SDCARDDETECT 49
429 417
       #else
430
-        #define SDCARDDETECT -1  // Ramps does not use this port
418
+        //arduino pin which triggers an piezzo beeper
419
+        #define BEEPER 33  // Beeper on AUX-4
420
+
421
+        //buttons are directly attached using AUX-2
422
+        #ifdef REPRAPWORLD_KEYPAD
423
+          #define BTN_EN1 64 // encoder
424
+          #define BTN_EN2 59 // encoder
425
+          #define BTN_ENC 63 // enter button
426
+          #define SHIFT_OUT 40 // shift register
427
+          #define SHIFT_CLK 44 // shift register
428
+          #define SHIFT_LD 42 // shift register
429
+        #else
430
+          #define BTN_EN1 37
431
+          #define BTN_EN2 35
432
+          #define BTN_ENC 31  //the click
433
+        #endif
434
+
435
+        #ifdef G3D_PANEL
436
+          #define SDCARDDETECT 49
437
+        #else
438
+          #define SDCARDDETECT -1  // Ramps does not use this port
439
+        #endif
440
+    
431 441
       #endif
432
-    #endif
433 442
 
434
-  #else //old style panel with shift register
435
-    //arduino pin witch triggers an piezzo beeper
436
-    #define BEEPER 33   // No Beeper added 
437
-
438
-    //buttons are attached to a shift register
439
-  // Not wired this yet
440
-    //#define SHIFT_CLK 38
441
-    //#define SHIFT_LD 42
442
-    //#define SHIFT_OUT 40
443
-    //#define SHIFT_EN 17
444
-
445
-    #define LCD_PINS_RS 16
446
-    #define LCD_PINS_ENABLE 17
447
-    #define LCD_PINS_D4 23
448
-    #define LCD_PINS_D5 25
449
-    #define LCD_PINS_D6 27
450
-    #define LCD_PINS_D7 29
451
-  #endif 
452
-#endif //ULTRA_LCD
443
+    #else //old style panel with shift register
444
+      //arduino pin witch triggers an piezzo beeper
445
+      #define BEEPER 33   // No Beeper added 
446
+
447
+      //buttons are attached to a shift register
448
+      // Not wired this yet
449
+      //#define SHIFT_CLK 38
450
+      //#define SHIFT_LD 42
451
+      //#define SHIFT_OUT 40
452
+      //#define SHIFT_EN 17
453
+
454
+      #define LCD_PINS_RS 16
455
+      #define LCD_PINS_ENABLE 17
456
+      #define LCD_PINS_D4 23
457
+      #define LCD_PINS_D5 25
458
+      #define LCD_PINS_D6 27
459
+      #define LCD_PINS_D7 29
460
+    #endif 
461
+  #endif //ULTRA_LCD
453 462
 
454 463
 #else // RAMPS_V_1_1 or RAMPS_V_1_2 as default (MOTHERBOARD == 3)
455 464
 
456
-#define X_STEP_PIN         26
457
-#define X_DIR_PIN          28
458
-#define X_ENABLE_PIN       24
459
-#define X_MIN_PIN           3
460
-#define X_MAX_PIN          -1    //2
461
-
462
-#define Y_STEP_PIN         38
463
-#define Y_DIR_PIN          40
464
-#define Y_ENABLE_PIN       36
465
-#define Y_MIN_PIN          16
466
-#define Y_MAX_PIN          -1    //17
467
-
468
-#define Z_STEP_PIN         44
469
-#define Z_DIR_PIN          46
470
-#define Z_ENABLE_PIN       42
471
-#define Z_MIN_PIN          18
472
-#define Z_MAX_PIN          -1    //19
465
+  #define X_STEP_PIN         26
466
+  #define X_DIR_PIN          28
467
+  #define X_ENABLE_PIN       24
468
+  #define X_MIN_PIN           3
469
+  #define X_MAX_PIN          -1    //2
470
+
471
+  #define Y_STEP_PIN         38
472
+  #define Y_DIR_PIN          40
473
+  #define Y_ENABLE_PIN       36
474
+  #define Y_MIN_PIN          16
475
+  #define Y_MAX_PIN          -1    //17
476
+
477
+  #define Z_STEP_PIN         44
478
+  #define Z_DIR_PIN          46
479
+  #define Z_ENABLE_PIN       42
480
+  #define Z_MIN_PIN          18
481
+  #define Z_MAX_PIN          -1    //19
482
+
483
+  #define E0_STEP_PIN         32
484
+  #define E0_DIR_PIN          34
485
+  #define E0_ENABLE_PIN       30
486
+
487
+  #define SDPOWER            48
488
+  #define SDSS               53
489
+  #define LED_PIN            13
490
+  #define PS_ON_PIN          -1
491
+  #define KILL_PIN           -1
492
+
493
+  #ifdef RAMPS_V_1_0 // RAMPS_V_1_0
494
+    #define HEATER_0_PIN     12    // RAMPS 1.0
495
+    #define HEATER_BED_PIN   -1    // RAMPS 1.0
496
+    #define FAN_PIN          11    // RAMPS 1.0
497
+  #else // RAMPS_V_1_1 or RAMPS_V_1_2
498
+    #define HEATER_0_PIN     10    // RAMPS 1.1
499
+    #define HEATER_BED_PIN    8    // RAMPS 1.1
500
+    #define FAN_PIN           9    // RAMPS 1.1
501
+  #endif
473 502
 
474
-#define E0_STEP_PIN         32
475
-#define E0_DIR_PIN          34
476
-#define E0_ENABLE_PIN       30
503
+  #define HEATER_1_PIN        -1
504
+  #define HEATER_2_PIN        -1
505
+  #define TEMP_0_PIN          2    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
506
+  #define TEMP_1_PIN          -1
507
+  #define TEMP_2_PIN          -1
508
+  #define TEMP_BED_PIN        1    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
477 509
 
478
-#define SDPOWER            48
479
-#define SDSS               53
480
-#define LED_PIN            13
481
-#define PS_ON_PIN          -1
482
-#define KILL_PIN           -1
483
-
484
-#ifdef RAMPS_V_1_0 // RAMPS_V_1_0
485
-  #define HEATER_0_PIN     12    // RAMPS 1.0
486
-  #define HEATER_BED_PIN   -1    // RAMPS 1.0
487
-  #define FAN_PIN          11    // RAMPS 1.0
488
-#else // RAMPS_V_1_1 or RAMPS_V_1_2
489
-  #define HEATER_0_PIN     10    // RAMPS 1.1
490
-  #define HEATER_BED_PIN    8    // RAMPS 1.1
491
-  #define FAN_PIN           9    // RAMPS 1.1
492
-#endif
493
-#define HEATER_1_PIN        -1
494
-#define HEATER_2_PIN        -1
495
-#define TEMP_0_PIN          2    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
496
-#define TEMP_1_PIN          -1
497
-#define TEMP_2_PIN          -1
498
-#define TEMP_BED_PIN        1    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
499 510
 #endif// MOTHERBOARD == 33 || MOTHERBOARD == 34
500 511
 
501 512
 // SPI for Max6675 Thermocouple
@@ -1618,4 +1629,4 @@
1618 1629
                         HEATER_BED_PIN, FAN_PIN,                  \
1619 1630
                         _E0_PINS _E1_PINS _E2_PINS             \
1620 1631
                         analogInputToDigitalPin(TEMP_0_PIN), analogInputToDigitalPin(TEMP_1_PIN), analogInputToDigitalPin(TEMP_2_PIN), analogInputToDigitalPin(TEMP_BED_PIN) }
1621
-#endif
1632
+#endif

+ 20
- 10
Marlin/temperature.cpp View File

@@ -107,15 +107,15 @@ static volatile bool temp_meas_ready = false;
107 107
     (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
108 108
   static unsigned long extruder_autofan_last_check;
109 109
 #endif  
110
-  
110
+
111 111
 #if EXTRUDERS > 3
112
-# error Unsupported number of extruders
112
+  # error Unsupported number of extruders
113 113
 #elif EXTRUDERS > 2
114
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
114
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
115 115
 #elif EXTRUDERS > 1
116
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
116
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
117 117
 #else
118
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
118
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
119 119
 #endif
120 120
 
121 121
 // Init min and max temp with extreme values to prevent false errors during startup
@@ -127,8 +127,14 @@ static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383 );
127 127
 #ifdef BED_MAXTEMP
128 128
 static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
129 129
 #endif
130
-static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
131
-static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN );
130
+
131
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
132
+  static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
133
+  static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
134
+#else
135
+  static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
136
+  static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN );
137
+#endif
132 138
 
133 139
 static float analog2temp(int raw, uint8_t e);
134 140
 static float analog2tempBed(int raw);
@@ -475,11 +481,11 @@ void manage_heater()
475 481
     }
476 482
     #endif
477 483
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
478
-      if(fabs(current_temperature[1] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
484
+      if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
479 485
         disable_heater();
480 486
         if(IsStopped() == false) {
481 487
           SERIAL_ERROR_START;
482
-          SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is to high !");
488
+          SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !");
483 489
           LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
484 490
         }
485 491
         #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
@@ -580,7 +586,11 @@ void manage_heater()
580 586
 // Derived from RepRap FiveD extruder::getTemperature()
581 587
 // For hot end temperature measurement.
582 588
 static float analog2temp(int raw, uint8_t e) {
589
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
590
+  if(e > EXTRUDERS)
591
+#else
583 592
   if(e >= EXTRUDERS)
593
+#endif
584 594
   {
585 595
       SERIAL_ERROR_START;
586 596
       SERIAL_ERROR((int)e);
@@ -660,7 +670,7 @@ static void updateTemperaturesFromRawValues()
660 670
     }
661 671
     current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
662 672
     #ifdef TEMP_SENSOR_1_AS_REDUNDANT
663
-      redundant_temperature =analog2temp(redundant_temperature_raw, 1);
673
+      redundant_temperature = analog2temp(redundant_temperature_raw, 1);
664 674
     #endif
665 675
     //Reset the watchdog after we know we have a temperature measurement.
666 676
     watchdog_reset();

Loading…
Cancel
Save