Merge pull request #68 from WebSpider/experimental
Experimental adding of M109 cooldown handling
This commit is contained in:
commit
4d58a83f6f
1 changed files with 41 additions and 10 deletions
|
|
@ -798,16 +798,47 @@ inline void process_commands()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
#ifdef TEMP_RESIDENCY_TIME
|
/* See if we are heating up or cooling down */
|
||||||
long residencyStart;
|
if( current_raw < target_raw )
|
||||||
residencyStart = -1;
|
/* We are heating up */
|
||||||
/* continue to loop until we have reached the target temp
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
long residencyStart;
|
||||||
while( current_raw < target_raw
|
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) ) {
|
|| (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
||||||
#else
|
#else
|
||||||
while(current_raw < target_raw) {
|
while(current_raw < target_raw) {
|
||||||
#endif
|
#endif
|
||||||
|
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();
|
||||||
|
#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();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if( current_raw > target_raw )
|
||||||
|
/* We are cooling down */
|
||||||
|
#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:");
|
||||||
|
|
@ -818,7 +849,7 @@ inline void process_commands()
|
||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first 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 */
|
or when current temp falls outside the hysteresis after target temp was reached */
|
||||||
if ( (residencyStart == -1 && current_raw >= target_raw)
|
if ( (residencyStart == -1 && current_raw <= target_raw)
|
||||||
|| (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) {
|
|| (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) {
|
||||||
residencyStart = millis();
|
residencyStart = millis();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue