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
 #define HEATER_2_MAXTEMP 275
87
 #define HEATER_2_MAXTEMP 275
88
 #define BED_MAXTEMP 150
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
 // PID settings:
95
 // PID settings:
92
 // Comment the following line to disable PID and enable bang-bang.
96
 // Comment the following line to disable PID and enable bang-bang.

+ 25
- 0
Marlin/temperature.cpp View File

254
 
254
 
255
 void manage_heater()
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
   #ifdef USE_WATCHDOG
262
   #ifdef USE_WATCHDOG
258
     wd_reset();
263
     wd_reset();
259
   #endif
264
   #endif
333
     }
338
     }
334
   #endif
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
   if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
351
   if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
337
     return;
352
     return;
338
   previous_millis_bed_heater = millis();
353
   previous_millis_bed_heater = millis();
339
   
354
   
340
   #if TEMP_BED_PIN > -1
355
   #if TEMP_BED_PIN > -1
341
   
356
   
357
+    #ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
358
+    bed_needs_heating=0;
359
+    #endif
360
+
342
     #ifndef BED_LIMIT_SWITCHING
361
     #ifndef BED_LIMIT_SWITCHING
343
       // Check if temperature is within the correct range
362
       // Check if temperature is within the correct range
344
       if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
363
       if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
348
         }
367
         }
349
         else 
368
         else 
350
         {
369
         {
370
+          #ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
371
+          bed_needs_heating=1;
372
+          #endif
351
           WRITE(HEATER_BED_PIN,HIGH);
373
           WRITE(HEATER_BED_PIN,HIGH);
352
         }
374
         }
353
       }
375
       }
364
         else 
386
         else 
365
           if(current_raw_bed <= target_bed_low_temp)
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
           WRITE(HEATER_BED_PIN,HIGH);
392
           WRITE(HEATER_BED_PIN,HIGH);
368
         }
393
         }
369
       }
394
       }

Loading…
Cancel
Save