New implementation of TEMP_RESIDENCY_TIME. We now wait for the target temp to be esablished and maintained for residency time +/- a configurable hysteresis

This commit is contained in:
Alessandro Ranellucci 2011-07-26 18:17:52 +02:00
parent 3ff008c064
commit 53be78c949
2 changed files with 20 additions and 18 deletions

View file

@ -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 // 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 //#define WATCHPERIOD 5000 //5 seconds
// Wait this long after achieving target temperature on M109 before continuing with print (seconds) // Actual temperature must be close to target for this long before M109 returns success
//#define TEMP_RESIDENCY_TIME 20 //#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 //// The minimal temperature defines the temperature below which the heater will not be enabled
#define MINTEMP 5 #define MINTEMP 5

View file

@ -769,7 +769,16 @@ inline void process_commands()
} }
#endif #endif
codenum = millis(); 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. if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{ {
Serial.print("T:"); Serial.print("T:");
@ -777,23 +786,15 @@ inline void process_commands()
codenum = millis(); codenum = millis();
} }
manage_heater(); manage_heater();
} #ifdef TEMP_RESIDENCY_TIME
// wait extra time before letting the print continue /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
#ifdef TEMP_RESIDENCY_TIME or when current temp falls outside the hysteresis after target temp was reached */
{ if ( (residencyStart == -1 && current_raw >= target_raw)
long residencyStart = millis(); || (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) {
codenum = millis(); residencyStart = 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();
} }
manage_heater(); #endif
}
} }
#endif
break; break;
case 190: // M190 - Wait bed for heater to reach target. case 190: // M190 - Wait bed for heater to reach target.