ntc_sensor.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /**
  2. * @file ntc_sensor.c
  3. * @author zhouxiong(wangzy49@midea.com)
  4. * @brief
  5. * @version 0.1
  6. * @date 2021-10-08
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. /************************************************************************
  12. Beginning of File, do not put anything above here except notes
  13. Compiler Directives:
  14. *************************************************************************/
  15. #include "ntc_sensor.h"
  16. /******************************
  17. *
  18. * Parameter
  19. *
  20. ******************************/
  21. //PCB温度传感器寄存器与温度对照表,-40~140摄氏度
  22. const UWORD NTC_Table_PCB[181] =
  23. {
  24. 99,
  25. 107,
  26. 114,
  27. 123,
  28. 131,
  29. 140,
  30. 150,
  31. 160,
  32. 171,
  33. 183,
  34. 195,
  35. 208,
  36. 221,
  37. 235,
  38. 250,
  39. 265,
  40. 282,
  41. 299,
  42. 317,
  43. 335,
  44. 355,
  45. 375,
  46. 397,
  47. 419,
  48. 442,
  49. 466,
  50. 491,
  51. 517,
  52. 544,
  53. 571,
  54. 600,
  55. 630,
  56. 660,
  57. 692,
  58. 724,
  59. 758,
  60. 792,
  61. 828,
  62. 864,
  63. 901,
  64. 939,
  65. 977,
  66. 1017,
  67. 1057,
  68. 1098,
  69. 1140,
  70. 1182,
  71. 1225,
  72. 1269,
  73. 1313,
  74. 1357,
  75. 1402,
  76. 1447,
  77. 1493,
  78. 1539,
  79. 1585,
  80. 1631,
  81. 1678,
  82. 1724,
  83. 1771,
  84. 1817,
  85. 1864,
  86. 1910,
  87. 1956,
  88. 2002,
  89. 2048,
  90. 2093,
  91. 2138,
  92. 2182,
  93. 2227,
  94. 2270,
  95. 2314,
  96. 2356,
  97. 2398,
  98. 2440,
  99. 2481,
  100. 2521,
  101. 2561,
  102. 2600,
  103. 2639,
  104. 2676,
  105. 2713,
  106. 2749,
  107. 2785,
  108. 2820,
  109. 2854,
  110. 2887,
  111. 2920,
  112. 2952,
  113. 2983,
  114. 3014,
  115. 3043,
  116. 3072,
  117. 3101,
  118. 3128,
  119. 3155,
  120. 3181,
  121. 3207,
  122. 3232,
  123. 3256,
  124. 3280,
  125. 3303,
  126. 3325,
  127. 3347,
  128. 3368,
  129. 3388,
  130. 3408,
  131. 3427,
  132. 3446,
  133. 3464,
  134. 3482,
  135. 3499,
  136. 3516,
  137. 3532,
  138. 3548,
  139. 3563,
  140. 3578,
  141. 3593,
  142. 3607,
  143. 3620,
  144. 3633,
  145. 3646,
  146. 3659,
  147. 3671,
  148. 3682,
  149. 3694,
  150. 3705,
  151. 3715,
  152. 3726,
  153. 3736,
  154. 3745,
  155. 3755,
  156. 3764,
  157. 3773,
  158. 3781,
  159. 3790,
  160. 3798,
  161. 3806,
  162. 3813,
  163. 3821,
  164. 3828,
  165. 3835,
  166. 3842,
  167. 3848,
  168. 3855,
  169. 3861,
  170. 3867,
  171. 3873,
  172. 3878,
  173. 3884,
  174. 3889,
  175. 3894,
  176. 3899,
  177. 3904,
  178. 3909,
  179. 3914,
  180. 3918,
  181. 3922,
  182. 3927,
  183. 3931,
  184. 3935,
  185. 3939,
  186. 3942,
  187. 3946,
  188. 3950,
  189. 3953,
  190. 3957,
  191. 3960,
  192. 3963,
  193. 3966,
  194. 3969,
  195. 3972,
  196. 3975,
  197. 3978,
  198. 3980,
  199. 3983,
  200. 3985,
  201. 3988,
  202. 3990,
  203. 3993,
  204. 3995
  205. };
  206. //力矩温度传感器寄存器与温度对照表,-40~140摄氏度
  207. const UWORD NTC_Table_Torque[181] =
  208. {
  209. 3996,
  210. 3988,
  211. 3981,
  212. 3972,
  213. 3964,
  214. 3955,
  215. 3945,
  216. 3935,
  217. 3924,
  218. 3912,
  219. 3900,
  220. 3887,
  221. 3874,
  222. 3860,
  223. 3845,
  224. 3830,
  225. 3813,
  226. 3796,
  227. 3778,
  228. 3760,
  229. 3740,
  230. 3720,
  231. 3698,
  232. 3676,
  233. 3653,
  234. 3629,
  235. 3604,
  236. 3578,
  237. 3551,
  238. 3524,
  239. 3495,
  240. 3465,
  241. 3435,
  242. 3403,
  243. 3371,
  244. 3337,
  245. 3303,
  246. 3267,
  247. 3231,
  248. 3194,
  249. 3156,
  250. 3118,
  251. 3078,
  252. 3038,
  253. 2997,
  254. 2955,
  255. 2913,
  256. 2870,
  257. 2826,
  258. 2782,
  259. 2738,
  260. 2693,
  261. 2648,
  262. 2602,
  263. 2556,
  264. 2510,
  265. 2464,
  266. 2417,
  267. 2371,
  268. 2324,
  269. 2278,
  270. 2231,
  271. 2185,
  272. 2139,
  273. 2093,
  274. 2048,
  275. 2002,
  276. 1957,
  277. 1913,
  278. 1868,
  279. 1825,
  280. 1781,
  281. 1739,
  282. 1697,
  283. 1655,
  284. 1614,
  285. 1574,
  286. 1534,
  287. 1495,
  288. 1456,
  289. 1419,
  290. 1382,
  291. 1346,
  292. 1310,
  293. 1275,
  294. 1241,
  295. 1208,
  296. 1175,
  297. 1143,
  298. 1112,
  299. 1081,
  300. 1052,
  301. 1023,
  302. 994,
  303. 967,
  304. 940,
  305. 914,
  306. 888,
  307. 863,
  308. 839,
  309. 815,
  310. 792,
  311. 770,
  312. 748,
  313. 727,
  314. 707,
  315. 687,
  316. 668,
  317. 649,
  318. 631,
  319. 613,
  320. 596,
  321. 579,
  322. 563,
  323. 547,
  324. 532,
  325. 517,
  326. 502,
  327. 488,
  328. 475,
  329. 462,
  330. 449,
  331. 436,
  332. 424,
  333. 413,
  334. 401,
  335. 390,
  336. 380,
  337. 369,
  338. 359,
  339. 350,
  340. 340,
  341. 331,
  342. 322,
  343. 314,
  344. 305,
  345. 297,
  346. 289,
  347. 282,
  348. 274,
  349. 267,
  350. 260,
  351. 253,
  352. 247,
  353. 240,
  354. 234,
  355. 228,
  356. 222,
  357. 217,
  358. 211,
  359. 206,
  360. 201,
  361. 196,
  362. 191,
  363. 186,
  364. 181,
  365. 177,
  366. 173,
  367. 168,
  368. 164,
  369. 160,
  370. 156,
  371. 153,
  372. 149,
  373. 145,
  374. 142,
  375. 138,
  376. 135,
  377. 132,
  378. 129,
  379. 126,
  380. 123,
  381. 120,
  382. 117,
  383. 115,
  384. 112,
  385. 110,
  386. 107,
  387. 105,
  388. 102,
  389. 100
  390. };
  391. /***************************************************************
  392. Function: Get PCB Temp
  393. Description:
  394. Call by:
  395. Input Variables: N/A
  396. Output/Return Variables: N/A
  397. Subroutine Call: N/A;
  398. Reference: N/A
  399. ****************************************************************/
  400. SWORD GetPCBTemp(UWORD ADC_Result)
  401. {
  402. UBYTE Count;
  403. for(Count=0; Count<181; Count++)
  404. {
  405. if(ADC_Result <= NTC_Table_PCB[Count])
  406. {
  407. return (SWORD)(Count - 40);
  408. }
  409. }
  410. return -40;
  411. }
  412. /***************************************************************
  413. Function: Get Torque Temp
  414. Description:
  415. Call by:
  416. Input Variables: N/A
  417. Output/Return Variables: N/A
  418. Subroutine Call: N/A;
  419. Reference: N/A
  420. ****************************************************************/
  421. SWORD GetTorqueTemp(UWORD ADC_Result)
  422. {
  423. UBYTE Count;
  424. for(Count=0; Count<181; Count++)
  425. {
  426. if(ADC_Result >= NTC_Table_Torque[Count])
  427. {
  428. return (SWORD)(Count - 40);
  429. }
  430. }
  431. return -40;
  432. }
  433. /*************************************************************************
  434. End of this File (EOF)!
  435. Do not put anything after this part!
  436. *************************************************************************/