我是靠谱客的博主 寒冷裙子,最近开发中收集的这篇文章主要介绍方法一 NTC热敏电阻转换温度的计算方式(分段法),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一.硬件

STC15W408AS单片机 10KNTC热敏电阻

 

二.资料

热敏电阻阻值温度对应表 -30摄氏度~240摄氏度对应的阻值    每个温度对应一个阻值

三.计算方法

根据需求,我这测试只用选取0~100度区间就OK了.也就是100个点 , 用表格绘制曲线图.Y轴是温度,X轴是电阻值,单位KΩ.这是一个非线性曲线,所以我们很难求解. 所以不如把它划分成多个区间,每个区间都是一小段直线.

0~100度划分了17个区间 ,当然划分的区间越多结果就越精确,这样就能得到16个线段了,然后求出16个一元一次方程的解,把ADC测出的阻值带入到对应的方程里,就能求出对应的温度.

四.求温度代码

#include <stdio.h>
/*10K NTC 温度与阻值对应表 X轴代表温度
Y轴代表阻值*/
uint16_t X_Temp[17] = {0,6,12,18,25,31,37,45,50,57,63,70,76,83,89,94,100};
uint16_t Y_Res[17] = {31908,23698,17794,13498,9900,7625,5925,4288,3529,2709,2177,1701,1386,1101,909,778,649};
/*************************************************
*函数名称:OneDimensionalEquation
*功
能:解一元一次方程
给出两点坐标和第三点的x值或y值
得出第三点y值或x值
*参
数:
*返 回 值:
*************************************************/
float OneDimensionalEquation(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t Unkown_x,uint16_t Unkown_y)
{
float k = 0;
float b = 0;
k = (((int32_t)y1-(int32_t)y2)/((int32_t)x1-(int32_t)x2));
b = y1-x1*k;
if(0 == Unkown_x)
//如果unknown_x设为0 就是求x的值 否则求y值
return ((float)Unkown_y-b)/k;
else
return ((float)Unkown_x*k+b);
}
/*************************************************
*函数名称:uint8_t Res_To_Temperature(uint16_t NTC_Res)
*功
能:计算真实温度
*参
数:NTC当前阻值
*返 回 值:温度值
*************************************************/
float Res_To_Temperature(uint16_t NTC_Res)
{
uint8_t Loop = 0;
uint8_t StartPoint = 0;
float RealTemp = 0;
/*查找阻值所对应的区间*/
for(Loop = 0;Loop < 17;Loop++)
{
if(NTC_Res > Y_Res[Loop+1])
{
StartPoint = Loop;
break;
}
}
RealTemp = (float)OneDimensionalEquation(X_Temp[StartPoint],Y_Res[StartPoint],X_Temp[StartPoint+1],Y_Res[StartPoint+1],0,NTC_Res);
return RealTemp;
}

 五.阻值表

区间采样阻值表

Temp.Rmin
(deg. C)( Ohms)
031908
623698
1217794
1813498
259900
317625
375925
454288
503529
572709
632177
701701
761386
831101
89909
94778
100649

详细组织表 

