Sfoglia il codice sorgente

Merge branch 'reisnyderb' of https://github.com/ErikZalm/Marlin into Marlin_v1

Erik van der Zalm 12 anni fa
parent
commit
79374f0b93
6 ha cambiato i file con 256 aggiunte e 205 eliminazioni
  1. 5
    1
      Marlin/Configuration.h
  2. 3
    0
      Marlin/Configuration_adv.h
  3. 2
    2
      Marlin/Marlin_main.cpp
  4. 169
    158
      Marlin/pins.h
  5. 74
    44
      Marlin/temperature.cpp
  6. 3
    0
      Marlin/temperature.h

+ 5
- 1
Marlin/Configuration.h Vedi File

@@ -90,10 +90,14 @@
90 90
 // 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan) (1k pullup)
91 91
 
92 92
 #define TEMP_SENSOR_0 -1
93
-#define TEMP_SENSOR_1 0
93
+#define TEMP_SENSOR_1 -1
94 94
 #define TEMP_SENSOR_2 0
95 95
 #define TEMP_SENSOR_BED 0
96 96
 
97
+// 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.
98
+//#define TEMP_SENSOR_1_AS_REDUNDANT 
99
+#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
100
+
97 101
 // Actual temperature must be close to target for this long before M109 returns success
98 102
 #define TEMP_RESIDENCY_TIME 10  // (seconds)
99 103
 #define TEMP_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one

+ 3
- 0
Marlin/Configuration_adv.h Vedi 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

+ 2
- 2
Marlin/Marlin_main.cpp Vedi 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);
@@ -2281,4 +2281,4 @@ bool setTargetedHotend(int code){
2281 2281
     }
2282 2282
   }
2283 2283
   return false;
2284
-}
2284
+}

+ 169
- 158
Marlin/pins.h Vedi 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
@@ -1835,4 +1846,4 @@
1835 1846
                         HEATER_BED_PIN, FAN_PIN,                  \
1836 1847
                         _E0_PINS _E1_PINS _E2_PINS             \
1837 1848
                         analogInputToDigitalPin(TEMP_0_PIN), analogInputToDigitalPin(TEMP_1_PIN), analogInputToDigitalPin(TEMP_2_PIN), analogInputToDigitalPin(TEMP_BED_PIN) }
1838
-#endif
1849
+#endif

+ 74
- 44
Marlin/temperature.cpp Vedi File

@@ -40,10 +40,13 @@
40 40
 int target_temperature[EXTRUDERS] = { 0 };
41 41
 int target_temperature_bed = 0;
42 42
 int current_temperature_raw[EXTRUDERS] = { 0 };
43
-float current_temperature[EXTRUDERS] = { 0 };
43
+float current_temperature[EXTRUDERS] = { 0.0 };
44 44
 int current_temperature_bed_raw = 0;
45
-float current_temperature_bed = 0;
46
-
45
+float current_temperature_bed = 0.0;
46
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
47
+  int redundant_temperature_raw = 0;
48
+  float redundant_temperature = 0.0;
49
+#endif
47 50
 #ifdef PIDTEMP
48 51
   float Kp=DEFAULT_Kp;
49 52
   float Ki=(DEFAULT_Ki*PID_dT);
@@ -104,15 +107,15 @@ static volatile bool temp_meas_ready = false;
104 107
     (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
105 108
   static unsigned long extruder_autofan_last_check;
106 109
 #endif  
107
-  
110
+
108 111
 #if EXTRUDERS > 3
109
-# error Unsupported number of extruders
112
+  # error Unsupported number of extruders
110 113
 #elif EXTRUDERS > 2
111
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
114
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2, v3 }
112 115
 #elif EXTRUDERS > 1
113
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
116
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1, v2 }
114 117
 #else
115
-# define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
118
+  # define ARRAY_BY_EXTRUDERS(v1, v2, v3) { v1 }
116 119
 #endif
117 120
 
118 121
 // Init min and max temp with extreme values to prevent false errors during startup
@@ -124,8 +127,14 @@ static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383 );
124 127
 #ifdef BED_MAXTEMP
125 128
 static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
126 129
 #endif
127
-static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE );
128
-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
129 138
 
130 139
 static float analog2temp(int raw, uint8_t e);
131 140
 static float analog2tempBed(int raw);
@@ -157,28 +166,28 @@ void PID_autotune(float temp, int extruder, int ncycles)
157 166
   float Kp, Ki, Kd;
158 167
   float max = 0, min = 10000;
159 168
 
160
-	if ((extruder > EXTRUDERS)
169
+  if ((extruder > EXTRUDERS)
161 170
   #if (TEMP_BED_PIN <= -1)
162
-		||(extruder < 0)
163
-	#endif
164
-	){
165
-  	SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
166
-  	return;
167
-	}
171
+       ||(extruder < 0)
172
+  #endif
173
+       ){
174
+          SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
175
+          return;
176
+        }
168 177
 	
169 178
   SERIAL_ECHOLN("PID Autotune start");
170 179
   
171 180
   disable_heater(); // switch off all heaters.
172 181
 
