summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sprinter/Configuration.h5
-rw-r--r--Sprinter/Sprinter.pde33
2 files changed, 20 insertions, 18 deletions
diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h
index 3073393..1798642 100644
--- a/Sprinter/Configuration.h
+++ b/Sprinter/Configuration.h
@@ -143,8 +143,9 @@ char uuid[] = "00000000-0000-0000-0000-000000000000";
// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
//#define WATCHPERIOD 5000 //5 seconds
-// Wait this long after achieving target temperature on M109 before continuing with print (seconds)
-//#define TEMP_RESIDENCY_TIME 20
+// Actual temperature must be close to target for this long before M109 returns success
+//#define TEMP_RESIDENCY_TIME 20 // (seconds)
+//#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
//// The minimal temperature defines the temperature below which the heater will not be enabled
#define MINTEMP 5
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde
index 801f103..4b93c0e 100644
--- a/Sprinter/Sprinter.pde
+++ b/Sprinter/Sprinter.pde
@@ -769,7 +769,16 @@ inline void process_commands()
}
#endif
codenum = millis();
- while(current_raw < target_raw) {
+ #ifdef TEMP_RESIDENCY_TIME
+ long residencyStart;
+ residencyStart = -1;
+ /* continue to loop until we have reached the target temp
+ _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
+ while( current_raw < target_raw
+ || (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
+ #else
+ while(current_raw < target_raw) {
+ #endif
if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
Serial.print("T:");
@@ -777,23 +786,15 @@ inline void process_commands()
codenum = millis();
}
manage_heater();
- }
- // wait extra time before letting the print continue
- #ifdef TEMP_RESIDENCY_TIME
- {
- long residencyStart = millis();
- codenum = millis();
- while(millis()-residencyStart<(TEMP_RESIDENCY_TIME*1000)) {
- if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
- {
- Serial.print("T:");
- Serial.println( analog2temp(current_raw) );
- codenum = millis();
+ #ifdef TEMP_RESIDENCY_TIME
+ /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
+ or when current temp falls outside the hysteresis after target temp was reached */
+ if ( (residencyStart == -1 && current_raw >= target_raw)
+ || (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) {
+ residencyStart = millis();
}
- manage_heater();
- }
+ #endif
}
- #endif
break;
case 190: // M190 - Wait bed for heater to reach target.