Browse Source

Merge pull request #334 from KevinOConnor/FanKick

Add feature to briefly run the cooling fan at full speed when it first starts.
daid 12 years ago
parent
commit
6ec56fa923
3 changed files with 20 additions and 27 deletions
  1. 5
    0
      Marlin/Configuration_adv.h
  2. 15
    21
      Marlin/planner.cpp
  3. 0
    6
      Marlin/ultralcd.cpp

+ 5
- 0
Marlin/Configuration_adv.h View File

@@ -66,6 +66,11 @@
66 66
 //#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
67 67
 #define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run
68 68
 
69
+// When first starting the main fan, run it at full speed for the
70
+// given number of milliseconds.  This gets the fan spinning reliably
71
+// before setting a PWM value.  Set to zero to disable.
72
+#define FAN_KICKSTART_TIME 100
73
+
69 74
 //===========================================================================
70 75
 //=============================Mechanical Settings===========================
71 76
 //===========================================================================

+ 15
- 21
Marlin/planner.cpp View File

@@ -438,8 +438,7 @@ void check_axes_activity()
438 438
   unsigned char y_active = 0;  
439 439
   unsigned char z_active = 0;
440 440
   unsigned char e_active = 0;
441
-  unsigned char fan_speed = 0;
442
-  unsigned char tail_fan_speed = 0;
441
+  unsigned char tail_fan_speed = fanSpeed;
443 442
   block_t *block;
444 443
 
445 444
   if(block_buffer_tail != block_buffer_head)
@@ -453,20 +452,9 @@ void check_axes_activity()
453 452
       if(block->steps_y != 0) y_active++;
454 453
       if(block->steps_z != 0) z_active++;
455 454
       if(block->steps_e != 0) e_active++;
456
-      if(block->fan_speed != 0) fan_speed++;
457 455
       block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
458 456
     }
459 457
   }
460
-  else
461
-  {
462
-    #if FAN_PIN > -1
463
-    #ifndef FAN_SOFT_PWM
464
-    if (fanSpeed != 0){
465
-      analogWrite(FAN_PIN,fanSpeed); // If buffer is empty use current fan speed
466
-    }
467
-    #endif
468
-	#endif
469
-  }
470 458
   if((DISABLE_X) && (x_active == 0)) disable_x();
471 459
   if((DISABLE_Y) && (y_active == 0)) disable_y();
472 460
   if((DISABLE_Z) && (z_active == 0)) disable_z();
@@ -478,15 +466,21 @@ void check_axes_activity()
478 466
   }
479 467
 #if FAN_PIN > -1
480 468
   #ifndef FAN_SOFT_PWM
481
-  if((fanSpeed == 0) && (fan_speed ==0))
482
-  {
483
-    analogWrite(FAN_PIN, 0);
484
-  }
485
-
486
-  if (fanSpeed != 0 && tail_fan_speed !=0)
487
-  {
488
-    analogWrite(FAN_PIN,tail_fan_speed);
469
+  if (FAN_KICKSTART_TIME) {
470
+    static unsigned long FanKickEnd;
471
+    if (tail_fan_speed) {
472
+      if (FanKickEnd == 0) {
473
+        // Just starting up fan - run at full power.
474
+        FanKickEnd = millis() + FAN_KICKSTART_TIME;
475
+        tail_fan_speed = 255;
476
+      } else if (FanKickEnd > millis())
477
+        // Fan still spinning up.
478
+        tail_fan_speed = 255;
479
+    } else {
480
+      FanKickEnd = 0;
481
+    }
489 482
   }
483
+  analogWrite(FAN_PIN,tail_fan_speed);
490 484
   #endif
491 485
 #endif
492 486
 #ifdef AUTOTEMP

+ 0
- 6
Marlin/ultralcd.cpp View File

@@ -221,10 +221,7 @@ void lcd_preheat_pla()
221 221
     setTargetHotend1(plaPreheatHotendTemp);
222 222
     setTargetHotend2(plaPreheatHotendTemp);
223 223
     setTargetBed(plaPreheatHPBTemp);
224
-#if FAN_PIN > -1
225 224
     fanSpeed = plaPreheatFanSpeed;
226
-    analogWrite(FAN_PIN,  fanSpeed);
227
-#endif
228 225
     lcd_return_to_status();
229 226
 }
230 227
 
@@ -234,10 +231,7 @@ void lcd_preheat_abs()
234 231
     setTargetHotend1(absPreheatHotendTemp);
235 232
     setTargetHotend2(absPreheatHotendTemp);
236 233
     setTargetBed(absPreheatHPBTemp);
237
-#if FAN_PIN > -1
238 234
     fanSpeed = absPreheatFanSpeed;
239
-    analogWrite(FAN_PIN,  fanSpeed);
240
-#endif
241 235
     lcd_return_to_status();
242 236
 }
243 237
 

Loading…
Cancel
Save