Added CONTROLLERFAN. (Controlling a fan to cool down the steppper drivers)

This commit is contained in:
Erik van der Zalm 2012-03-11 10:44:10 +01:00
parent 387fe51a56
commit 87ff2f8867
3 changed files with 54 additions and 0 deletions

View file

@ -61,6 +61,12 @@
#define TEMP_SENSOR_AD595_OFFSET 0.0 #define TEMP_SENSOR_AD595_OFFSET 0.0
#define TEMP_SENSOR_AD595_GAIN 1.0 #define TEMP_SENSOR_AD595_GAIN 1.0
//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
//=========================================================================== //===========================================================================
//=============================Mechanical Settings=========================== //=============================Mechanical Settings===========================
//=========================================================================== //===========================================================================

View file

@ -290,6 +290,7 @@ void setup()
axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
} }
tp_init(); // Initialize temperature loop tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner; plan_init(); // Initialize planner;
st_init(); // Initialize stepper; st_init(); // Initialize stepper;
@ -1337,6 +1338,40 @@ void prepare_arc_move(char isclockwise) {
previous_millis_cmd = millis(); previous_millis_cmd = millis();
} }
#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)
#if EXTRUDERS > 2
|| !READ(E2_ENABLE_PIN)
#endif
#if EXTRUDER > 1
|| !READ(E2_ENABLE_PIN)
#endif
|| !READ(E0_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_inactivity(byte debug) void manage_inactivity(byte debug)
{ {
if( (millis() - previous_millis_cmd) > max_inactive_time ) if( (millis() - previous_millis_cmd) > max_inactive_time )
@ -1355,6 +1390,9 @@ void manage_inactivity(byte debug)
} }
} }
} }
#ifdef CONTROLLERFAN_PIN
controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif
#ifdef EXTRUDER_RUNOUT_PREVENT #ifdef EXTRUDER_RUNOUT_PREVENT
if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 ) if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)

View file

@ -714,21 +714,31 @@ void st_init()
//Initialize Step Pins //Initialize Step Pins
#if (X_STEP_PIN > -1) #if (X_STEP_PIN > -1)
SET_OUTPUT(X_STEP_PIN); SET_OUTPUT(X_STEP_PIN);
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
#endif #endif
#if (Y_STEP_PIN > -1) #if (Y_STEP_PIN > -1)
SET_OUTPUT(Y_STEP_PIN); SET_OUTPUT(Y_STEP_PIN);
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
#endif #endif
#if (Z_STEP_PIN > -1) #if (Z_STEP_PIN > -1)
SET_OUTPUT(Z_STEP_PIN); SET_OUTPUT(Z_STEP_PIN);
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
#endif #endif
#if (E0_STEP_PIN > -1) #if (E0_STEP_PIN > -1)
SET_OUTPUT(E0_STEP_PIN); SET_OUTPUT(E0_STEP_PIN);
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
#endif #endif
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
SET_OUTPUT(E1_STEP_PIN); SET_OUTPUT(E1_STEP_PIN);
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
#endif #endif
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
SET_OUTPUT(E2_STEP_PIN); SET_OUTPUT(E2_STEP_PIN);
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
#endif
#ifdef CONTROLLERFAN_PIN
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
#endif #endif
// waveform generation = 0100 = CTC // waveform generation = 0100 = CTC