Merge pull request #104 from blddk/experimental
Cooling fan control for a stepper driver fan - enable fan when stepper drivers are active
This commit is contained in:
commit
b784326f14
2 changed files with 40 additions and 0 deletions
|
|
@ -179,6 +179,12 @@ char uuid[] = "00000000-0000-0000-0000-000000000000";
|
||||||
#define BED_USES_THERMISTOR
|
#define BED_USES_THERMISTOR
|
||||||
//#define BED_USES_AD595
|
//#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
|
// Uncomment the following line to enable debugging. You can better control debugging below the following line
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,10 @@ void setup()
|
||||||
if(!E_ENABLE_ON) WRITE(E_ENABLE_PIN,HIGH);
|
if(!E_ENABLE_ON) WRITE(E_ENABLE_PIN,HIGH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONTROLLERFAN_PIN
|
||||||
|
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
|
||||||
|
#endif
|
||||||
|
|
||||||
//endstops and pullups
|
//endstops and pullups
|
||||||
#ifdef ENDSTOPPULLUPS
|
#ifdef ENDSTOPPULLUPS
|
||||||
#if X_MIN_PIN > -1
|
#if X_MIN_PIN > -1
|
||||||
|
|
@ -1441,6 +1445,32 @@ int read_max6675()
|
||||||
}
|
}
|
||||||
#endif
|
#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(!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*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
|
||||||
|
{
|
||||||
|
WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WRITE(CONTROLLERFAN_PIN, HIGH); //... turn the fan on
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void manage_heater()
|
void manage_heater()
|
||||||
{
|
{
|
||||||
|
|
@ -1579,6 +1609,10 @@ void manage_heater()
|
||||||
WRITE(HEATER_1_PIN,HIGH);
|
WRITE(HEATER_1_PIN,HIGH);
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
#if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue