From 3f2f94ef28a051754089395582f0ca3890138000 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 9 Dec 2012 22:28:09 -0500 Subject: [PATCH 1/2] Be consistent in setting of the fan PWM. Always set the FAN PWM value in check_axes_activity() and always use the value of the active move if a move is active. --- Marlin/planner.cpp | 24 ++---------------------- Marlin/ultralcd.cpp | 6 ------ 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 66809a10af..c7da244e9a 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -438,8 +438,7 @@ void check_axes_activity() unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; - unsigned char fan_speed = 0; - unsigned char tail_fan_speed = 0; + unsigned char tail_fan_speed = fanSpeed; block_t *block; if(block_buffer_tail != block_buffer_head) @@ -453,20 +452,9 @@ void check_axes_activity() if(block->steps_y != 0) y_active++; if(block->steps_z != 0) z_active++; if(block->steps_e != 0) e_active++; - if(block->fan_speed != 0) fan_speed++; block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1); } } - else - { - #if FAN_PIN > -1 - #ifndef FAN_SOFT_PWM - if (fanSpeed != 0){ - analogWrite(FAN_PIN,fanSpeed); // If buffer is empty use current fan speed - } - #endif - #endif - } if((DISABLE_X) && (x_active == 0)) disable_x(); if((DISABLE_Y) && (y_active == 0)) disable_y(); if((DISABLE_Z) && (z_active == 0)) disable_z(); @@ -478,15 +466,7 @@ void check_axes_activity() } #if FAN_PIN > -1 #ifndef FAN_SOFT_PWM - if((fanSpeed == 0) && (fan_speed ==0)) - { - analogWrite(FAN_PIN, 0); - } - - if (fanSpeed != 0 && tail_fan_speed !=0) - { - analogWrite(FAN_PIN,tail_fan_speed); - } + analogWrite(FAN_PIN,tail_fan_speed); #endif #endif #ifdef AUTOTEMP diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 32398354ff..5758ac1268 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -221,10 +221,7 @@ void lcd_preheat_pla() setTargetHotend1(plaPreheatHotendTemp); setTargetHotend2(plaPreheatHotendTemp); setTargetBed(plaPreheatHPBTemp); -#if FAN_PIN > -1 fanSpeed = plaPreheatFanSpeed; - analogWrite(FAN_PIN, fanSpeed); -#endif lcd_return_to_status(); } @@ -234,10 +231,7 @@ void lcd_preheat_abs() setTargetHotend1(absPreheatHotendTemp); setTargetHotend2(absPreheatHotendTemp); setTargetBed(absPreheatHPBTemp); -#if FAN_PIN > -1 fanSpeed = absPreheatFanSpeed; - analogWrite(FAN_PIN, fanSpeed); -#endif lcd_return_to_status(); } From 3d91bd486ce6a42944b573b615c23c515525d985 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 9 Dec 2012 23:47:52 -0500 Subject: [PATCH 2/2] Add "kick fan" feature - briefly run fan at full speed on start. Add a feature to run the cooling fan at full speed for a small period (default 100ms) when first starting the fan. Some fans wont reliably start spinning at low power, and many fans have issue with the PWM at low power. However, once the fan starts spinning it can reliably be set to a wide range of PWM values. --- Marlin/Configuration_adv.h | 5 +++++ Marlin/planner.cpp | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b718640c1c..98d0da2756 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -66,6 +66,11 @@ //#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function #define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run +// When first starting the main fan, run it at full speed for the +// given number of milliseconds. This gets the fan spinning reliably +// before setting a PWM value. Set to zero to disable. +#define FAN_KICKSTART_TIME 100 + //=========================================================================== //=============================Mechanical Settings=========================== //=========================================================================== diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index c7da244e9a..6173bcea3a 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -466,6 +466,20 @@ void check_axes_activity() } #if FAN_PIN > -1 #ifndef FAN_SOFT_PWM + if (FAN_KICKSTART_TIME) { + static unsigned long FanKickEnd; + if (tail_fan_speed) { + if (FanKickEnd == 0) { + // Just starting up fan - run at full power. + FanKickEnd = millis() + FAN_KICKSTART_TIME; + tail_fan_speed = 255; + } else if (FanKickEnd > millis()) + // Fan still spinning up. + tail_fan_speed = 255; + } else { + FanKickEnd = 0; + } + } analogWrite(FAN_PIN,tail_fan_speed); #endif #endif