M109 now equal to sprinter
This commit is contained in:
parent
bf879ceaa9
commit
95d3d9847c
2 changed files with 52 additions and 23 deletions
|
@ -146,9 +146,16 @@ const int dropsegments=5; //everything with this number of steps will be ignore
|
||||||
#define WATCHDOG_TIMEOUT 4
|
#define WATCHDOG_TIMEOUT 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//// Experimental watchdog and minimal temp
|
||||||
|
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||||
// 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
|
||||||
|
|
||||||
|
// 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
|
//// The minimal temperature defines the temperature below which the heater will not be enabled
|
||||||
#define MINTEMP 5
|
#define MINTEMP 5
|
||||||
#define BED_MINTEMP 5
|
#define BED_MINTEMP 5
|
||||||
|
|
|
@ -780,7 +780,7 @@ inline void process_commands()
|
||||||
#ifdef WATCHPERIOD
|
#ifdef WATCHPERIOD
|
||||||
if(target_raw[0] > current_raw[0]){
|
if(target_raw[0] > current_raw[0]){
|
||||||
watchmillis = max(1,millis());
|
watchmillis = max(1,millis());
|
||||||
watch_raw[0] = current_raw[0];
|
watch_raw = current_raw[0];
|
||||||
}else{
|
}else{
|
||||||
watchmillis = 0;
|
watchmillis = 0;
|
||||||
}
|
}
|
||||||
|
@ -820,32 +820,54 @@ inline void process_commands()
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
//break;
|
//break;
|
||||||
case 109: // M109 - Wait for extruder heater to reach target.
|
case 109: {// M109 - Wait for extruder heater to reach target.
|
||||||
LCD_MESSAGE("Heating...");
|
LCD_MESSAGE("Heating...");
|
||||||
if (code_seen('S')) target_raw[0] = temp2analog(code_value());
|
if (code_seen('S')) target_raw[0] = temp2analog(code_value());
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
pid_setpoint = code_value();
|
pid_setpoint = code_value();
|
||||||
#endif //PIDTEM
|
#endif //PIDTEM
|
||||||
#ifdef WATCHPERIOD
|
#ifdef WATCHPERIOD
|
||||||
if(target_raw[0]>current_raw[0]){
|
if(target_raw[0]>current_raw[0]) {
|
||||||
watchmillis = max(1,millis());
|
watchmillis = max(1,millis());
|
||||||
watch_raw[0] = current_raw[0];
|
watch_raw = current_raw[0];
|
||||||
}else{
|
} else {
|
||||||
watchmillis = 0;
|
watchmillis = 0;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
codenum = millis();
|
|
||||||
starttime=millis();
|
|
||||||
while(current_raw[0] < target_raw[0]) {
|
|
||||||
if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up.
|
|
||||||
Serial.print("T:");
|
|
||||||
Serial.println( analog2temp(current_raw[0]) );
|
|
||||||
codenum = millis();
|
|
||||||
}
|
}
|
||||||
LCD_STATUS;
|
#endif //WATCHPERIOD
|
||||||
manage_heater();
|
codenum = millis();
|
||||||
|
|
||||||
|
/* See if we are heating up or cooling down */
|
||||||
|
bool target_direction = (current_raw[0] < target_raw[0]); // true if heating, false if cooling
|
||||||
|
|
||||||
|
#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((target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0])) ||
|
||||||
|
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
||||||
|
#else
|
||||||
|
while ( target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0]) ) {
|
||||||
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
|
if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
|
||||||
|
Serial.print("T:");
|
||||||
|
Serial.println( analog2temp(current_raw[0]) );
|
||||||
|
codenum = millis();
|
||||||
|
}
|
||||||
|
manage_heater();
|
||||||
|
LCD_STATUS;
|
||||||
|
#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 && target_direction && current_raw[0] >= target_raw[0]) ||
|
||||||
|
(residencyStart == -1 && !target_direction && current_raw[0] <= target_raw[0]) ||
|
||||||
|
(residencyStart > -1 && labs(analog2temp(current_raw[0]) - analog2temp(target_raw[0])) > TEMP_HYSTERESIS) ) {
|
||||||
|
residencyStart = millis();
|
||||||
|
}
|
||||||
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
|
}
|
||||||
|
LCD_MESSAGE("Marlin ready.");
|
||||||
}
|
}
|
||||||
LCD_MESSAGE("UltiMarlin ready.");
|
|
||||||
break;
|
break;
|
||||||
case 190: // M190 - Wait bed for heater to reach target.
|
case 190: // M190 - Wait bed for heater to reach target.
|
||||||
#if TEMP_1_PIN > -1
|
#if TEMP_1_PIN > -1
|
||||||
|
|
Reference in a new issue