summaryrefslogtreecommitdiff
path: root/Sprinter/Sprinter.pde
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2011-07-26 18:17:52 +0200
committerAlessandro Ranellucci <aar@cpan.org>2011-07-26 18:17:52 +0200
commit53be78c9496f3fa2df191fb7dc621affdb2e1dc1 (patch)
tree1f744680f804fd71ce295df0f5ee06945f73ccd9 /Sprinter/Sprinter.pde
parent3ff008c064bd112352138dae0b44db7d50458685 (diff)
New implementation of TEMP_RESIDENCY_TIME. We now wait for the target temp to be esablished and maintained for residency time +/- a configurable hysteresis
Diffstat (limited to 'Sprinter/Sprinter.pde')
-rw-r--r--Sprinter/Sprinter.pde33
1 files changed, 17 insertions, 16 deletions
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.