Browse Source

Merge pull request #210 from Dabble63/Marlin_v1

Add Duty Cycling to the Heater Bed
ErikZalm 12 years ago
parent
commit
57468d3c21
2 changed files with 29 additions and 0 deletions
  1. 4
    0
      Marlin/Configuration.h
  2. 25
    0
      Marlin/temperature.cpp

+ 4
- 0
Marlin/Configuration.h View File

@@ -87,6 +87,10 @@
87 87
 #define HEATER_2_MAXTEMP 275
88 88
 #define BED_MAXTEMP 150
89 89
 
90
+// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the
91
+// average current. The value should be an integer and the heat bed will be turned on for 1 interval of
92
+// HEATER_BED_DUTY_CYCLE_DIVIDER intervals.
93
+//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4
90 94
 
91 95
 // PID settings:
92 96
 // Comment the following line to disable PID and enable bang-bang.

+ 25
- 0
Marlin/temperature.cpp View File

@@ -254,6 +254,11 @@ int getHeaterPower(int heater) {
254 254
 
255 255
 void manage_heater()
256 256
 {
257
+#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
258
+  static int bed_needs_heating=0;
259
+  static int bed_is_on=0;
260
+#endif
261
+
257 262
   #ifdef USE_WATCHDOG
258 263
     wd_reset();
259 264
   #endif
@@ -333,12 +338,26 @@ void manage_heater()
333 338
     }
334 339
   #endif
335 340
   
341
+#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
342
+  if (bed_needs_heating){
343
+    if (bed_is_on==0)
344
+        WRITE(HEATER_BED_PIN,HIGH);
345
+    if (bed_is_on==1)
346
+        WRITE(HEATER_BED_PIN,LOW);
347
+    bed_is_on=(bed_is_on+1) % HEATER_BED_DUTY_CYCLE_DIVIDER;
348
+  }
349
+#endif
350
+
336 351
   if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
337 352
     return;
338 353
   previous_millis_bed_heater = millis();
339 354
   
340 355
   #if TEMP_BED_PIN > -1
341 356
   
357
+    #ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
358
+    bed_needs_heating=0;
359
+    #endif
360
+
342 361
     #ifndef BED_LIMIT_SWITCHING
343 362
       // Check if temperature is within the correct range
344 363
       if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
@@ -348,6 +367,9 @@ void manage_heater()
348 367
         }
349 368
         else 
350 369
         {
370
+          #ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
371
+          bed_needs_heating=1;
372
+          #endif
351 373
           WRITE(HEATER_BED_PIN,HIGH);
352 374
         }
353 375
       }
@@ -364,6 +386,9 @@ void manage_heater()
364 386
         else 
365 387
           if(current_raw_bed <= target_bed_low_temp)
366 388
         {
389
+          #ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
390
+          bed_needs_heating=1;
391
+          #endif
367 392
           WRITE(HEATER_BED_PIN,HIGH);
368 393
         }
369 394
       }

Loading…
Cancel
Save