Hello everybody,
I am trying to read the temperature of the CPU core,but i am getting some weird readings.
Here's the code:
float K60_temp()
{
float data = 0.0;
float V_temp = 0;
float V_temp_25 = 0;
float slope_m = 0;
temp_uc_adc3_StartSingleMeasurement(core_temp);
while (!temp_uc_adc3_GetMeasurementCompleteStatus(core_temp)) {}; /* Wait for conversion completeness */
temp_uc_adc3_GetMeasuredValues(core_temp, (LDD_TData *) (&cpu_temp_adc_count)); /* Read measured values */
V_temp = 0.100708*cpu_temp_adc_count;//(3300/32768)*cpu_temp_adc_count;
V_temp_25 = 716.00;//mV
slope_m = 1.62;//or 1/m = 0.61728mV
data = (float)((float)(V_temp - V_temp_25)*0.61728)/10;
return data;
}
When i increase the core temp(using a hot air gun),the temperature decreases!!
Isn't it supposed to happen the other way around?
Kindly help,
Arun
Solved! Go to Solution.
I think your 'data' needs to be 25.0 minus the rest you show (except NOT a /10??) -- the calculation you show does give you the DIFFERENCE to the calibrated results at 25C.
I am also a little confused as to where you got your /32768 divisor in ADC calculation -- seems to me I would expect a 16-bit 'full scale' span, so each LSB (from 3.3V) is 3300/65536mV.
See also:
I think your 'data' needs to be 25.0 minus the rest you show (except NOT a /10??) -- the calculation you show does give you the DIFFERENCE to the calibrated results at 25C.
I am also a little confused as to where you got your /32768 divisor in ADC calculation -- seems to me I would expect a 16-bit 'full scale' span, so each LSB (from 3.3V) is 3300/65536mV.
See also:
Thanks for the reply Earl,i did the calculation thinking the adc is a 15 bit adc(2^15 = 32768),i corrected it now,the mentioned link helped a lot.
It is showing correct readings now.
Here's the function:
float uc_temp()
{
float V_temp = 0;
float V_temp_25 = 0.719;
float slope_m = 0.00162; //1/m = 617.283
temp_uc_adc3_StartSingleMeasurement(core_temp);
while (!temp_uc_adc3_GetMeasurementCompleteStatus(core_temp)) {}; /* Wait for conversion completeness */
temp_uc_adc3_GetMeasuredValues(core_temp, (LDD_TData *) (&cpu_temp_adc_count)); /* Read measured values */
//convert count to volts
V_temp = (3.3/65536) * cpu_temp_adc_count;
//temp at 25c in volts
//V_temp_25 = 0.719;
//slope in volts
//slope_m = 0.00175;
//return 25 - ((V_temp - V_temp_25)/slope_m);
return 25 - ((V_temp - V_temp_25)*617.28F);
}