Make disconnected thermistor show temp as absolute zero again
In a previous commit I changed the temperature calculation to give more accurate readings at extreme values. This change meant that a disconnected thermistor no longer shows as absolute zero. Coupled with the change in thermistor beta value, this meant that a disconnected extruder thermistor would show as -28.2C, which is above the usual error threshold of -30C. This commit introduces a special case for a disconnected thermistor and restores the reading to absolute zero for that case.
This commit is contained in:
parent
618304c021
commit
82e23d4774
1 changed files with 9 additions and 3 deletions
12
Platform.cpp
12
Platform.cpp
|
@ -334,9 +334,15 @@ void Platform::ClassReport(char* className, float &lastTime)
|
|||
|
||||
float Platform::GetTemperature(int8_t heater)
|
||||
{
|
||||
// If the ADC reading is N then for an ideal ADC, the input voltage is at least N/(ADC_RANGE + 1) and less than (N + 1)/(ADC_RANGE + 1), times the analog reference.
|
||||
// So we add 0.5 to to the reading to get a better estimate of the input. We don't care whether or not we get exactly zero with the thermistor disconnected.
|
||||
float r = (float)GetRawTemperature(heater) + 0.5;
|
||||
// If the ADC reading is N then for an ideal ADC, the input voltage is at least N/(AD_RANGE + 1) and less than (N + 1)/(AD_RANGE + 1), times the analog reference.
|
||||
// So we add 0.5 to to the reading to get a better estimate of the input. But first, recognise the special case of thermistor disconnected.
|
||||
int rawTemp = GetRawTemperature(heater);
|
||||
if (rawTemp == AD_RANGE)
|
||||
{
|
||||
// Thermistor is disconnected
|
||||
return ABS_ZERO;
|
||||
}
|
||||
float r = (float)rawTemp + 0.5;
|
||||
return ABS_ZERO + thermistorBetas[heater]/log( (r*thermistorSeriesRs[heater]/((AD_RANGE + 1) - r))/thermistorInfRs[heater] );
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue