-
Notifications
You must be signed in to change notification settings - Fork 326
Description
I had some trouble with prints failing because the temperature was dropping. I guess it is caused by a bad temperature reading, triggering this code in Sprinter.pde:
#ifdef MINTEMP
if(current_raw <= minttemp)
target_raw=0;
#endif
If instead of setting the target_raw to 0 the heater_pin can be set low, so if the next reading of the temperature sensor is ok the printer keeps on managing the heater.
I changed Sprinter.pde by moving #ifdef MINTEMP to where the heater pin is managed:
if (TEMP_0_PIN > -1) || defined (HEATER_USES_MAX6675) || defined (HEATER_USES_AD595)
#ifdef PIDTEMP
error = target_raw - current_raw;
pTerm = (PID_PGAIN * error) / 100;
temp_iState += error;
temp_iState = constrain(temp_iState, temp_iState_min, temp_iState_max);
iTerm = (PID_IGAIN * temp_iState) / 100;
dTerm = (PID_DGAIN * (current_raw - temp_dState)) / 100;
temp_dState = current_raw;
analogWrite(HEATER_0_PIN, constrain(pTerm + iTerm - dTerm, 0, PID_MAX));
#else
if(current_raw >= target_raw)
{
WRITE(HEATER_0_PIN,LOW);
#if LED_PIN>-1
WRITE(LED_PIN,LOW);
#endif
}
else
{
WRITE(HEATER_0_PIN,HIGH);
#if LED_PIN > -1
WRITE(LED_PIN,HIGH);
#endif
}
// ----------------------------------------------------
// if bad temp reading turn heater off for now
//--
#ifdef MINTEMP
if(current_raw <= minttemp) {
WRITE(HEATER_0_PIN,LOW);
#if LED_PIN>-1
WRITE(LED_PIN,LOW);
#endif
}
#endif
//---------------------------------
#endif
Thanks,
Frank