1

I'm configuring the internal temperature sensor of a STM32F4 MCU, and when reading the documentation, I came across some "duplicated" but divergent definitions.

Take a look in the image below:

enter image description here

The temperature sensor is connected to the ADC1, channel 16. When reading the ADC value inside my room, I always get values around ~920;

The values for the calibrations (read from MCU memory) are the following:

TS_CAL1 = 941

TS_CAL2 = 1199

It seems to me that calculating the final temperature using the relationship shown on Table 69 leads to different results from when using the relationship from Table 70.

Can anyone help me in this topic? What's the difference between the data of Tables 69 and 70? What is the purpose of each one? How to calculate the temperature correctly?

  • I’m voting to close this question because it i snot a programming issue - ask at https://electronics.stackexchange.com/ perhap? – Clifford Jun 19 '22 at 08:00
  • 2
    There is no conflict or duplication. A "characteristic" is the general shape of the response - it is "typically" linear to withing 1°C, with a "typical" gradient of 2.5mV/°C. and is true of all parts of the type. The "calibration" values define the _actual_ response for the _individual_ device. In your case you have 258 ADC levels over a 80°C span. At 3.3V 258 is about 208mV, so 208/80 = 2.6mV per °C. If you have a value ~940 that corresponds to 30°C. – Clifford Jun 19 '22 at 08:18
  • 2
    Given the sensor is on the die however, what you are measuring is the die temperature, not the ambient temperature and calibrating it to ambient may not yield the expected results if the die temperature varies with CPU load and/or peripheral activity. – Clifford Jun 19 '22 at 08:20

2 Answers2

3

As Clifford explained in the comments, the information in table 69 tells you the typical behaviour of any device from this family, whereas the pointers in table 70 give you the address of the calibration data for your particular device which were measured in the factory.

If you told me that some device of this type gave a reading of 920, I would estimate the temperature as follows:

ADC voltage = 920/4096 * 3.3V = 741mV

Voltage offset from V(25C) = 741mV - 760mV = -19mV

Temperature offset from 25C = -19/2.5 = 7.6C

Temperature = 25 - 7.6 = 17.4 degrees C

For your calibrated device I would estimate the temperature like this:

Slope = (1199 - 941) / (110 - 30)  = 3.225 LSB/degree

ADC offset from ADC(30C) = (920 - 941) = -21 LSB

Temperature offset from 30C = -21 / 3.225 = 17.775 C

Temperature = 30 - 17.775 = 12.2 degrees C

It is important to note however that although this second number is "calibrated", it is done so using calibration data from much higher temperatures. To use it below 30 degrees requires to extrapolate in a way which may not be physically valid.

Ask yourself, was the room closer to 17 degrees or 12 degrees? Bear in mind that the internal temperature sensor is probably subject to a certain amount of self-heating from the high performance processor.

If you want to use the internal temperature sensor to measure low temperatures outside the calibration range like this it might be appropriate to use the offset from the lower calibration point, but then use the typical slope from the datasheet.

Note also that many STM32 evaluation boards run at 3.0V not 3.3V, so all the calculation will have to be changed if that is the case.

Tom V
  • 4,827
  • 2
  • 5
  • 22
1

I can not see the table but in theory there are following points need to considers when working with sensor:

  • Offset: value that is different with the actual value. You may check by feed a constant voltage to system and compare with ADC value measured.
  • Error of sensor: you might need to measure at known value. For example, for temperature, it is used to measure at 0 temperature which is a steady state.
ThongDT
  • 162
  • 7