TempC = (Vtemp – 0.7013) ÷ (0.0017)
Hello BP,
This subject was extensively discussed in your thread of a couple of years ago. I suggest that you revisit that thread here. The calculations shown in my posts towards the end of the thread would still be applicable. These covered single point calibration where the calibration temperature was known, but other than 25C, and also compensation for change of Vdd.
The temperature coefficient of the sensor is negative because it is simply the voltage accross a single diode that is measured.
Regards,
Mac
Here is a sample code, not the best calibration, but gets your there....I did the calculations in millivolts...
you have to call these functions before hand:
while ( AD1_Measure(TRUE) !=ERR_OK ){;}
AD1_GetValue16(&ADC_Values);
TemperatureFunction (&tempVariable);
#define mhot 1.769
#define mcold 1.646
#define Vtemp25 701.2 //In milliVolts
double Vtemp=0; //In milliVolts
void TemperatureFunction ( double *temp)
{
Vtemp = 120 * (10*(double) ADC_Values [ ADC_TempSensor]) / (double)ADC_Values[ADC_Bandgap];
if ( Vtemp > Vtemp25 )
{
(*temp) = 25- ( (Vtemp- Vtemp25 )/mhot );
}else
{
(*temp) = 25- ( (Vtemp - Vtemp25)/mcold );
}
}