From 7eef2733856dac97dd46f19160cf6fb2eedd198b Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 16 Oct 2011 15:55:42 +0300 Subject: Added function for controlling controller cooling fan --- Sprinter/Sprinter.pde | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 52910ec..8124f00 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -245,6 +245,10 @@ void setup() if(!E_ENABLE_ON) WRITE(E_ENABLE_PIN,HIGH); #endif + #ifdef CONTROLLERFAN_PIN + SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan + #endif + //endstops and pullups #ifdef ENDSTOPPULLUPS #if X_MIN_PIN > -1 @@ -1441,6 +1445,32 @@ int read_max6675() } #endif +#ifdef CONTROLLERFAN_PIN +unsigned long lastMotor = 0; //Save the time for when a motor was turned on last +unsigned long lastMotorCheck = 0; + +void controllerFan() +{ + if ((millis() - lastMotorCheck) >= 2500) //Not a time critical function, so we only check every 2500ms + { + lastMotorCheck = millis(); + + if(!digitalRead(X_ENABLE_PIN) || !digitalRead(Y_ENABLE_PIN) || !digitalRead(Z_ENABLE_PIN) || !digitalRead(E_ENABLE_PIN)) //If any of the drivers are enabled... + { + lastMotor = millis(); //... set time to NOW so the fan will turn on + } + + if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... + { + digitalWrite(CONTROLLERFAN_PIN, LOW); //... turn the fan off + } + else + { + digitalWrite(CONTROLLERFAN_PIN, HIGH); //... turn the fan on + } + } +} +#endif void manage_heater() { @@ -1579,6 +1609,10 @@ void manage_heater() WRITE(HEATER_1_PIN,HIGH); } #endif + +#ifdef CONTROLLERFAN_PIN + controllerFan(); //Check if fan should be turned on to cool stepper drivers down +#endif } #if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR) -- cgit v1.2.1 From a584adc97f791fc3f9d71e6612db135d492df888 Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 16 Oct 2011 15:56:21 +0300 Subject: Added options for the controller cooling fan --- Sprinter/Configuration.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h index 3f2dda2..8c73f57 100644 --- a/Sprinter/Configuration.h +++ b/Sprinter/Configuration.h @@ -179,6 +179,12 @@ char uuid[] = "00000000-0000-0000-0000-000000000000"; #define BED_USES_THERMISTOR //#define BED_USES_AD595 +//This is for controlling a fan to cool down the stepper drivers +//it will turn on when any driver is enabled +//and turn off after the set amount of seconds from last driver being disabled again +#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 + // Uncomment the following line to enable debugging. You can better control debugging below the following line //#define DEBUG #ifdef DEBUG -- cgit v1.2.1 From c62f9388144c6723541e26a9cdf4e0e7c9f234aa Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 16 Oct 2011 16:18:50 +0300 Subject: Update Sprinter/Configuration.h --- Sprinter/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h index 8c73f57..a3a5d59 100644 --- a/Sprinter/Configuration.h +++ b/Sprinter/Configuration.h @@ -182,7 +182,7 @@ char uuid[] = "00000000-0000-0000-0000-000000000000"; //This is for controlling a fan to cool down the stepper drivers //it will turn on when any driver is enabled //and turn off after the set amount of seconds from last driver being disabled again -#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function +//#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 // Uncomment the following line to enable debugging. You can better control debugging below the following line -- cgit v1.2.1 From cc1bb0fc0825ca7997b3c21ae744972a1b22a6f9 Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 16 Oct 2011 16:26:08 +0300 Subject: Update Sprinter/Sprinter.pde --- Sprinter/Sprinter.pde | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 8124f00..9b694fd 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -1455,18 +1455,18 @@ void controllerFan() { lastMotorCheck = millis(); - if(!digitalRead(X_ENABLE_PIN) || !digitalRead(Y_ENABLE_PIN) || !digitalRead(Z_ENABLE_PIN) || !digitalRead(E_ENABLE_PIN)) //If any of the drivers are enabled... + if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN) || !READ(E_ENABLE_PIN)) //If any of the drivers are enabled... { lastMotor = millis(); //... set time to NOW so the fan will turn on } if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... { - digitalWrite(CONTROLLERFAN_PIN, LOW); //... turn the fan off + WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off } else { - digitalWrite(CONTROLLERFAN_PIN, HIGH); //... turn the fan on + WRITE(CONTROLLERFAN_PIN, HIGH); //... turn the fan on } } } -- cgit v1.2.1 From 588109f0984eeeb1f97dee956f26c9cecea1c806 Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 16 Oct 2011 16:29:59 +0300 Subject: Update Sprinter/Sprinter.pde --- Sprinter/Sprinter.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 9b694fd..ca3e0e9 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -1460,7 +1460,7 @@ void controllerFan() lastMotor = millis(); //... set time to NOW so the fan will turn on } - if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... + if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000L) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... { WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off } -- cgit v1.2.1 From f63468b74788d6c9efd7d7a2bf9174c99d0044ca Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 16 Oct 2011 16:31:56 +0300 Subject: Update Sprinter/Sprinter.pde --- Sprinter/Sprinter.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index ca3e0e9..7a6bf5e 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -1460,7 +1460,7 @@ void controllerFan() lastMotor = millis(); //... set time to NOW so the fan will turn on } - if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000L) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... + if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... { WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off } -- cgit v1.2.1