cancel
Showing results for 
Search instead for 
Did you mean: 

Converting temperature

alexcarrillo
Associate II
Posted on June 23, 2008 at 11:25

Converting temperature

4 REPLIES 4
alexcarrillo
Associate II
Posted on May 17, 2011 at 12:37

I'm using the temperature sensor in my SMT32f103. It is configured in the following way:

Quote:

// ADC1 configuration

ADC_DeInit(ADC1);

ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;

ADC_InitStructure.ADC_ScanConvMode = ENABLE;

ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;

ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;

ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

ADC_InitStructure.ADC_NbrOfChannel = 1;

ADC_Init(ADC1, &ADC_InitStructure);

// ADC1 regular channels configuration

// Micro internal temperature sensor

ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_239Cycles5);

It looks seems properly (aparently) and I get values from the ADC about 1715. When I convert this value to celsius I obtain 36C that is too much even for the processor temperature.

I use the formula and the values from the datasheet. Those values are:

Avg_slope = 4.3 mV/C

V_25 = 1.4 V

V_ref = Vdda = 3.3V

Are those values right? How could I get real values?

Thanks.

obtronix
Associate II
Posted on May 17, 2011 at 12:37

temp C = (1.4 - 1715/2^12*3.3)/.0043 + 25

= 0.01828/.0043 + 25

= 4.25 + 25

= 29.25 C +/- 1.5 deg C

sounds about right

obtronix
Associate II
Posted on May 17, 2011 at 12:37

Your right it is a very wide range

V25 Avg_Slope Deg C

1.34 0.004 14.5715332

1.43 0.0043 36.22933321

1.52 0.0046 55.06220279

looks like the part to part variation is very high, but once calibrated, it's +/- 2deg.

I guess you need to calibrate each part, power up and quickly take a reading at room temp (before it heats up), it should be 21 deg (or whatever your room temperature is). Compute a bias, store it in FLASH, and add that to any future reading and you should be ok.

alexcarrillo
Associate II
Posted on May 17, 2011 at 12:37

My value for V25 is 1.43. In the manual the value is between 1.34 and 1.52 but very small variations of this value imply big variations in the result. How could I get a better calibration of this value?