Bläddra i källkod

Added redundant temp sensor

Erik van der Zalm 12 år sedan
förälder
incheckning
9be61cdc02
4 ändrade filer med 68 tillägg och 38 borttagningar
  1. 5
    1
      Marlin/Configuration.h
  2. 3
    0
      Marlin/Configuration_adv.h
  3. 57
    37
      Marlin/temperature.cpp
  4. 3
    0
      Marlin/temperature.h

+ 5
- 1
Marlin/Configuration.h Visa fil

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

+ 3
- 0
Marlin/Configuration_adv.h Visa fil

@@ -367,5 +367,8 @@ const unsigned int dropsegments=5; //everything with less than this number of st
367 367
   #undef BED_MAXTEMP
368 368
 #endif
369 369
 
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
370 373
 
371 374
 #endif //__CONFIGURATION_ADV_H

+ 57
- 37
Marlin/temperature.cpp Visa fil

@@ -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);
@@ -157,28 +160,28 @@ void PID_autotune(float temp, int extruder, int ncycles)
157 160
   float Kp, Ki, Kd;
158 161
   float max = 0, min = 10000;
159 162
 
160
-	if ((extruder > EXTRUDERS)
163
+  if ((extruder > EXTRUDERS)
161 164
   #if (TEMP_BED_PIN <= -1)
162
-		||(extruder < 0)
163
-	#endif
164
-	){
165
-  	SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
166
-  	return;
167
-	}
165
+       ||(extruder < 0)
166
+  #endif
167
+       ){
168
+          SERIAL_ECHOLN("PID Autotune failed. Bad extruder number.");
169
+          return;
170
+        }
168 171
 	
169 172
   SERIAL_ECHOLN("PID Autotune start");
170 173
   
171 174
   disable_heater(); // switch off all heaters.
172 175
 
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;
176
+  if (extruder<0)
177
+  {
178
+     soft_pwm_bed = (MAX_BED_POWER)/2;
179
+     bias = d = (MAX_BED_POWER)/2;
180
+   }
181
+   else
182
+   {
183
+     soft_pwm[extruder] = (PID_MAX)/2;
184
+     bias = d = (PID_MAX)/2;
182 185
   }
183 186
 
184 187
 
@@ -196,10 +199,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
196 199
       if(heating == true && input > temp) {
197 200
         if(millis() - t2 > 5000) { 
198 201
           heating=false;
199
-					if (extruder<0)
200
-						soft_pwm_bed = (bias - d) >> 1;
201
-					else
202
-						soft_pwm[extruder] = (bias - d) >> 1;
202
+          if (extruder<0)
203
+            soft_pwm_bed = (bias - d) >> 1;
204
+          else
205
+            soft_pwm[extruder] = (bias - d) >> 1;
203 206
           t1=millis();
204 207
           t_high=t1 - t2;
205 208
           max=temp;
@@ -250,10 +253,10 @@ void PID_autotune(float temp, int extruder, int ncycles)
250 253
               */
251 254
             }
252 255
           }
253
-					if (extruder<0)
254
-						soft_pwm_bed = (bias + d) >> 1;
255
-					else
256
-						soft_pwm[extruder] = (bias + d) >> 1;
256
+          if (extruder<0)
257
+            soft_pwm_bed = (bias + d) >> 1;
258
+          else
259
+            soft_pwm[extruder] = (bias + d) >> 1;
257 260
           cycles++;
258 261
           min=temp;
259 262
         }
@@ -264,14 +267,14 @@ void PID_autotune(float temp, int extruder, int ncycles)
264 267
       return;
265 268
     }
266 269
     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
-			}
270
+      int p;
271
+      if (extruder<0){
272
+        p=soft_pwm_bed;       
273
+        SERIAL_PROTOCOLPGM("ok B:");
274
+      }else{
275
+        p=soft_pwm[extruder];       
276
+        SERIAL_PROTOCOLPGM("ok T:");
277
+      }
275 278
 			
276 279
       SERIAL_PROTOCOL(input);   
277 280
       SERIAL_PROTOCOLPGM(" @:");
@@ -471,7 +474,19 @@ void manage_heater()
471 474
         }
472 475
     }
473 476
     #endif
474
-
477
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
478
+      if(fabs(current_temperature[1] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
479
+        disable_heater();
480
+        if(IsStopped() == false) {
481
+          SERIAL_ERROR_START;
482
+          SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is to high !");
483
+          LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
484
+        }
485
+        #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
486
+          Stop();
487
+        #endif
488
+      }
489
+    #endif
475 490
   } // End extruder for loop
476 491
 
477 492
   #if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
@@ -644,7 +659,9 @@ static void updateTemperaturesFromRawValues()
644 659
         current_temperature[e] = analog2temp(current_temperature_raw[e], e);
645 660
     }
646 661
     current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
647
-
662
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
663
+      redundant_temperature =analog2temp(redundant_temperature_raw, 1);
664
+    #endif
648 665
     //Reset the watchdog after we know we have a temperature measurement.
649 666
     watchdog_reset();
650 667
 
@@ -1145,6 +1162,9 @@ ISR(TIMER0_COMPB_vect)
1145 1162
 #if EXTRUDERS > 1
1146 1163
       current_temperature_raw[1] = raw_temp_1_value;
1147 1164
 #endif
1165
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
1166
+      redundant_temperature_raw = raw_temp_1_value;
1167
+#endif
1148 1168
 #if EXTRUDERS > 2
1149 1169
       current_temperature_raw[2] = raw_temp_2_value;
1150 1170
 #endif

+ 3
- 0
Marlin/temperature.h Visa fil

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

Laddar…
Avbryt
Spara