采用的是深圳市敏创电子的25℃下的温感阻值为100k:NTC 100K B值3950 R/
每个型号和每个公司的的相同类型阻值表都不一样
使用的是12位ADC 4096采集。本文只写原理,和处理程序。采集程序只需要例程测试。
由硬件可以知道:通过串联分压测量R88的电压就是温感电压:当前温度的电压分度=中心值/(中心值+串联电阻)*3300mv*(4096/3300mv)。如下红色就是计算出来的
使用查表法,并且数据用表先处理好。1、可以减少ARM的运算量,提高实时效率。2、设计工程比较大,可以节省单片机内存。因为NTC本身是热敏电阻电阻误差大,所以温度误差控制在1摄氏度比较准确。
如下表就是不同温度下的温感阻值表。温度Temp、阻值中心值Rnor、阻值最大值Rmax、阻值最小值Rmin。
深圳市敏创电子有限公司 | |||||||
深圳 | 中心值 | 电压在3300 | 用的数据 | ||||
Temp. | Rmax | Rnor | Rmin | 中心值Ω | 串联电阻欧姆 | 中心值/(中心值+串联电阻)*3300mv*(4096/3300mv) | 去掉小数点 |
(deg. C) | (k Ohms) | (k Ohms) | (k Ohms) | ||||
-30 | 1858.6927 | 1787.9797 | 1719.7849 | 17879797 | 100000 | 4073.218875 | 4073 |
-29 | 1744.937 | 1679.6017 | 1616.551 | 16796017 | 4071.7576 | 4072 | |
-28 | 1638.8912 | 1578.5061 | 1520.194 | 15785061 | 4070.214767 | 4070 | |
-27 | 1539.9847 | 1484.1584 | 1430.2129 | 14841584 | 4068.586574 | 4069 | |
-26 | 1447.6929 | 1396.0662 | 1346.1459 | 13960662 | 4066.869081 | 4067 | |
-25 | 1361.5315 | 1313.7754 | 1267.5675 | 13137754 | 4065.058195 | 4065 | |
-24 | 1281.056 | 1236.8685 | 1194.0856 | 12368685 | 4063.149703 | 4063 | |
-23 | 1205.8561 | 1164.9598 | 1125.3381 | 11649598 | 4061.139233 | 4061 | |
-22 | 1135.5532 | 1097.6941 | 1060.9911 | 10976941 | 4059.022282 | 4059 | |
-21 | 1069.7992 | 1034.7432 | 1000.7358 | 10347432 | 4056.794193 | 4057 | |
-20 | 1008.2715 | 975.8038 | 944.2871 | 9758038 | 4054.45015 | 4054 | |
-19 | 950.6732 | 920.5962 | 891.3817 | 9205962 | 4051.985206 | 4052 | |
-18 | 896.7294 | 868.8615 | 841.7754 | 8688615 | 4049.394249 | 4049 | |
-17 | 846.1864 | 820.3603 | 795.2428 | 8203603 | 4046.672016 | 4047 | |
-16 | 798.8093 | 774.871 | 751.575 | 7748710 | 4043.81308 | 4044 | |
-15 | 754.381 | 732.1889 | 710.5786 | 7321889 | 4040.811894 | 4041 | |
-14 | 712.7005 | 692.1238 | 672.0741 | 6921238 | 4037.66271 | 4038 | |
-13 | 673.5814 | 654.4999 | 635.8954 | 6544999 | 4034.35966 | 4034 | |
-12 | 636.8513 | 619.154 | 601.8883 | 6191540 | 4030.896703 | 4031 | |
-11 | 602.3502 | 585.9346 | 569.9095 | 5859346 | 4027.267626 | 4027 | |
-10 | 569.9298 | 554.7016 | 539.8262 | 5547016 | 4023.466117 | 4023 | |
-9 | 539.4526 | 525.3245 | 511.5153 | 5253245 | 4019.485662 | 4019 | |
-8 | 510.7906 | 497.6821 | 484.8615 | 4976821 | 4015.31959 | 4015 | |
-7 | 483.8254 | 471.6621 | 459.7586 | 4716621 | 4010.961131 | 4011 | |
-6 | 458.4467 | 447.1599 | 436.1073 | 4471599 | 4006.40334 | 4006 | |
-5 | 434.5519 | 424.0781 | 413.8153 | 4240781 | 4001.6391 | 4002 | |
-4 | 412.046 | 402.3264 | 392.7968 | 4023264 | 3996.661224 | 3997 | |
-3 | 390.8401 | 381.8204 | 372.9716 | 3818204 | 3991.462309 | 3991 | |
-2 | 370.8519 | 362.4818 | 354.2653 | 3624818 | 3986.034896 | 3986 | |
-1 | 352.0045 | 344.2375 | 336.6083 | 3442375 | 3980.371361 | 3980 | |
0 | 334.2264 | 327.0195 | 319.936 | 3270195 | 3974.464006 | 3974 | |
1 | 317.4508 | 310.764 | 304.1877 | 3107640 | 3968.304872 | 3968 | |
2 | 301.6157 | 295.4121 | 289.3072 | 2954121 | 3961.886126 | 3962 | |
3 | 286.6631 | 280.9084 | 275.2418 | 2809084 | 3955.199666 | 3955 | |
4 | 272.5389 | 267.2014 | 261.9423 | 2672014 | 3948.237399 | 3948 | |
5 | 259.1926 | 254.2428 | 249.3626 | 2542428 | 3940.991046 | 3941 | |
6 | 246.577 | 241.9877 | 237.4601 | 2419877 | 3933.452384 | 3933 | |
7 | 234.6482 | 230.394 | 226.1943 | 2303940 | 3925.613052 | 3926 | |
8 | 223.365 | 219.4224 | 215.5278 | 2194224 | 3917.464687 | 3917 | |
9 | 212.689 | 209.0361 | 205.4255 | 2090361 | 3908.998862 | 3909 | |
10 | 202.584 | 199.2007 | 195.8544 | 1992007 | 3900.207156 | 3900 | |
11 | 193.0167 | 189.8841 | 186.7836 | 1898841 | 3891.08125 | 3891 | |
12 | 183.9552 | 181.0559 | 178.1844 | 1810559 | 3881.612483 | 3882 | |
13 | 175.3704 | 172.6881 | 170.0298 | 1726881 | 3871.792731 | 3872 | |
14 | 167.2345 | 164.754 | 162.2942 | 1647540 | 3861.613377 | 3862 | |
15 | 159.5216 | 157.229 | 154.9539 | 1572290 | 3851.066406 | 3851 | |
16 | 152.2075 | 150.0898 | 147.9867 | 1500898 | 3840.143599 | 3840 | |
17 | 145.2694 | 143.3144 | 141.3716 | 1433144 | 3828.836576 | 3829 | |
18 | 138.6861 | 136.8825 | 135.0889 | 1368825 | 3817.137644 | 3817 | |
19 | 132.4375 | 130.7749 | 129.1202 | 1307749 | 3805.03904 | 3805 | |
20 | 126.5049 | 124.9734 | 123.4482 | 1249734 | 3792.532798 | 3793 | |
21 | 120.8705 | 119.4612 | 118.0564 | 1194612 | 3779.611769 | 3780 | |
22 | 115.518 | 114.2223 | 112.9298 | 1142223 | 3766.268543 | 3766 | |
23 | 110.4316 | 109.2417 | 108.0537 | 1092417 | 3752.496008 | 3752 | |
24 | 105.5969 | 104.5053 | 103.4147 | 1045053 | 3738.2873 | 3738 | |
25 | 101 | 100 | 99 | 1000000 | 3723.636364 | 3724 | |
26 | 96.7127 | 95.7132 | 94.7146 | 957132 | 3708.536561 | 3709 | |
27 | 92.6306 | 91.6333 | 90.6378 | 916333 | 3692.982485 | 3693 | |
28 | 88.7426 | 87.7492 | 86.7583 | 877492 | 3676.968438 | 3677 | |
29 | 85.0386 | 84.0505 | 83.0655 | 840505 | 3660.48929 | 3660 | |
30 | 81.509 | 80.5274 | 79.5497 | 805274 | 3643.540303 | 3644 | |
31 | 78.1446 | 77.1707 | 76.2012 | 771707 | 3626.117344 | 3626 | |
32 | 74.937 | 73.9717 | 73.0115 | 739717 | 3608.216616 | 3608 | |
33 | 71.8779 | 70.9222 | 69.9721 | 709222 | 3589.834819 | 3590 | |
34 | 68.9598 | 68.0144 | 67.0752 | 680144 | 3570.968724 | 3571 | |
35 | 66.1755 | 65.2411 | 64.3134 | 652411 | 3551.616678 | 3552 | |
36 | 63.5182 | 62.5954 | 61.6798 | 625954 | 3531.776923 | 3532 | |
37 | 60.9814 | 60.0707 | 59.1677 | 600707 | 3511.447541 | 3511 | |
38 | 58.5591 | 57.661 | 56.771 | 576610 | 3490.629107 | 3491 | |
39 | 56.2456 | 55.3604 | 54.4837 | 553604 | 3469.320849 | 3469 | |
40 | 54.0355 | 53.1635 | 52.3004 | 531635 | 3447.524219 | 3448 | |
41 | 51.9235 | 51.0651 | 50.2158 | 510651 | 3425.240434 | 3425 | |
42 | 49.9049 | 49.0602 | 48.225 | 490602 | 3402.470347 | 3402 | |
43 | 47.9752 | 47.1443 | 46.3232 | 471443 | 3379.218099 | 3379 | |
44 | 46.1298 | 45.313 | 44.5062 | 453130 | 3355.48692 | 3355 | |
45 | 44.3649 | 43.5621 | 42.7696 | 435621 | 3331.28017 | 3331 | |
46 | 42.6764 | 41.8878 | 41.1096 | 418878 | 3306.60442 | 3307 | |
47 | 41.0607 | 40.2862 | 39.5224 | 402862 | 3281.462413 | 3281 | |
48 | 39.5143 | 38.7539 | 38.0044 | 387539 | 3255.862083 | 3256 | |
49 | 38.0339 | 37.2876 | 36.5524 | 372876 | 3229.810978 | 3230 | |
50 | 36.6163 | 35.8842 | 35.1631 | 358842 | 3203.317987 | 3203 | |
51 | 35.2587 | 34.5405 | 33.8335 | 345405 | 3176.387512 | 3176 | |
52 | 33.9582 | 33.2538 | 32.5608 | 332538 | 3149.031179 | 3149 | |
53 | 32.7121 | 32.0214 | 31.3423 | 320214 | 3121.258559 | 3121 | |
54 | 31.5178 | 30.8408 | 30.1754 | 308408 | 3093.08135 | 3093 | |
55 | 30.3731 | 29.7096 | 29.0576 | 297096 | 3064.511393 | 3065 | |
56 | 29.2755 | 28.6253 | 27.9868 | 286253 | 3035.555162 | 3036 | |
57 | 28.223 | 27.586 | 26.9607 | 275860 | 3006.232533 | 3006 | |
58 | 27.2135 | 26.5895 | 25.9772 | 265895 | 2976.553164 | 2977 | |
59 | 26.245 | 25.6338 | 25.0343 | 256338 | 2946.529553 | 2947 | |
60 | 25.3156 | 24.7171 | 24.1303 | 247171 | 2916.177953 | 2916 | |
61 | 24.4237 | 23.8376 | 23.2633 | 238376 | 2885.512259 | 2886 | |
62 | 23.5675 | 22.9937 | 22.4315 | 229937 | 2854.550875 | 2855 | |
63 | 22.7454 | 22.1836 | 21.6336 | 221836 | 2823.302104 | 2823 | |
64 | 21.956 | 21.4061 | 20.8678 | 214061 | 2791.794766 | 2792 | |
65 | 21.1977 | 20.6594 | 20.1328 | 206594 | 2760.03126 | 2760 | |
66 | 20.4692 | 19.9424 | 19.4272 | 199424 | 2728.040184 | 2728 | |
67 | 19.7693 | 19.2537 | 18.7497 | 192537 | 2695.835235 | 2696 | |
68 | 19.0966 | 18.592 | 18.099 | 185920 | 2663.431449 | 2663 | |
69 | 18.4499 | 17.9562 | 17.474 | 179562 | 2630.850945 | 2631 | |
70 | 17.8282 | 17.3452 | 16.8735 | 173452 | 2598.113716 | 2598 | |
71 | 17.2304 | 16.7578 | 16.2965 | 167578 | 2565.231402 | 2565 | |
72 | 16.6554 | 16.193 | 15.7419 | 161930 | 2532.223418 | 2532 | |
73 | 16.1023 | 15.6499 | 15.2087 | 156499 | 2499.112683 | 2499 | |
74 | 15.5702 | 15.1276 | 14.6961 | 151276 | 2465.919929 | 2466 | |
75 | 15.0581 | 14.6251 | 14.2032 | 146251 | 2432.656501 | 2433 | |
76 | 14.5652 | 14.1417 | 13.7291 | 141417 | 2399.350634 | 2399 | |
77 | 14.0907 | 13.6764 | 13.2729 | 136764 | 2366.007265 | 2366 | |
78 | 13.6339 | 13.2286 | 12.8341 | 132286 | 2332.656535 | 2333 | |
79 | 13.194 | 12.7976 | 12.4118 | 127976 | 2299.319648 | 2299 | |
80 | 12.7703 | 12.3825 | 12.0053 | 123825 | 2265.998883 | 2266 | |
81 | 12.3622 | 11.9828 | 11.6139 | 119828 | 2232.725076 | 2233 | |
82 | 11.9689 | 11.5978 | 11.2372 | 115978 | 2199.510543 | 2200 | |
83 | 11.59 | 11.227 | 10.8743 | 112270 | 2166.382061 | 2166 | |
84 | 11.2247 | 10.8697 | 10.5248 | 108697 | 2133.346009 | 2133 | |
85 | 10.8727 | 10.5254 | 10.1881 | 105254 | 2100.423787 | 2100 | |
86 | 10.5332 | 10.1935 | 9.8637 | 101935 | 2067.624533 | 2068 | |
87 | 10.2059 | 9.8736 | 9.5511 | 98736 | 2034.974318 | 2035 | |
88 | 9.8902 | 9.5652 | 9.2499 | 95652 | 2002.487028 | 2002 | |
89 | 9.5858 | 9.2678 | 8.9594 | 92678 | 1970.173492 | 1970 | |
90 | 9.292 | 8.9809 | 8.6794 | 89809 | 1938.04121 | 1938 | |
91 | 9.0085 | 8.7042 | 8.4094 | 87042 | 1906.117514 | 1906 | |
92 | 8.735 | 8.4373 | 8.1489 | 84373 | 1874.416579 | 1874 | |
93 | 8.471 | 8.1797 | 7.8977 | 81797 | 1842.937518 | 1843 | |
94 | 8.2161 | 7.9312 | 7.6554 | 79312 | 1811.713393 | 1812 | |
95 | 7.97 | 7.6912 | 7.4215 | 76912 | 1780.724609 | 1781 | |
96 | 7.7324 | 7.4596 | 7.1958 | 74596 | 1750.012692 | 1750 | |
97 | 7.5029 | 7.236 | 6.978 | 72360 | 1719.578557 | 1720 | |
98 | 7.2812 | 7.0201 | 6.7677 | 70201 | 1689.433646 | 1689 | |
99 | 7.067 | 6.8115 | 6.5647 | 68115 | 1659.572555 | 1660 | |
100 | 6.8601 | 6.6101 | 6.3686 | 66101 | 1630.0305 | 1630 | |
101 | 6.6601 | 6.4155 | 6.1793 | 64155 | 1600.797295 | 1601 | |
102 | 6.4668 | 6.2274 | 5.9964 | 62274 | 1571.874139 | 1572 | |
103 | 6.2799 | 6.0457 | 5.8197 | 60457 | 1543.291175 | 1543 | |
104 | 6.0993 | 5.8701 | 5.6489 | 58701 | 1515.045879 | 1515 | |
105 | 5.9246 | 5.7003 | 5.4839 | 57003 | 1487.132654 | 1487 | |
106 | 5.7557 | 5.5362 | 5.3245 | 55362 | 1459.576679 | 1460 | |
107 | 5.5923 | 5.3775 | 5.1703 | 53775 | 1432.36807 | 1432 | |
108 | 5.4343 | 5.224 | 5.0213 | 52240 | 1405.511298 | 1406 | |
109 | 5.2814 | 5.0755 | 4.8772 | 50755 | 1379.008855 | 1379 | |
110 | 5.1334 | 4.9319 | 4.7379 | 49319 | 1352.879567 | 1353 | |
111 | 4.9903 | 4.793 | 4.6031 | 47930 | 1327.122828 | 1327 | |
112 | 4.8517 | 4.6586 | 4.4727 | 46586 | 1301.735882 | 1302 | |
113 | 4.7175 | 4.5285 | 4.3466 | 45285 | 1276.713769 | 1277 | |
114 | 4.5877 | 4.4026 | 4.2245 | 44026 | 1252.069043 | 1252 | |
115 | 4.4619 | 4.2807 | 4.1064 | 42807 | 1227.793259 | 1228 | |
116 | 4.3401 | 4.1627 | 3.9921 | 41627 | 1203.896093 | 1204 | |
117 | 4.2222 | 4.0484 | 3.8815 | 40484 | 1180.365479 | 1180 | |
118 | 4.1079 | 3.9378 | 3.7743 | 39378 | 1157.229175 | 1157 | |
119 | 3.9972 | 3.8306 | 3.6706 | 38306 | 1134.450971 | 1134 | |
120 | 3.89 | 3.7268 | 3.5702 | 37268 | 1112.056182 | 1112 | |
121 | 3.7861 | 3.6263 | 3.4729 | 36263 | 1090.048274 | 1090 | |
122 | 3.6854 | 3.5289 | 3.3787 | 35289 | 1068.407217 | 1068 | |
123 | 3.5877 | 3.4345 | 3.2874 | 34345 | 1047.133276 | 1047 | |
124 | 3.4931 | 3.343 | 3.199 | 33430 | 1026.225586 | 1026 | |
125 | 3.4014 | 3.2543 | 3.1133 | 32543 | 1005.682141 | 1006 | |
126 | 3.3124 | 3.1683 | 3.0302 | 31683 | 985.4997836 | 985 | |
127 | 3.2261 | 3.085 | 2.9497 | 30850 | 965.6981276 | 966 | |
128 | 3.1424 | 3.0042 | 2.8717 | 30042 | 946.2483813 | 946 | |
129 | 3.0613 | 2.9258 | 2.796 | 29258 | 927.1439137 | 927 | |
130 | 2.9825 | 2.8498 | 2.7227 | 28498 | 908.4017494 | 908 | |
131 | 2.9061 | 2.7761 | 2.6515 | 27761 | 890.0138227 | 890 | |
132 | 2.832 | 2.7045 | 2.5826 | 27045 | 871.9455311 | 872 | |
133 | 2.7601 | 2.6352 | 2.5157 | 26352 | 854.2626314 | 854 | |
134 | 2.6902 | 2.5678 | 2.4507 | 25678 | 836.8774805 | 837 | |
135 | 2.6225 | 2.5025 | 2.3878 | 25025 | 819.855229 | 820 | |
136 | 2.5567 | 2.4391 | 2.3267 | 24391 | 803.1572702 | 803 | |
137 | 2.4928 | 2.3775 | 2.2674 | 23775 | 786.7695415 | 787 | |
138 | 2.4308 | 2.3178 | 2.2098 | 23178 | 770.7308773 | 771 | |
139 | 2.3705 | 2.2598 | 2.154 | 22598 | 754.9993311 | 755 | |
140 | 2.312 | 2.2034 | 2.0997 | 22034 | 739.5583526 | 740 | |
141 | 2.2552 | 2.1487 | 2.0471 | 21487 | 724.4458419 | 724 | |
142 | 2.2 | 2.0956 | 1.996 | 20956 | 709.6446311 | 710 | |
143 | 2.1463 | 2.044 | 1.9463 | 20440 | 695.1364995 | 695 | |
144 | 2.0942 | 1.9939 | 1.8981 | 19939 | 680.9306731 | 681 | |
145 | 2.0436 | 1.9452 | 1.8513 | 19452 | 667.0076014 | 667 | |
146 | 1.9943 | 1.8978 | 1.8058 | 18978 | 653.3467364 | 653 | |
147 | 1.9465 | 1.8518 | 1.7616 | 18518 | 639.9848799 | 640 | |
148 | 1.9 | 1.8071 | 1.7187 | 18071 | 626.9008986 | 627 | |
149 | 1.8547 | 1.7637 | 1.677 | 17637 | 614.1022977 | 614 | |
150 | 1.8108 | 1.7215 | 1.6364 | 17215 | 601.5666937 | 602 | |
151 | 1.768 | 1.6804 | 1.597 | 16804 | 589.2707784 | 589 | |
152 | 1.7264 | 1.6405 | 1.5587 | 16405 | 577.2508054 | 577 | |
153 | 1.686 | 1.6017 | 1.5215 | 16017 | 565.4829206 | 565 | |
154 | 1.6467 | 1.564 | 1.4853 | 15640 | 553.9730197 | 554 | |
155 | 1.6084 | 1.5273 | 1.4501 | 15273 | 542.696104 | 543 | |
156 | 1.5712 | 1.4915 | 1.4158 | 14915 | 531.6263325 | 532 | |
157 | 1.5349 | 1.4568 | 1.3825 | 14568 | 520.8306682 | 521 | |
158 | 1.4997 | 1.423 | 1.3501 | 14230 | 510.2519478 | 510 | |
159 | 1.4654 | 1.3901 | 1.3186 | 13901 | 499.8946102 | 500 | |
160 | 1.432 | 1.3582 | 1.288 | 13582 | 489.7947914 | 490 | |
161 | 1.3995 | 1.327 | 1.2582 | 13270 | 479.8615697 | 480 | |
162 | 1.3678 | 1.2967 | 1.2292 | 12967 | 470.162366 | 470 | |
163 | 1.337 | 1.2672 | 1.2009 | 12672 | 460.6691281 | 461 | |
164 | 1.307 | 1.2385 | 1.1734 | 12385 | 451.3855052 | 451 | |
165 | 1.2778 | 1.2106 | 1.1467 | 12106 | 442.3150946 | 442 | |
166 | 1.2494 | 1.1833 | 1.1207 | 11833 | 433.3959386 | 433 | |
167 | 1.2217 | 1.1568 | 1.0953 | 11568 | 424.6964004 | 425 | |
168 | 1.1947 | 1.131 | 1.0706 | 11310 | 416.1868655 | 416 | |
169 | 1.1684 | 1.1059 | 1.0466 | 11059 | 407.8702672 | 408 | |
170 | 1.1428 | 1.0814 | 1.0232 | 10814 | 399.716137 | 400 | |
171 | 1.1179 | 1.0576 | 1.0004 | 10576 | 391.760382 | 392 | |
172 | 1.0935 | 1.0343 | 0.9782 | 10343 | 383.938519 | 384 | |
173 | 1.0698 | 1.0117 | 0.9566 | 10117 | 376.3200232 | 376 | |
174 | 1.0467 | 0.9896 | 0.9355 | 9896 | 368.8397758 | 369 | |
175 | 1.0242 | 0.9681 | 0.915 | 9681 | 361.533684 | 362 | |
176 | 1.0023 | 0.9472 | 0.895 | 9472 | 354.4039754 | 354 | |
177 | 0.9809 | 0.9268 | 0.8756 | 9268 | 347.4185306 | 347 | |
178 | 0.9601 | 0.9069 | 0.8566 | 9069 | 340.5791196 | 341 | |
179 | 0.9397 | 0.8875 | 0.8381 | 8875 | 333.8874856 | 334 | |
180 | 0.9199 | 0.8686 | 0.82 | 8686 | 327.3453435 | 327 | |
181 | 0.9006 | 0.8501 | 0.8024 | 8501 | 320.919586 | 321 | |
182 | 0.8817 | 0.8321 | 0.7853 | 8321 | 314.6464305 | 315 | |
183 | 0.8633 | 0.8146 | 0.7686 | 8146 | 308.5275091 | 309 | |
184 | 0.8454 | 0.7975 | 0.7523 | 7975 | 302.5292892 | 303 | |
185 | 0.8279 | 0.7808 | 0.7364 | 7808 | 296.6530128 | 297 | |
186 | 0.8108 | 0.7646 | 0.7209 | 7646 | 290.9352507 | 291 | |
187 | 0.7941 | 0.7487 | 0.7058 | 7487 | 285.3066138 | 285 | |
188 | 0.7779 | 0.7332 | 0.6911 | 7332 | 279.8035255 | 280 | |
189 | 0.762 | 0.7181 | 0.6767 | 7181 | 274.4271466 | 274 | |
190 | 0.7465 | 0.7034 | 0.6627 | 7034 | 269.1786161 | 269 | |
191 | 0.7314 | 0.689 | 0.649 | 6890 | 264.0232014 | 264 | |
192 | 0.7166 | 0.6749 | 0.6356 | 6749 | 258.9617139 | 259 | |
193 | 0.7022 | 0.6612 | 0.6226 | 6612 | 254.0309909 | 254 | |
194 | 0.6882 | 0.6479 | 0.6099 | 6479 | 249.2320927 | 249 | |
195 | 0.6744 | 0.6348 | 0.5975 | 6348 | 244.4936247 | 244 | |
196 | 0.661 | 0.6221 | 0.5853 | 6221 | 239.8886849 | 240 | |
197 | 0.6479 | 0.6096 | 0.5735 | 6096 | 235.3454984 | 235 | |
198 | 0.6351 | 0.5975 | 0.562 | 5975 | 230.9374853 | 231 | |
199 | 0.6227 | 0.5856 | 0.5507 | 5856 | 226.592503 | 227 | |
200 | 0.6105 | 0.574 | 0.5397 | 5740 | 222.3476452 | 222 | |
201 | 0.5985 | 0.5627 | 0.529 | 5627 | 218.2036032 | 218 | |
202 | 0.5869 | 0.5517 | 0.5185 | 5517 | 214.1610546 | 214 | |
203 | 0.5755 | 0.5409 | 0.5082 | 5409 | 210.1837983 | 210 | |
204 | 0.5644 | 0.5303 | 0.4982 | 5303 | 206.2722619 | 206 | |
205 | 0.5536 | 0.52 | 0.4884 | 5200 | 202.4638783 | 202 | |
206 | 0.543 | 0.5099 | 0.4789 | 5099 | 198.7221953 | 199 | |
207 | 0.5326 | 0.5001 | 0.4696 | 5001 | 195.0847706 | 195 | |
208 | 0.5225 | 0.4905 | 0.4604 | 4905 | 191.5149898 | 192 | |
209 | 0.5126 | 0.4811 | 0.4515 | 4811 | 188.0132429 | 188 | |
210 | 0.5029 | 0.4719 | 0.4428 | 4719 | 184.5799139 | 185 | |
211 | 0.4934 | 0.463 | 0.4343 | 4630 | 181.2527956 | 181 | |
212 | 0.4842 | 0.4542 | 0.426 | 4542 | 177.9574908 | 178 | |
213 | 0.4751 | 0.4456 | 0.4179 | 4456 | 174.7317148 | 175 | |
214 | 0.4663 | 0.4372 | 0.41 | 4372 | 171.5758249 | 172 | |
215 | 0.4576 | 0.429 | 0.4022 | 4290 | 168.4901716 | 168 | |
216 | 0.4492 | 0.421 | 0.3946 | 4210 | 165.4750984 | 165 | |
217 | 0.4409 | 0.4132 | 0.3872 | 4132 | 162.5309415 | 163 | |
218 | 0.4328 | 0.4055 | 0.38 | 4055 | 159.6202009 | 160 | |
219 | 0.4249 | 0.398 | 0.3729 | 3980 | 156.7809194 | 157 | |
220 | 0.4171 | 0.3907 | 0.366 | 3907 | 154.0134158 | 154 | |
221 | 0.4096 | 0.3836 | 0.3592 | 3836 | 151.3180015 | 151 | |
222 | 0.4021 | 0.3765 | 0.3525 | 3765 | 148.6188985 | 149 | |
223 | 0.3949 | 0.3697 | 0.3461 | 3697 | 146.030377 | 146 | |
224 | 0.3878 | 0.363 | 0.3397 | 3630 | 143.4765994 | 143 | |
225 | 0.3809 | 0.3564 | 0.3335 | 3564 | 140.9577073 | 141 | |
226 | 0.3741 | 0.35 | 0.3274 | 3500 | 138.5120773 | 139 | |
227 | 0.3674 | 0.3437 | 0.3215 | 3437 | 136.1017044 | 136 | |
228 | 0.3609 | 0.3376 | 0.3157 | 3376 | 133.7650518 | 134 | |
229 | 0.3545 | 0.3315 | 0.31 | 3315 | 131.42564 | 131 | |
230 | 0.3483 | 0.3257 | 0.3045 | 3257 | 129.1987178 | 129 | |
231 | 0.3422 | 0.3199 | 0.299 | 3199 | 126.9692923 | 127 | |
232 | 0.3362 | 0.3142 | 0.2937 | 3142 | 124.7758624 | 125 | |
233 | 0.3304 | 0.3087 | 0.2885 | 3087 | 122.6570955 | 123 | |
234 | 0.3246 | 0.3033 | 0.2834 | 3033 | 120.5746508 | 121 | |
235 | 0.319 | 0.298 | 0.2784 | 2980 | 118.5286463 | 119 | |
236 | 0.3135 | 0.2928 | 0.2735 | 2928 | 116.5191979 | 117 | |
237 | 0.3081 | 0.2878 | 0.2687 | 2878 | 114.5851202 | 115 | |
238 | 0.3029 | 0.2828 | 0.264 | 2828 | 112.6491617 | 113 | |
239 | 0.2977 | 0.2779 | 0.2594 | 2779 | 110.7500949 | 111 | |
240 | 0.2927 | 0.2732 | 0.2549 | 2732 | 108.9268388 | 109 | |
241 | 0.2877 | 0.2685 | 0.2505 | 2685 | 107.1019136 | 107 | |
242 | 0.2829 | 0.2639 | 0.2462 | 2639 | 105.3141983 | 105 | |
243 | 0.2781 | 0.2594 | 0.242 | 2594 | 103.5637952 | 104 | |
244 | 0.2734 | 0.255 | 0.2379 | 2550 | 101.8508045 | 102 | |
245 | 0.2689 | 0.2507 | 0.2338 | 2507 | 100.1753246 | 100 | |
246 | 0.2644 | 0.2465 | 0.2298 | 2465 | 98.53745181 | 99 | |
247 | 0.26 | 0.2424 | 0.2259 | 2424 | 96.93728032 | 97 | |
248 | 0.2557 | 0.2384 | 0.2221 | 2384 | 95.37490233 | 95 | |
249 | 0.2515 | 0.2344 | 0.2184 | 2344 | 93.81130306 | 94 | |
250 | 0.2474 | 0.2305 | 0.2148 | 2305 | 92.28561654 | 92 | |
251 | 0.2433 | 0.2267 | 0.2112 | 2267 | 90.79793091 | 91 | |
252 | 0.2394 | 0.223 | 0.2077 | 2230 | 89.34833219 | 89 | |
253 | 0.2355 | 0.2193 | 0.2042 | 2193 | 87.89768379 | 88 | |
254 | 0.2317 | 0.2157 | 0.2009 | 2157 | 86.48523351 | 86 | |
255 | 0.2279 | 0.2122 | 0.1976 | 2122 | 85.11106324 | 85 | |
256 | 0.2243 | 0.2088 | 0.1943 | 2088 | 83.77525272 | 84 | |
257 | 0.2207 | 0.2054 | 0.1911 | 2054 | 82.43855214 | 82 |
1、首先ADC是采集好的,只需要一阶滞后滤波处理ADC信号
2、把处理好的ADC信号,每秒进行去对比一次上表得红色的部分,也就是温感当前电压。进行逐个从上到下对比,对比次数++,对比次数初始值对应的是表的第一个。对于第一个大于当前值的就是此时的温度值。
如对比次数初始为-30,而当前采集到的电压分度为3728。也就是刚好大于于25度时的红色的值,也是理想下的25度温感电压分度。3728一直从对比直到第一个大于的数组元素(25度的电压分度值),次数从-30累加到25,然后返回的累加值就是当前温度,也就是25度。
程序:
u16 ad[6];//ad[ ]为采集到的各个采集脚的ADC存储数组,温感的是采集脚5存到ad[5],全局变量
void ADC_temper()
[
static u16 sum[6]//一个临时数组,用到sum[5],存储滤波后的值
sum[5]=0.9*ad[5]+0.1*sum[5];//一阶滞后滤波,这个也发布有一个文章;
if(caclulate_Temperature(&sum[5])) gs.io.in.bit.Temperature = sum[5];
}
对比次数初始为0,只用到了0--256摄氏度。如下是温度处理子程序
u8 caclulate_Temperature(u16 * Temperature)//传递ADc的地址
{
u16 i = 0 ,temp = 0 ;//,state_calculate;
static TIMER_STRUCT time_Temperature; TimeMs(&time_Temperature);//定时器
//传进来的实参是分度值,精度不需要小数点
const u16 T_data[256] = {//0到255温度,的分度值
3974,3968,3962,3955,3948,3941,3933,3926,3917,3909,3900,3891,3882,3872,3862,3851,3840,3829,3817,3805,3793,3780,3766,3752,3738,3724,3709,3693,3677,3660,
3644,3626,3608,3590,3571,3552,3532,3511,3491,3469,3448,3425,3402,3379,3355,3331,3307,3281,3256,3230,3203,3176,3149,3121,3093,3065,3036,3006,2977,2947,
2916,2886,2855,2823,2792,2760,2728,2696,2663,2631,2598,2565,2532,2499,2466,2433,2399,2366,2333,2299,2266,2233,2200,2166,2133,2100,2068,2035,2002,1970,
1938,1906,1874,1843,1812,1781,1750,1720,1689,1660,1630,1601,1572,1543,1515,1487,1460,1432,1406,1379,1353,1327,1302,1277,1252,1228,1204,1180,1157,1134,
1112,1090,1068,1047,1026,1006, 985, 966, 946, 927, 908, 890, 872, 854, 837, 820, 803, 787, 771, 755, 740, 724, 710, 695, 681, 667, 653, 640, 627, 614,
602, 589, 577, 565, 554, 543, 532, 521, 510, 500, 490, 480, 470, 461, 451, 442, 433, 425, 416, 408, 400, 392, 384, 376, 369, 362, 354, 347, 341, 334,
327, 321, 315, 309, 303, 297, 291, 285, 280, 274, 269, 264, 259, 254, 249, 244, 240, 235, 231, 227, 222, 218, 214, 210, 206, 202, 199, 195, 192, 188,
185, 181, 178, 175, 172, 168, 165, 163, 160, 157, 154, 151, 149, 146, 143, 141, 139, 136, 134, 131, 129, 127, 125, 123, 121, 119, 117, 115, 113, 111,
109, 107, 105, 104, 102, 100, 99, 97, 95, 94, 92, 91, 89, 88, 86, 85};
if(time_Temperature.Delay >= 1000) //时间为1000ms,就进行判断一次。
{
time_Temperature.Delay = 0;
for(i = 0;i < 256;i++)//计数初始值为0,对比当前的元素之后,满足当前值刚好大于元素值,返回计数值
{
if(*Temperature > T_data[i]) //如果读取到的分度值大于扫到的数组元素i
{
if(i == 0){*Temperature = 0;break;} //保证温度范围在0--255
if(i == 255){*Temperature = 255;break;}
temp=(T_data[i - 1] - T_data[i])/2; //在元素[i] 元素[i-1] 之间差/2,判断当前分度在后半部分i,前半部分是i-1;
if(T_data[i]+temp > *Temperature)
{*Temperature = i;break;}
else {*Temperature = i-1;break;}
}
}return 1;
}return 0;
}
换了另一个公司的一个传感器温度范围-40到125度,也是100kB值的传感器。
图1
1、把以上图的每一份的分度中心值,做成一个256大小数组。记作数组a1【】
补充:也可以想成只用12位分度值的高8位进行模糊计算。
2、把每个份的温度做成一个表:
首先先把温度阻值表,做出一个分度值的表:表2
3、用分度值的表,打印成一个数组;记作数组f1
4、再用一个a1数组每一个去对比f1每一个值,得到温度数组,得到一个T表数组。
5、把T放进单片机程序,把每次采集的ADC/16的值,作为数组序号。数组序号的值就是温度。
表2
R 最小值 | R 中心值 | R 最大值 | ||
R_Min (Kohm) | R_Cent (Kohm) | R_Max (Kohm) | 中心值Ω | 分度值=中心值/(中心值+串联电阻)*4096 |
3,299.275 | 3,452.75 | 3,613.000 | 3452748 | 4084 |
3,086.507 | 3,227.909 | 3,375.451 | 3227909 | 4083 |
2,888.916 | 3,019.247 | 3,155.143 | 3019247 | 4082 |
2,705.320 | 2,825.494 | 2,950.711 | 2825494 | 4082 |
2,534.636 | 2,645.486 | 2,760.908 | 2645486 | 4081 |
2,375.874 | 2,478.161 | 2,584.594 | 2478161 | 4080 |
2,228.123 | 2,322.542 | 2,420.720 | 2322542 | 4078 |
2,090.549 | 2,177.736 | 2,268.333 | 2177736 | 4077 |
1,962.386 | 2,042.922 | 2,126.550 | 2042922 | 4076 |
1,842.930 | 1,917.347 | 1,994.569 | 1917347 | 4075 |
1,731.535 | 1,800.319 | 1,871.649 | 1800319 | 4073 |
1,627.605 | 1,691.203 | 1,757.110 | 1691203 | 4072 |
1,530.593 | 1,589.414 | 1,650.330 | 1589414 | 4070 |
1,439.996 | 1,494.413 | 1,550.732 | 1494413 | 4069 |
1,355.349 | 1,405.707 | 1,457.791 | 1405707 | 4067 |
1,276.225 | 1,322.839 | 1,371.019 | 1322839 | 4065 |
1,202.069 | 1,245.222 | 1,289.795 | 1245222 | 4063 |
1,132.704 | 1,172.662 | 1,213.908 | 1172662 | 4061 |
1,067.789 | 1,104.798 | 1,142.976 | 1104798 | 4059 |
1,007.012 | 1,041.298 | 1,076.644 | 1041298 | 4057 |
950.083 | 981.854 | 1,014.586 | 981854 | 4055 |
896.736 | 926.182 | 956.500 | 926182 | 4052 |
846.723 | 874.020 | 902.107 | 874020 | 4050 |
799.816 | 825.125 | 851.151 | 825125 | 4047 |
755.802 | 779.274 | 803.393 | 779274 | 4044 |
714.487 | 736.257 | 758.614 | 736257 | 4041 |
675.688 | 695.883 | 716.610 | 695883 | 4038 |
639.237 | 657.974 | 677.193 | 657974 | 4035 |
604.978 | 622.365 | 640.187 | 622365 | 4031 |
572.767 | 588.902 | 605.432 | 588902 | 4028 |
542.468 | 557.444 | 572.776 | 557444 | 4024 |
513.958 | 527.858 | 542.081 | 527858 | 4020 |
487.119 | 500.023 | 513.217 | 500023 | 4016 |
461.844 | 473.824 | 486.065 | 473824 | 4011 |
438.034 | 449.155 | 460.513 | 449155 | 4007 |
415.595 | 425.920 | 436.458 | 425920 | 4002 |
394.410 | 403.995 | 413.772 | 403995 | 3997 |
374.434 | 383.332 | 392.403 | 383332 | 3992 |
355.589 | 363.850 | 372.266 | 363850 | 3986 |
337.807 | 345.475 | 353.283 | 345475 | 3981 |
321.020 | 328.139 | 335.382 | 328139 | 3975 |
305.185 | 311.793 | 318.513 | 311793 | 3969 |
290.224 | 296.357 | 302.590 | 296357 | 3962 |
276.083 | 281.775 | 287.557 | 281775 | 3956 |
262.713 | 267.995 | 273.357 | 267995 | 3949 |
250.067 | 254.969 | 259.940 | 254969 | 3941 |
238.082 | 242.628 | 247.236 | 242628 | 3934 |
226.741 | 230.956 | 235.227 | 230956 | 3926 |
216.007 | 219.915 | 223.872 | 219915 | 3918 |
205.845 | 209.467 | 213.132 | 209467 | 3909 |
196.220 | 199.576 | 202.969 | 199576 | 3901 |
187.106 | 190.215 | 193.357 | 190215 | 3891 |
178.469 | 181.348 | 184.255 | 181348 | 3882 |
170.278 | 172.943 | 175.632 | 172943 | 3872 |
162.511 | 164.976 | 167.462 | 164976 | 3862 |
155.141 | 157.420 | 159.718 | 157420 | 3851 |
148.144 | 150.250 | 152.372 | 150250 | 3840 |
141.502 | 143.448 | 145.406 | 143448 | 3829 |
135.195 | 136.991 | 138.797 | 136991 | 3817 |
129.205 | 130.862 | 132.526 | 130862 | 3805 |
123.514 | 125.041 | 126.574 | 125041 | 3793 |
118.106 | 119.511 | 120.922 | 119511 | 3780 |
112.964 | 114.257 | 115.554 | 114257 | 3766 |
108.075 | 109.264 | 110.454 | 109264 | 3753 |
103.425 | 104.515 | 105.607 | 104515 | 3738 |
99.000 | 100.000 | 101.000 | 100000 | 3724 |
94.705 | 95.704 | 96.704 | 95704 | 3709 |
90.621 | 91.617 | 92.614 | 91617 | 3693 |
86.735 | 87.726 | 88.719 | 87726 | 3677 |
83.036 | 84.021 | 85.009 | 84021 | 3660 |
79.516 | 80.493 | 81.475 | 80493 | 3643 |
76.164 | 77.133 | 78.107 | 77133 | 3626 |
72.972 | 73.932 | 74.897 | 73932 | 3608 |
69.931 | 70.881 | 71.837 | 70881 | 3590 |
67.034 | 67.973 | 68.918 | 67973 | 3571 |
64.272 | 65.199 | 66.133 | 65199 | 3551 |
61.638 | 62.554 | 63.476 | 62554 | 3531 |
59.127 | 60.030 | 60.941 | 60030 | 3511 |
56.732 | 57.621 | 58.519 | 57621 | 3490 |
54.446 | 55.322 | 56.207 | 55322 | 3469 |
52.264 | 53.127 | 53.999 | 53127 | 3447 |
50.181 | 51.030 | 51.889 | 51030 | 3425 |
48.193 | 49.028 | 49.873 | 49028 | 3402 |
46.294 | 47.115 | 47.945 | 47115 | 3379 |
44.479 | 45.285 | 46.102 | 45285 | 3355 |
42.745 | 43.537 | 44.340 | 43537 | 3331 |
41.089 | 41.867 | 42.656 | 41867 | 3306 |
39.507 | 40.270 | 41.045 | 40270 | 3281 |
37.993 | 38.743 | 39.503 | 38743 | 3256 |
36.546 | 37.281 | 38.027 | 37281 | 3230 |
35.161 | 35.882 | 36.614 | 35882 | 3203 |
33.836 | 34.543 | 35.261 | 34543 | 3176 |
32.567 | 33.260 | 33.965 | 33260 | 3149 |
31.353 | 32.032 | 32.723 | 32032 | 3122 |
30.190 | 30.856 | 31.533 | 30856 | 3093 |
29.076 | 29.729 | 30.392 | 29729 | 3065 |
28.010 | 28.649 | 29.299 | 28649 | 3036 |
26.988 | 27.613 | 28.251 | 27613 | 3007 |
26.008 | 26.620 | 27.245 | 26620 | 2977 |
25.069 | 25.669 | 26.280 | 25669 | 2948 |
24.168 | 24.755 | 25.355 | 24755 | 2917 |
23.306 | 23.881 | 24.468 | 23881 | 2887 |
22.479 | 23.042 | 23.616 | 23042 | 2856 |
21.686 | 22.237 | 22.799 | 22237 | 2825 |
20.925 | 21.464 | 22.014 | 21464 | 2794 |
20.194 | 20.721 | 21.261 | 20721 | 2763 |
19.491 | 20.007 | 20.535 | 20007 | 2731 |
18.816 | 19.321 | 19.838 | 19321 | 2699 |
18.167 | 18.661 | 19.167 | 18661 | 2667 |
17.544 | 18.028 | 18.523 | 18028 | 2635 |
16.946 | 17.419 | 17.903 | 17419 | 2602 |
16.374 | 16.836 | 17.310 | 16836 | 2570 |
15.824 | 16.276 | 16.740 | 16276 | 2537 |
15.295 | 15.738 | 16.192 | 15738 | 2505 |
14.786 | 15.220 | 15.664 | 15220 | 2472 |
14.298 | 14.721 | 15.156 | 14721 | 2439 |
13.826 | 14.240 | 14.666 | 14240 | 2406 |
13.372 | 13.777 | 14.194 | 13777 | 2373 |
12.935 | 13.332 | 13.739 | 13332 | 2340 |
12.515 | 12.903 | 13.301 | 12903 | 2308 |
12.110 | 12.490 | 12.880 | 12490 | 2275 |
11.722 | 12.093 | 12.475 | 12093 | 2242 |
11.348 | 11.711 | 12.084 | 11711 | 2209 |
10.988 | 11.343 | 11.708 | 11343 | 2177 |
10.641 | 10.988 | 11.346 | 10988 | 2144 |
10.306 | 10.646 | 10.996 | 10646 | 2112 |
9.984 | 10.316 | 10.659 | 10316 | 2080 |
9.673 | 9.999 | 10.334 | 9999 | 2048 |
9.374 | 9.692 | 10.020 | 9692 | 2016 |
9.085 | 9.396 | 9.717 | 9396 | 1984 |
8.806 | 9.111 | 9.425 | 9111 | 1953 |
8.538 | 8.836 | 9.143 | 8836 | 1921 |
8.279 | 8.570 | 8.871 | 8570 | 1890 |
8.029 | 8.314 | 8.609 | 8314 | 1859 |
7.787 | 8.066 | 8.355 | 8066 | 1829 |
7.555 | 7.828 | 8.110 | 7828 | 1798 |
7.330 | 7.598 | 7.874 | 7598 | 1768 |
7.114 | 7.376 | 7.646 | 7376 | 1739 |
6.906 | 7.162 | 7.427 | 7162 | 1709 |
6.704 | 6.955 | 7.214 | 6955 | 1680 |
6.509 | 6.755 | 7.008 | 6755 | 1651 |
6.321 | 6.561 | 6.810 | 6561 | 1623 |
6.139 | 6.374 | 6.618 | 6374 | 1594 |
5.963 | 6.194 | 6.432 | 6194 | 1567 |
5.793 | 6.019 | 6.252 | 6019 | 1539 |
5.629 | 5.850 | 6.079 | 5850 | 1512 |
5.470 | 5.686 | 5.910 | 5686 | 1485 |
5.317 | 5.528 | 5.747 | 5528 | 1458 |
5.168 | 5.375 | 5.590 | 5375 | 1432 |
5.025 | 5.227 | 5.438 | 5227 | 1406 |
4.886 | 5.084 | 5.290 | 5084 | 1381 |
4.751 | 4.945 | 5.147 | 4945 | 1355 |
4.620 | 4.811 | 5.009 | 4811 | 1330 |
4.494 | 4.681 | 4.875 | 4681 | 1306 |
4.372 | 4.555 | 4.745 | 4555 | 1282 |
4.254 | 4.433 | 4.619 | 4433 | 1258 |
4.141 | 4.316 | 4.498 | 4316 | 1235 |
4.030 | 4.202 | 4.381 | 4202 | 1212 |
3.923 | 4.092 | 4.267 | 4092 | 1189 |
3.820 | 3.985 | 4.157 | 3985 | 1167 |
3.720 | 3.881 | 4.050 | 3881 | 1145 |
3.622 | 3.781 | 3.946 | 3781 | 1124 |
3.528 | 3.684 | 3.845 | 3684 | 1103 |
3.437 | 3.589 | 3.748 | 3589 | 1082 |
3.349 | 3.498 | 3.653 | 3498 | 1061 |
3.263 | 3.409 | 3.562 | 3409 | 1041 |
在vc2019中使用如下程序;复制最后行的分度值输入,然后提成数组备用。
for (i = 0; i < 166; i++)
{
scanf_s("%d ",&RT_Rarray[i]);
}
printf("\r\n ");
for (i = 0 ,tatol = 1; i < (166); i++,tatol++)
{
printf("%d ,",RT_Rarray[i]);
if (tatol % 10 == 0)printf("\r\n ");
}
提取到的数组为
unsigned int RT_Rarray[166] = { //按顺序的-40-125摄氏度的分度值
4084 ,4083 ,4082 ,4082 ,4081 ,4080 ,4078 ,4077 ,4076 ,4075 ,
4073 ,4072 ,4070 ,4069 ,4067 ,4065 ,4063 ,4061 ,4059 ,4057 ,
4055 ,4052 ,4050 ,4047 ,4044 ,4041 ,4038 ,4035 ,4031 ,4028 ,
4024 ,4020 ,4016 ,4011 ,4007 ,4002 ,3997 ,3992 ,3986 ,3981 ,
3975 ,3969 ,3962 ,3956 ,3949 ,3941 ,3934 ,3926 ,3918 ,3909 ,
3901 ,3891 ,3882 ,3872 ,3862 ,3851 ,3840 ,3829 ,3817 ,3805 ,
3793 ,3780 ,3766 ,3753 ,3738 ,3724 ,3709 ,3693 ,3677 ,3660 ,
3643 ,3626 ,3608 ,3590 ,3571 ,3551 ,3531 ,3511 ,3490 ,3469 ,
3447 ,3425 ,3402 ,3379 ,3355 ,3331 ,3306 ,3281 ,3256 ,3230 ,
3203 ,3176 ,3149 ,3122 ,3093 ,3065 ,3036 ,3007 ,2977 ,2948 ,
2917 ,2887 ,2856 ,2825 ,2794 ,2763 ,2731 ,2699 ,2667 ,2635 ,
2602 ,2570 ,2537 ,2505 ,2472 ,2439 ,2406 ,2373 ,2340 ,2308 ,
2275 ,2242 ,2209 ,2177 ,2144 ,2112 ,2080 ,2048 ,2016 ,1984 ,
1953 ,1921 ,1890 ,1859 ,1829 ,1798 ,1768 ,1739 ,1709 ,1680 ,
1651 ,1623 ,1594 ,1567 ,1539 ,1512 ,1485 ,1458 ,1432 ,1406 ,
1381 ,1355 ,1330 ,1306 ,1282 ,1258 ,1235 ,1212 ,1189 ,1167 ,
1145 ,1124 ,1103 ,1082 ,1061 ,1041
};
第四步:使用VC2019程序如下
#include"stdio.h"
unsigned int RT_Rarray[166] = { //按顺序的-40-125摄氏度的分度值
4084 ,4083 ,4082 ,4082 ,4081 ,4080 ,4078 ,4077 ,4076 ,4075 ,
4073 ,4072 ,4070 ,4069 ,4067 ,4065 ,4063 ,4061 ,4059 ,4057 ,
4055 ,4052 ,4050 ,4047 ,4044 ,4041 ,4038 ,4035 ,4031 ,4028 ,
4024 ,4020 ,4016 ,4011 ,4007 ,4002 ,3997 ,3992 ,3986 ,3981 ,
3975 ,3969 ,3962 ,3956 ,3949 ,3941 ,3934 ,3926 ,3918 ,3909 ,
3901 ,3891 ,3882 ,3872 ,3862 ,3851 ,3840 ,3829 ,3817 ,3805 ,
3793 ,3780 ,3766 ,3753 ,3738 ,3724 ,3709 ,3693 ,3677 ,3660 ,
3643 ,3626 ,3608 ,3590 ,3571 ,3551 ,3531 ,3511 ,3490 ,3469 ,
3447 ,3425 ,3402 ,3379 ,3355 ,3331 ,3306 ,3281 ,3256 ,3230 ,
3203 ,3176 ,3149 ,3122 ,3093 ,3065 ,3036 ,3007 ,2977 ,2948 ,
2917 ,2887 ,2856 ,2825 ,2794 ,2763 ,2731 ,2699 ,2667 ,2635 ,
2602 ,2570 ,2537 ,2505 ,2472 ,2439 ,2406 ,2373 ,2340 ,2308 ,
2275 ,2242 ,2209 ,2177 ,2144 ,2112 ,2080 ,2048 ,2016 ,1984 ,
1953 ,1921 ,1890 ,1859 ,1829 ,1798 ,1768 ,1739 ,1709 ,1680 ,
1651 ,1623 ,1594 ,1567 ,1539 ,1512 ,1485 ,1458 ,1432 ,1406 ,
1381 ,1355 ,1330 ,1306 ,1282 ,1258 ,1235 ,1212 ,1189 ,1167 ,
1145 ,1124 ,1103 ,1082 ,1061 ,1041
};
int main()
{
unsigned short buff[256] = { 0 };
short buff_temper[256] = { 0 };
int i = 0,j = 0 ,temper=8;
int tatol = 1;
/************************ XLSX表格 输入得到数组表 ******************************************/
//for (i = 0; i < 166; i++)
//{
// scanf_s("%d ",&RT_Rarray[i]);
//}
//printf("\r\n ");
//for (i = 0 ,tatol = 1; i < (166); i++,tatol++)
//{
// printf("%d ,",RT_Rarray[i]);
// if (tatol % 10 == 0)printf("\r\n ");
//}
/*****************************************************************/
/********************分度值,求温度***********************/
for (i = 1; i < 256; i++)
{
temper += 16;
buff[i] = temper;
}
/* 使用分度值,对比以上的的分度值 */
for (i = 0; i < 256; i++)
{
for (j = 0; j < 161; j++)
{
if (buff[i] < RT_Rarray[160])buff_temper[i] = 125;
if (buff[i] > RT_Rarray[j])
{
buff_temper[i] = j - 40;
break;
}
}
}
for (i = 0, tatol = 1; i < 256; i++, tatol++)
{
printf("%d ,", buff_temper[i]);
if (tatol % 10 == 0)printf("\r\n");
}
/*********************************************************/
}
得到T表数组
T表数组
南京时恒的100KNTC 分度值除16的,分度值0--4096的顺序 对应温度表,最终表
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,120 ,119 ,118 ,118 ,117 ,116 ,116 ,115 ,
114 ,114 ,113 ,112 ,112 ,111 ,110 ,110 ,109 ,109 ,
108 ,107 ,107 ,106 ,106 ,105 ,104 ,104 ,103 ,103 ,
102 ,101 ,101 ,100 ,100 ,99 ,99 ,98 ,98 ,97 ,
97 ,96 ,95 ,95 ,94 ,94 ,93 ,93 ,92 ,92 ,
91 ,91 ,90 ,90 ,89 ,89 ,88 ,88 ,87 ,87 ,
86 ,86 ,85 ,85 ,84 ,84 ,83 ,83 ,82 ,82 ,
81 ,81 ,80 ,80 ,79 ,79 ,78 ,78 ,77 ,77 ,
76 ,76 ,75 ,75 ,75 ,74 ,74 ,73 ,73 ,72 ,
72 ,71 ,71 ,70 ,70 ,69 ,69 ,68 ,68 ,67 ,
67 ,66 ,66 ,65 ,65 ,64 ,64 ,63 ,63 ,62 ,
61 ,61 ,60 ,60 ,59 ,59 ,58 ,58 ,57 ,57 ,
56 ,56 ,55 ,54 ,54 ,53 ,53 ,52 ,52 ,51 ,
50 ,50 ,49 ,49 ,48 ,47 ,47 ,46 ,45 ,45 ,
44 ,43 ,43 ,42 ,41 ,40 ,40 ,39 ,38 ,37 ,
37 ,36 ,35 ,34 ,33 ,33 ,32 ,31 ,30 ,29 ,
28 ,27 ,26 ,25 ,24 ,22 ,21 ,20 ,19 ,17 ,
16 ,14 ,13 ,11 ,9 ,7 ,5 ,3 ,0 ,-2 ,
-6 ,-9 ,-14 ,-20 ,-28 ,-40
第5步
这个放单片机的程序,临时手打的。但是原理就是这样的。
singned char caclualate(u16 * wendu_adc)
{
singned char temper=0;
singned char f1[256]={
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,125 ,
125 ,125 ,120 ,119 ,118 ,118 ,117 ,116 ,116 ,115 ,
114 ,114 ,113 ,112 ,112 ,111 ,110 ,110 ,109 ,109 ,
108 ,107 ,107 ,106 ,106 ,105 ,104 ,104 ,103 ,103 ,
102 ,101 ,101 ,100 ,100 ,99 ,99 ,98 ,98 ,97 ,
97 ,96 ,95 ,95 ,94 ,94 ,93 ,93 ,92 ,92 ,
91 ,91 ,90 ,90 ,89 ,89 ,88 ,88 ,87 ,87 ,
86 ,86 ,85 ,85 ,84 ,84 ,83 ,83 ,82 ,82 ,
81 ,81 ,80 ,80 ,79 ,79 ,78 ,78 ,77 ,77 ,
76 ,76 ,75 ,75 ,75 ,74 ,74 ,73 ,73 ,72 ,
72 ,71 ,71 ,70 ,70 ,69 ,69 ,68 ,68 ,67 ,
67 ,66 ,66 ,65 ,65 ,64 ,64 ,63 ,63 ,62 ,
61 ,61 ,60 ,60 ,59 ,59 ,58 ,58 ,57 ,57 ,
56 ,56 ,55 ,54 ,54 ,53 ,53 ,52 ,52 ,51 ,
50 ,50 ,49 ,49 ,48 ,47 ,47 ,46 ,45 ,45 ,
44 ,43 ,43 ,42 ,41 ,40 ,40 ,39 ,38 ,37 ,
37 ,36 ,35 ,34 ,33 ,33 ,32 ,31 ,30 ,29 ,
28 ,27 ,26 ,25 ,24 ,22 ,21 ,20 ,19 ,17 ,
16 ,14 ,13 ,11 ,9 ,7 ,5 ,3 ,0 ,-2 ,
-6 ,-9 ,-14 ,-20 ,-28 ,-40
}
temper= f1[*wendu_adc/16];
return temper;
}