Temp.RmaxRnorRmin
(deg. C)(k Ohms)(k Ohms)(k Ohms)
-30184.3727177.3726170.6211
-29173.1351166.6654160.4213
-28162.6553156.674150.8976
-27152.8776147.3463142.0008
-26143.7506138.6339133.686
-25135.227130.4927125.9115
-24127.2633122.8816118.6389
-23119.8193115.763111.8328
-22112.8579109.1019105.4603
-21106.345102.866399.4914
-20100.24997.026493.8979
-1994.540791.554788.6541
-1889.193186.425883.736
-1784.181381.616379.1214
-1679.482377.104374.7899
-1575.074772.869770.7223
-1470.938768.893766.9011
-1367.055965.159263.3099
-1263.409561.6559.9334
-1159.983658.351356.7577
-1056.763655.249153.7697
-953.73652.330750.9571
-850.888249.584148.3086
-748.208546.998245.8137
-645.68644.562743.4627
-543.310542.26841.2465
-441.072740.105239.1565
-338.963938.065837.1848
-236.975836.142335.3241
-135.100934.327433.5675
033.332132.614231.9086
131.662830.996630.3415
230.086929.468828.8605
328.598628.025127.4604
427.192526.660626.1364
525.863825.370424.8839
624.607624.150123.6987
723.419722.995522.5768
822.295921.902821.5144
921.232520.868220.5081
1020.225919.888419.5546
1119.272718.960218.6509
1218.369918.080617.7941
1317.514417.246716.9815
1416.703616.456116.2106
1515.934915.706115.479
1615.205914.994514.7845
1714.514314.319114.1251
1813.85813.677913.4988
1913.23513.06912.9037
2012.643512.490512.3381
2112.081711.940911.8005
2211.547911.418411.2893
2311.040710.921710.803
2410.558510.449410.3403
2510.1109.9
269.67249.57249.4725
279.26519.16549.0659
288.87738.77798.6788
298.50788.40898.3104
308.15568.05747.9597
317.81997.72257.6256
327.49997.40337.3073
337.19467.0997.004
346.90346.80886.7149
356.62556.53216.4393
366.36036.2686.1764
376.10716.0165.9257
385.86545.77555.6865
395.63445.54595.4581
405.41385.32665.2402
415.2035.11715.0321
425.00154.91694.8333
434.80884.72574.6435
444.62464.54284.462
454.44844.3684.2886
464.27984.20084.1229
474.11844.04093.9644
483.9643.88783.8128
493.81623.74143.6678
503.67463.60123.529
513.5393.4673.3962
523.40913.33853.2691
533.28463.21543.1474
543.16533.09753.0308
553.0512.98452.9191
562.94132.87622.8121
572.83622.77232.7096
582.73532.67272.6113
592.63852.57722.5171
602.54572.48562.4268
612.45662.39772.3401
622.3712.31342.257
632.28882.23242.1772
642.20992.15472.1007
652.13412.08012.0272
662.06132.00841.9567
671.99131.93961.8889
681.92411.87341.8239
691.85941.80981.7614
701.79731.74871.7013
711.73751.691.6436
721.681.63351.5881
731.62471.57921.5348
741.57151.52691.4835
751.52021.47671.4342
761.47091.42831.3868
771.42351.38181.3411
781.37781.33691.2972
791.33371.29381.2549
801.29131.25231.2143
811.25051.21231.1751
821.21111.17371.1374
831.17321.13661.101
841.13661.10081.066
851.10141.06631.0323
861.06741.03310.9998
871.03461.00110.9685
881.0030.97020.9383
890.97250.94040.9092
900.94310.91160.8812
910.91470.88390.8541
920.88730.85720.828
930.86080.83140.8028
940.83530.80640.7785
950.81060.78240.7551
960.78680.75920.7324
970.76380.73670.7106
980.74150.71510.6895
990.72010.69420.6691
1000.69930.67390.6495
1010.67920.65440.6304
1020.65980.63550.6121
1030.64110.61730.5943
1040.6230.59970.5772
1050.60540.58260.5606
1060.58850.56610.5446
1070.57210.55020.5291
1080.55620.53480.5142
1090.54080.51990.4997
1100.5260.50540.4857
1110.51160.49150.4721
1120.49760.4780.459
1130.48420.46490.4463
1140.47110.45220.434
1150.45840.43990.4222
1160.44620.42810.4107
1170.43430.41660.3995
1180.42280.40540.3887
1190.41170.39470.3783
1200.40090.38420.3682
1210.39040.37410.3584
1220.38030.36430.3489
1230.37050.35470.3397
1240.36090.34550.3307
1250.35170.33660.3221
1260.34270.32790.3137
1270.3340.31950.3056
1280.32560.31140.2977
1290.31740.30340.2901
1300.30940.29580.2827
1310.30170.28830.2755
1320.29420.28110.2685
1330.2870.27410.2618
1340.27990.26730.2552
1350.27310.26070.2488
1360.26640.25430.2427
1370.260.2480.2367
1380.25370.2420.2308
1390.24760.23610.2252
1400.24170.23040.2197
1410.23590.22490.2144
1420.23030.21950.2092
1430.22490.21430.2041
1440.21960.20920.1993
1450.21450.20430.1945
1460.20950.19950.1899
1470.20460.19480.1854
1480.19990.19030.181
1490.19530.18590.1768
1500.19090.18160.1727
1510.18650.17740.1687
1520.18230.17330.1648
1530.17820.16940.161
1540.17420.16560.1573
1550.17030.16180.1537
1560.16650.15820.1502
1570.16280.15470.1469
1580.15930.15120.1436
1590.15580.14790.1403
1600.15240.14460.1372
1610.14910.14140.1342
1620.14580.13830.1312
1630.14270.13530.1283
1640.13960.13240.1255
1650.13660.12950.1228
1660.13370.12680.1201
1670.13090.12410.1175
1680.12820.12140.115
1690.12550.11880.1126
1700.12280.11630.1102
1710.12030.11390.1078
1720.11780.11150.1055
1730.11540.10920.1033
1740.1130.10690.1012
1750.11070.10470.0991
1760.10850.10260.097
1770.10630.10050.095
1780.10410.09840.0931
1790.1020.09640.0912
1800.10.09450.0893
1810.0980.09260.0875
1820.09610.09080.0857
1830.09420.0890.084
1840.09230.08720.0823
1850.09050.08550.0807
1860.08880.08380.0791
1870.08710.08220.0775
1880.08540.08060.076
1890.08370.0790.0745
1900.08220.07750.0731
1910.08060.0760.0716
1920.07910.07450.0703
1930.07760.07310.0689
1940.07610.07170.0676
1950.07470.07040.0663
1960.07330.06910.0651
1970.0720.06780.0638
1980.07060.06650.0626
1990.06930.06530.0615
2000.06810.06410.0603
2010.06680.06290.0592
2020.06560.06180.0581
2030.06440.06060.057
2040.06330.05950.056
2050.06220.05850.055
2060.06110.05740.054
2070.060.05640.053
2080.05890.05540.0521
2090.05790.05440.0511
2100.05690.05350.0502
2110.05590.05250.0493
2120.05490.05160.0485
2130.0540.05070.0476
2140.05310.04980.0468
2150.05220.0490.046
2160.05130.04810.0452
2170.05040.04730.0444
2180.04960.04650.0436
2190.04870.04570.0429
2200.04790.04490.0422
2210.04710.04420.0414
2220.04630.04350.0407
2230.04560.04270.0401
2240.04480.0420.0394
2250.04410.04130.0387
2260.04340.04070.0381
2270.04270.040.0375
2280.0420.03930.0369
2290.04130.03870.0362
2300.04070.03810.0357
2310.040.03750.0351
2320.03940.03690.0345
2330.03880.03630.034
2340.03820.03570.0334
2350.03760.03520.0329
2360.0370.03460.0324
2370.03640.03410.0319
2380.03590.03350.0314
2390.03530.0330.0309
2400.03480.03250.0304

最后

以上就是寒冷裙子为你收集整理的方法一 NTC热敏电阻转换温度的计算方式(分段法)的全部内容,希望文章能够帮你解决方法一 NTC热敏电阻转换温度的计算方式(分段法)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(37)

评论列表共有 0 条评论

立即
投稿
返回
顶部