BMS_NTC28.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*********************************************************************
  2. *
  3. * NTC28 C File
  4. *
  5. *********************************************************************
  6. * FileName: NTC28.c
  7. * Processor: PIC18F45K80
  8. * Complier: Microchip C18 v3.41
  9. * Company: KIT - CN - IPE
  10. *
  11. * Author Date Comment
  12. *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. * Ott W. 01.06.2016 Release 1.
  14. *********************************************************************/
  15. #include "BMS_Slave.h"
  16. /*********************************************************************
  17. *
  18. * Globals
  19. *
  20. *********************************************************************/
  21. /* Look Up Table für NTC103JT-025-3P Temperaturbestimmung von -50°C bis +90°C in 1°K Schritten */
  22. const rom int16_t NTC_LookUp[142]= /*!e950*/
  23. {4511,4503,4496,4488,4479,4470,4461,4452,4441,4431,
  24. 4420,4408,4396,4383,4370,4356,4342,4327,4311,4295,
  25. 4278,4261,4242,4223,4204,4183,4162,4140,4118,4095,
  26. 4071,4046,4020,3993,3965,3937,3908,3878,3847,3816,
  27. 3784,3751,3717,3682,3647,3611,3574,3537,3499,3461,
  28. 3422,3382,3341,3300,3259,3217,3175,3132,3090,3046,
  29. 3002,2959,2914,2870,2825,2781,2736,2691,2647,2603,
  30. 2558,2513,2469,2425,2381,2337,2293,2250,2206,2164,
  31. 2121,2079,2037,1996,1955,1914,1875,1835,1796,1758,
  32. 1720,1683,1646,1610,1574,1539,1505,1471,1438,1405,
  33. 1373,1342,1311,1280,1250,1221,1193,1165,1137,1110,
  34. 1084,1059,1034,1009,985,962,939,916,895,873,
  35. 853,832,812,793,774,756,738,720,703,686,
  36. 670,654,638,623,608,594,580,566,553,539,
  37. 527,515};
  38. /*********************************************************************
  39. * Function: int8_t LTC_CONV_UMESS_2_TEMP( int16_t Umess )
  40. *
  41. * Overview: Use this function to convert Umess 2 Temperature
  42. * for Temperature Sensor 103JT-025-3P
  43. *
  44. * PreCondition: None
  45. *
  46. * Input: Voltage [mV] [0..5000mV]
  47. *
  48. * Output: Temperature [°C] [-50°C..+90°C]
  49. * -51°C = Underflow; +91°C = Overflow
  50. *
  51. * Side Effects: None
  52. **********************************************************************/
  53. int8_t LTC_CONV_UMESS_2_TEMP( int16_t Umess )
  54. {
  55. int8_t Temp = -51;
  56. uint8_t i = 0;
  57. if(Umess < 516) /* OverFlow (>90°C) */
  58. {
  59. Temp = 91; /* Break Search */
  60. }
  61. else
  62. {
  63. while((NTC_LookUp[i] >= Umess))
  64. {
  65. i++;
  66. Temp++;
  67. }
  68. }
  69. return Temp;
  70. }