173
-	if (extruder<0)
174
-	{
175
-	 	soft_pwm_bed = (MAX_BED_POWER)/2;
176
-		bias = d = (MAX_BED_POWER)/2;
177
-  }
178
-	else
179
-	{
180
-	  soft_pwm[extruder] = (PID_MAX)/2;
181
-		bias = d = (PID_MAX)/2;
182
+  if (extruder<0)
183
+  {
184
+     soft_pwm_bed = (MAX_BED_POWER)/2;
185
+     bias = d = (MAX_BED_POWER)/2;
186
+   }
187
+   else
188
+   {
189
+     soft_pwm[extruder] = (PID_MAX)/2;
190
+     bias = d = (PID_MAX)/2;
182 191
   }
183 192
 
184 193
 
@@ -196,10 +205,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
196 205
       if(heating == true && input > temp) {
197 206
         if(millis() - t2 > 5000) { 
198 207
           heating=false;
199
-					if (extruder<0)
200
-						soft_pwm_bed = (bias - d) >> 1;
201
-					else
202
-						soft_pwm[extruder] = (bias - d) >> 1;
208
+          if (extruder<0)
209
+            soft_pwm_bed = (bias - d) >> 1;
210
+          else
211
+            soft_pwm[extruder] = (bias - d) >> 1;
203 212
           t1=millis();
204 213
           t_high=t1 - t2;
205 214
           max=temp;
@@ -250,10 +259,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
250 259
               */
251 260
             }
252 261
           }
253
-					if (extruder<0)
254
-						soft_pwm_bed = (bias + d) >> 1;
255
-					else
256
-						soft_pwm[extruder] = (bias + d) >> 1;
262
+          if (extruder<0)
263
+            soft_pwm_bed = (bias + d) >> 1;
264
+          else
265
+            soft_pwm[extruder] = (bias + d) >> 1;
257 266
           cycles++;
258 267
           min=temp;
259 268
         }
@@ -264,14 +273,14 @@ void PID_autotune(float temp, int extruder, int ncycles)
264 273
       return;
265 274
     }
266 275
     if(millis() - temp_millis > 2000) {
267
-			int p;
268
-			if (extruder<0){
269
-	      p=soft_pwm_bed;       
270
-	      SERIAL_PROTOCOLPGM("ok B:");
271
-			}else{
272
-	      p=soft_pwm[extruder];       
273
-	      SERIAL_PROTOCOLPGM("ok T:");
274
-			}
276
+      int p;
277
+      if (extruder<0){
278
+        p=soft_pwm_bed;       
279
+        SERIAL_PROTOCOLPGM("ok B:");
280
+      }else{
281
+        p=soft_pwm[extruder];       
282
+        SERIAL_PROTOCOLPGM("ok T:");
283
+      }
275 284
 			
276 285
       SERIAL_PROTOCOL(input);   
277 286
       SERIAL_PROTOCOLPGM(" @:");
@@ -471,7 +480,19 @@ void manage_heater()
471 480
         }
472 481
     }
473 482
     #endif
474
-
483
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
484
+      if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
485
+        disable_heater();
486
+        if(IsStopped() == false) {
487
+          SERIAL_ERROR_START;
488
+          SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !");
489
+          LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
490
+        }
491
+        #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
492
+          Stop();
493
+        #endif
494
+      }
495
+    #endif
475 496
   } // End extruder for loop
476 497
 
477 498
   #if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
@@ -565,7 +586,11 @@ void manage_heater()
565 586
 // Derived from RepRap FiveD extruder::getTemperature()
566 587
 // For hot end temperature measurement.
567 588
 static float analog2temp(int raw, uint8_t e) {
589
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
590
+  if(e > EXTRUDERS)
591
+#else
568 592
   if(e >= EXTRUDERS)
593
+#endif
569 594
   {
570 595
       SERIAL_ERROR_START;
571 596
       SERIAL_ERROR((int)e);
@@ -644,7 +669,9 @@ static void updateTemperaturesFromRawValues()
644 669
         current_temperature[e] = analog2temp(current_temperature_raw[e], e);
645 670
     }
646 671
     current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
647
-
672
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
673
+      redundant_temperature = analog2temp(redundant_temperature_raw, 1);
674
+    #endif
648 675
     //Reset the watchdog after we know we have a temperature measurement.
649 676
     watchdog_reset();
650 677
 
@@ -1145,6 +1172,9 @@ ISR(TIMER0_COMPB_vect)
1145 1172
 #if EXTRUDERS > 1
1146 1173
       current_temperature_raw[1] = raw_temp_1_value;
1147 1174
 #endif
1175
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
1176
+      redundant_temperature_raw = raw_temp_1_value;
1177
+#endif
1148 1178
 #if EXTRUDERS > 2
1149 1179
       current_temperature_raw[2] = raw_temp_2_value;
1150 1180
 #endif

+ 3
- 0
Marlin/temperature.h Vedi File

@@ -37,6 +37,9 @@ extern int target_temperature[EXTRUDERS];
37 37
 extern float current_temperature[EXTRUDERS];
38 38
 extern int target_temperature_bed;
39 39
 extern float current_temperature_bed;
40
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
41
+  extern float redundant_temperature;
42
+#endif
40 43
 
41 44
 #ifdef PIDTEMP
42 45
   extern float Kp,Ki,Kd,Kc;

Loading…
Annulla
Salva