diff options
author | blddk <michael.andresen@gmail.com> | 2011-10-16 15:55:42 +0300 |
---|---|---|
committer | blddk <michael.andresen@gmail.com> | 2011-10-16 15:55:42 +0300 |
commit | 7eef2733856dac97dd46f19160cf6fb2eedd198b (patch) | |
tree | 37a570eb6de938d6e1db3bf26632b05ff5209549 /Sprinter | |
parent | 01789743f693c6fb3578c2fc2204b7c5dfb2bf4c (diff) |
Added function for controlling controller cooling fan
Diffstat (limited to 'Sprinter')
-rw-r--r-- | Sprinter/Sprinter.pde | 34 |
1 files changed, 34 insertions, 0 deletions
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) |