3

I'm using STM32F401RE Nucleo board to measure the ambient temperature. After the sampling process, I receive a digital value from ADC_CHANNEL_TEMPERATURE and I want to convert this digital value into C°. I searched on the internet for this and I found two different methods:

Method 1: Page 226 in http://www.st.com/content/ccc/resource/technical/document

Temp(degree) = (V_sense - V_25)/Avg_slope + 25

Method 2: Page 251 in http://www.st.com/content/ccc/resource/technical/document

Temp(degree) = ( ( (110 - 30)*(TS_DATA - TS_CAL1) ) / (TS_CAL_2 - TS_CAL_1) ) + 30
Where:
    - TS_CAL2: temperature sensor calibration value at 110 C°
    - TS_CAL1: temperature sensor calibration value at 30 C°
    - TS_DATA: temperature sensor output from ADC

It confuses me which one is the correct formula for calculating the temperature in C°. Although Method 1 is from reference manual of STM32F401, the temperature result doesn't look correctly. While Method 2 from reference manual of STM32F0 series, it looks more reasonable.

Still I don't know which formula should I apply when using STM32F401RE Nucleo board?

BL_
  • 821
  • 1
  • 17
  • 23
  • Out of curiosity, what do you measure with the two methods and what do you use as reference temperature? – Bence Kaulics Feb 01 '17 at 08:40
  • The second equation is incorrect, it is either should be "80" or "110 - 30". – Bence Kaulics Feb 01 '17 at 11:49
  • Hi, there was a typo in the second equation (corrected now). I have an oven where I can control the temperature. I used room temperature (20oC), -10oC, 60oC as reference temperatures. The results I got from equation 2 are more reasonable to the reference temperatures. – BL_ Feb 02 '17 at 07:30

2 Answers2

4

Method 1 Temp(degree) = (V_sense - V_25)/Avg_slope + 25 is a simplified version where calibration is presumably done by pre-measuring the value at 25° and assigning it to V_25. In this context, Avg_slope is probably taken from datasheet - but it could be also a result of some calibration.

Method 2 Temp(degree) = ( ( (110 - 30)*(TS_DATA - TS_CAL1) ) / (TS_CAL_2 - TS_CAL_1) ) + 30 uses TWO calibration points, at 30° and 110°, and is more correct. Note that also method 1 can use two calibration points (used to calculate average slope). Also, method 2 would let you to take your calibration points anywhere (presumably, in the range where you are more interested in).

Both the methods, however, suffer from non-linearity (if any) of the sensor. I suppose that some non-linearity is present, because method 1 tells about "average slope". If you want greater precision, you can take several calibration points and interpolate between them.

  • Thanks @linuxfan, now I get a better understanding in the calculation of temperature sensor. – BL_ Feb 02 '17 at 09:19
  • 1
    @bienle You're welcome. As said in the help of this site, you should accept the answer instead of thanking... :-) – linuxfan says Reinstate Monica Feb 02 '17 at 09:57
  • 2
    @bienle, there is important note. STM32F0xx ships with calibrated temp sensors: each MCU have TS_CAL1 & TS_CAL2 values, stored at fixed addresses at flash memory. With this MCU you needed only read value from ADC, read values from flash and calculate exact temperature. Your MCU has no calibration, so you need do it before common use. – Alexey Esaulenko Feb 02 '17 at 15:30
-1

i am currently using the microcontroller stm32 f030 c8t6 :question:Is TS_DATA=(ADC Value)*(Vdd/Vref) or TS_DATA=(ADC Value) the temperature sensor adc value when the temperature sensor channel is activated ??

nithin
  • 1