1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

Merge pull request #210 from Dabble63/Marlin_v1

Add Duty Cycling to the Heater Bed
This commit is contained in:
ErikZalm 2012-08-11 01:42:02 -07:00
commit 57468d3c21
2 changed files with 29 additions and 0 deletions

View File

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

View File

@ -254,6 +254,11 @@ int getHeaterPower(int heater) {
void manage_heater()
{
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
static int bed_needs_heating=0;
static int bed_is_on=0;
#endif
#ifdef USE_WATCHDOG
wd_reset();
#endif
@ -333,12 +338,26 @@ void manage_heater()
}
#endif
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
if (bed_needs_heating){
if (bed_is_on==0)
WRITE(HEATER_BED_PIN,HIGH);
if (bed_is_on==1)
WRITE(HEATER_BED_PIN,LOW);
bed_is_on=(bed_is_on+1) % HEATER_BED_DUTY_CYCLE_DIVIDER;
}
#endif
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
return;
previous_millis_bed_heater = millis();
#if TEMP_BED_PIN > -1
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
bed_needs_heating=0;
#endif
#ifndef BED_LIMIT_SWITCHING
// Check if temperature is within the correct range
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
@ -348,6 +367,9 @@ void manage_heater()
}
else
{
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
bed_needs_heating=1;
#endif
WRITE(HEATER_BED_PIN,HIGH);
}
}
@ -364,6 +386,9 @@ void manage_heater()
else
if(current_raw_bed <= target_bed_low_temp)
{
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER
bed_needs_heating=1;
#endif
WRITE(HEATER_BED_PIN,HIGH);
}
}