ntc.c 445 B

12345678910111213141516171819202122232425
  1. #include "ntc.h"
  2. u32 NTC_ADC_VALUE_SUM = 0;
  3. float Get_Temperature(u16 ADC_VALUE)
  4. {
  5. float Rp = 10000.0; //分压电阻
  6. float Rn = 10000.0; //在TN常温下的标称阻值
  7. float T2 = (273.15 + 25.0); //开尔文温度,K度=273.15(绝对温度)+摄氏度
  8. float Bx = 3950.0;
  9. float Rt = 0.0;
  10. float valta = 0.0;
  11. valta = (float)ADC_VALUE*3.3/4095;
  12. Rt = (Rp*valta)/(3.3-valta);
  13. return (1/( log(Rt/Rn)/Bx+ (1/T2) )) - 273.15;//272.65
  14. }