am32-firmware / AM32

GNU General Public License v3.0
175 stars 37 forks source link

The temperature algorithm with ARTERY mcu maybe wrong #9

Open ymzcdg opened 4 months ago

ymzcdg commented 4 months ago

In "main.c", when my mcu is from ARTERY, the function to calc temp is "getConvertedDegrees() in ADC.c".In datasheet of AT32F421 ,the algorithm is "temp(°C) = {(V25 – VTS) / Avg_Slope} + 25"and Typ_Avg_Slope = -4.3mV, V25=1.28mV. So if my mcu is AT32F421K8U7,I will use "(12800 - (int32_t)adcrawtemp * 33000 / 4096) / -43 + 25;" to calc temperature inside mcu. Please answer my doubts, thanks.

DJ-URAN commented 4 months ago

4096? Are you sure? Maybe, 4095?

ymzcdg commented 4 months ago

4096? Are you sure? Maybe, 4095?

In ”Mcu/f421/Src/ADC.c“ it's 4096. Maybe 4096 is the correct value, so I did not change it. I think 4095 is correct value in math ,but in computer, calculate /4096 is faster then /4095 (/4096 can use bit shift not division), and the error is very small.

AlkaMotors commented 4 months ago

It doesn't really matter anyway since the temperature sensors are not calibrated like stm32. Many vendors use a external ntc for artery mcus.

ymzcdg commented 4 months ago

It doesn't really matter anyway since the temperature sensors are not calibrated like stm32. Many vendors use a external ntc for artery mcus.

I want design a hardware, what type of sensor does your formula correspond to?My NTC sensor calculation formulas all have logarithmic functions, but your formula does not have logarithmic functions.I think the sensor corresponding to your formula is easy to use, and I would like to know its model. Thanks.