ntc.c 883 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 T2 = (273.15 + 25.0);
  7. float Bx = 3950.0;
  8. //float Ka = 273.15;
  9. float Rt = 0.0;
  10. float valta = 0.0;
  11. float R = 10000.0;
  12. float Tmotor = 0.0;
  13. valta = ADC_VALUE*3.3/4095;
  14. Rt = (R*valta)/(3.3-valta);
  15. if(Rt>32116){
  16. Tmotor = 0;
  17. }
  18. else if(Rt>15652){
  19. Tmotor = -0.901*Rt/1000 + 28.381;
  20. }else if(Rt>6523){
  21. Tmotor = -2.5013*Rt/1000 + 50.657;
  22. }else if(Rt>2968){
  23. Tmotor = -6.3342*Rt/1000 + 73.203;
  24. }else if(Rt>1228){
  25. Tmotor = -16.002*Rt/1000 + 98.576;
  26. }else if(Rt > 657){
  27. Tmotor = -38.551*Rt/1000 + 124.83;
  28. }else if(Rt > 324){
  29. Tmotor = -81.812*Rt/1000 + 150.67;
  30. }else{
  31. Tmotor = 125;
  32. }
  33. return Tmotor;
  34. //return (1/( ( log(Rt/Rp) )/Bx+ (1/T2) )) - 272.65;
  35. }