Browse Source

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

Erik van der Zalm 13 years ago
parent
commit
87ff2f8867
3 changed files with 54 additions and 0 deletions
  1. 6
    0
      Marlin/Configuration_adv.h
  2. 38
    0
      Marlin/Marlin.pde
  3. 10
    0
      Marlin/stepper.cpp

+ 6
- 0
Marlin/Configuration_adv.h View File

@@ -61,6 +61,12 @@
61 61
 #define TEMP_SENSOR_AD595_OFFSET 0.0
62 62
 #define TEMP_SENSOR_AD595_GAIN   1.0
63 63
 
64
+//This is for controlling a fan to cool down the stepper drivers
65
+//it will turn on when any driver is enabled
66
+//and turn off after the set amount of seconds from last driver being disabled again
67
+//#define CONTROLLERFAN_PIN 23 //Pin used for the fan to cool controller, comment out to disable this function
68
+#define CONTROLLERFAN_SEC 60 //How many seconds, after all motors were disabled, the fan should run
69
+
64 70
 //===========================================================================
65 71
 //=============================Mechanical Settings===========================
66 72
 //===========================================================================

+ 38
- 0
Marlin/Marlin.pde View File

@@ -290,6 +290,7 @@ void setup()
290 290
     axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
291 291
   }
292 292
 
293
+
293 294
   tp_init();    // Initialize temperature loop 
294 295
   plan_init();  // Initialize planner;
295 296
   st_init();    // Initialize stepper;
@@ -1337,6 +1338,40 @@ void prepare_arc_move(char isclockwise) {
1337 1338
   previous_millis_cmd = millis();
1338 1339
 }
1339 1340
 
1341
+#ifdef CONTROLLERFAN_PIN
1342
+unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
1343
+unsigned long lastMotorCheck = 0;
1344
+
1345
+void controllerFan()
1346
+{
1347
+  if ((millis() - lastMotorCheck) >= 2500) //Not a time critical function, so we only check every 2500ms
1348
+  {
1349
+    lastMotorCheck = millis();
1350
+    
1351
+    if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN)
1352
+    #if EXTRUDERS > 2
1353
+       || !READ(E2_ENABLE_PIN)
1354
+    #endif
1355
+    #if EXTRUDER > 1
1356
+       || !READ(E2_ENABLE_PIN)
1357
+    #endif
1358
+       || !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...    
1359
+    {
1360
+      lastMotor = millis(); //... set time to NOW so the fan will turn on
1361
+    }
1362
+    
1363
+    if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...   
1364
+    {
1365
+      WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off
1366
+    }
1367
+    else
1368
+    {
1369
+      WRITE(CONTROLLERFAN_PIN, HIGH); //... turn the fan on
1370
+    }
1371
+  }
1372
+}
1373
+#endif
1374
+
1340 1375
 void manage_inactivity(byte debug) 
1341 1376
 { 
1342 1377
   if( (millis() - previous_millis_cmd) >  max_inactive_time ) 
@@ -1355,6 +1390,9 @@ void manage_inactivity(byte debug)
1355 1390
       }
1356 1391
     }
1357 1392
   }
1393
+  #ifdef CONTROLLERFAN_PIN
1394
+    controllerFan(); //Check if fan should be turned on to cool stepper drivers down
1395
+  #endif
1358 1396
   #ifdef EXTRUDER_RUNOUT_PREVENT
1359 1397
     if( (millis() - previous_millis_cmd) >  EXTRUDER_RUNOUT_SECONDS*1000 ) 
1360 1398
     if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)

+ 10
- 0
Marlin/stepper.cpp View File

@@ -714,23 +714,33 @@ void st_init()
714 714
   //Initialize Step Pins
715 715
   #if (X_STEP_PIN > -1) 
716 716
     SET_OUTPUT(X_STEP_PIN);
717
+    if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
717 718
   #endif  
718 719
   #if (Y_STEP_PIN > -1) 
719 720
     SET_OUTPUT(Y_STEP_PIN);
721
+    if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
720 722
   #endif  
721 723
   #if (Z_STEP_PIN > -1) 
722 724
     SET_OUTPUT(Z_STEP_PIN);
725
+    if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
723 726
   #endif  
724 727
   #if (E0_STEP_PIN > -1) 
725 728
     SET_OUTPUT(E0_STEP_PIN);
729
+    if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
726 730
   #endif  
727 731
   #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) 
728 732
     SET_OUTPUT(E1_STEP_PIN);
733
+    if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
729 734
   #endif  
730 735
   #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) 
731 736
     SET_OUTPUT(E2_STEP_PIN);
737
+    if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
732 738
   #endif  
733 739
 
740
+  #ifdef CONTROLLERFAN_PIN
741
+    SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
742
+  #endif
743
+  
734 744
   // waveform generation = 0100 = CTC
735 745
   TCCR1B &= ~(1<<WGM13);
736 746
   TCCR1B |=  (1<<WGM12);

Loading…
Cancel
Save