diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 58f5bcaeaf..3215a09c97 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -58,6 +58,10 @@ // Select one of these only to define how the bed temp is read. //#define THERMISTORBED 1 //#define BED_USES_THERMISTOR +//#define BED_LIMIT_SWITCHING +#ifdef BED_LIMIT_SWITCHING + #define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS +#endif //#define BED_USES_AD595 #define BED_CHECK_INTERVAL 5000 //ms @@ -167,6 +171,7 @@ #define EXTRUDER_RUNOUT_SECONDS 30. #define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament #define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed +#define EXTRUDER_RUNOUT_EXTRUDE 100 //=========================================================================== @@ -296,7 +301,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // hooke's law says: force = k * distance // bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant // so: v ^ 2 is proportional to number of steps we advance the extruder -#define ADVANCE +//#define ADVANCE #ifdef ADVANCE #define EXTRUDER_ADVANCE_K .0 @@ -315,7 +320,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers? #define SD_FINISHED_RELEASECOMMAND "M84 X Y E" // no z because of layer shift. -#define ULTIPANEL +//#define ULTIPANEL #ifdef ULTIPANEL //#define NEWPANEL //enable this if you have a click-encoder panel #define SDSUPPORT diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 0c346e1ead..a5044f8d33 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -432,6 +432,7 @@ void CardReader::updir() void CardReader::printingHasFinished() { + st_synchronize(); quickStop(); sdprinting = false; stop_heating_wait=true; diff --git a/Marlin/pins.h b/Marlin/pins.h index 4ec22793ec..6451d74250 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -555,7 +555,7 @@ #define Z_ENABLE_PIN 35 #define HEATER_BED_PIN 4 -#define TEMP_BED_PIN 11 +#define TEMP_BED_PIN 10 #define HEATER_0_PIN 2 #define TEMP_0_PIN 8 @@ -734,4 +734,4 @@ HEATER_BED_PIN, FAN_PIN, \ _E0_PINS, _E1_PINS, _E2_PINS, \ TEMP_0_PIN, TEMP_1_PIN, TEMP_2_PIN, TEMP_BED_PIN } -#endif +#endif diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index ba116c7aa3..e6c352fdff 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -42,6 +42,10 @@ //=========================================================================== int target_raw[EXTRUDERS] = { 0 }; int target_raw_bed = 0; +#ifdef BED_LIMIT_SWITCHING +int target_bed_low_temp =0; +int target_bed_high_temp =0; +#endif int current_raw[EXTRUDERS] = { 0 }; int current_raw_bed = 0; @@ -233,20 +237,39 @@ void manage_heater() previous_millis_bed_heater = millis(); #if TEMP_BED_PIN > -1 - // Check if temperature is within the correct range - if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) { - if(current_raw_bed >= target_raw_bed) - { + + #ifndef BED_LIMIT_SWITCHING + // Check if temperature is within the correct range + if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) { + if(current_raw_bed >= target_raw_bed) + { + WRITE(HEATER_BED_PIN,LOW); + } + else + { + WRITE(HEATER_BED_PIN,HIGH); + } + } + else { WRITE(HEATER_BED_PIN,LOW); } - else - { - WRITE(HEATER_BED_PIN,HIGH); + #else //#ifdef BED_LIMIT_SWITCHING + // Check if temperature is within the correct band + if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) { + if(current_raw_bed > target_bed_high_temp) + { + WRITE(HEATER_BED_PIN,LOW); + } + else + if(current_raw_bed <= target_bed_low_temp) + { + WRITE(HEATER_BED_PIN,HIGH); + } } - } - else { - WRITE(HEATER_BED_PIN,LOW); - } + else { + WRITE(HEATER_BED_PIN,LOW); + } + #endif #endif } @@ -520,6 +543,9 @@ void setWatch() void disable_heater() { + for(int i=0;i -1 target_raw[0]=0; soft_pwm[0]=0; diff --git a/Marlin/temperature.h b/Marlin/temperature.h index f8b09649f5..8e1deac8fe 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -43,6 +43,10 @@ extern int heatingtarget_raw[EXTRUDERS]; extern int current_raw[EXTRUDERS]; extern int target_raw_bed; extern int current_raw_bed; +#ifdef BED_LIMIT_SWITCHING + extern int target_bed_low_temp ; + extern int target_bed_high_temp ; +#endif extern float Kp,Ki,Kd,Kc; #ifdef PIDTEMP @@ -83,7 +87,20 @@ FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { }; FORCE_INLINE void setTargetBed(const float &celsius) { + target_raw_bed = temp2analogBed(celsius); + #ifdef BED_LIMIT_SWITCHING + if(celsius>BED_HYSTERESIS) + { + target_bed_low_temp= temp2analogBed(celsius-BED_HYSTERESIS); + target_bed_high_temp= temp2analogBed(celsius+BED_HYSTERESIS); + } + else + { + target_bed_low_temp=0; + target_bed_high_temp=0; + } + #endif }; FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ @@ -125,6 +142,13 @@ FORCE_INLINE bool isCoolingBed() { #error Invalid number of extruders #endif + + +int getHeaterPower(int heater); +void disable_heater(); +void setWatch(); +void updatePID(); + FORCE_INLINE void autotempShutdown(){ #ifdef AUTOTEMP if(autotemp_enabled) @@ -135,11 +159,5 @@ FORCE_INLINE void autotempShutdown(){ } #endif } - -int getHeaterPower(int heater); -void disable_heater(); -void setWatch(); -void updatePID(); - #endif diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index 3b7663beb9..947ec3dac9 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -165,8 +165,13 @@ void lcd_status() //previous_millis_buttons=millis(); long ms=millis(); for(int8_t i=0; i<8; i++) { + #ifndef NEWPANEL if((blocking[i]>ms)) buttons &= ~(1<ms)) + buttons &= ~(1< -1) +ItemT_bed, +#endif +ItemT_fan}; void MainMenu::showTune() { @@ -572,6 +581,42 @@ void MainMenu::showTune() lcd.setCursor(13,line);lcd.print(itostr3(encoderpos)); } }break; + #if (HEATER_BED_PIN > -1) + case ItemT_bed: + { + if(force_lcd_update) + { + lcd.setCursor(0,line);lcdprintPGM(" \002Bed:"); + lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed()))); + } + + if((activeline!=line) ) + break; + + if(CLICKED) + { + linechanging=!linechanging; + if(linechanging) + { + encoderpos=intround(degTargetBed()); + } + else + { + setTargetBed(encoderpos); + encoderpos=activeline*lcdslow; + beepshort(); + } + BLOCK; + } + if(linechanging) + { + if(encoderpos<0) encoderpos=0; + if(encoderpos>260) encoderpos=260; + lcd.setCursor(13,line);lcd.print(itostr3(encoderpos)); + } + }break; + #endif + case ItemT_fan: { @@ -677,6 +722,9 @@ enum { ItemCT_autotempactive, ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact, #endif +#if (HEATER_BED_PIN > -1) +ItemCT_bed, +#endif ItemCT_fan, ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C }; @@ -857,6 +905,41 @@ void MainMenu::showControlTemp() }break; #endif //autotemp + #if (HEATER_BED_PIN > -1) + case ItemCT_bed: + { + if(force_lcd_update) + { + lcd.setCursor(0,line);lcdprintPGM(" \002Bed:"); + lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed()))); + } + + if((activeline!=line) ) + break; + + if(CLICKED) + { + linechanging=!linechanging; + if(linechanging) + { + encoderpos=intround(degTargetBed()); + } + else + { + setTargetBed(encoderpos); + encoderpos=activeline*lcdslow; + beepshort(); + } + BLOCK; + } + if(linechanging) + { + if(encoderpos<0) encoderpos=0; + if(encoderpos>260) encoderpos=260; + lcd.setCursor(13,line);lcd.print(itostr3(encoderpos)); + } + }break; + #endif case ItemCT_fan: { if(force_lcd_update)