1 NTC热敏电阻
NTC热敏电阻一般用于环境温度的测量,可以识别-20到100度,如果要采集更高的温度就需要用到热电偶了。
2 NTC热敏电阻R/T对照表
T(℃)R(KΩ)T(℃)R(KΩ)T(℃)R(KΩ)-20.095.337020.512.213861.02.3820-19.592.655921.011.942561.52.3394-19.090.058021.511.677862.02.2977-18.587.540622.011.419862.52.2568-18.085.100922.511.168163.02.2167-17.582.736423.010.922763.52.1775-17.080.444523.510.683464.02.1390-16.578.222724.010.449964.52.1013-16.076.068924.510.222265.02.0644-15.573.980625.010.000065.52.0282-15.071.955825.59.783366.01.9928-14.569.992326.09.571866.51.9580-14.068.088126.59.365567.01.9240-13.566.241227.09.164267.51.8906-13.064.449927.58.967768.01.8579-12.562.712228.08.776068.51.8258-12.061.026428.58.588969.01.7944-11.559.390829.08.406369.51.7636-11.057.803829.58.228170.01.7334-10.556.263930.08.054170.51.7037-10.054.769430.57.884271.01.6747-9.553.318931.07.718471.51.6462-9.051.911131.57.556572.01.6183-8.550.544532.07.398572.51.5910-8.049.217832.57.244273.01.5641-7.547.929833.07.093573.51.5378-7.046.679233.56.946374.01.5120-6.545.464934.06.802674.51.4867-6.044.285634.56.662275.01.4619-5.543.140335.06.525175.51.4375-5.042.027935.56.391276.01.4136-4.540.947436.06.260476.51.3902-4.039.897836.56.132677.01.3672-3.538.878037.06.007777.51.3447-3.037.887337.55.885878.01.3225-2.536.924638.05.766678.51.3008-2.035.989238.55.650179.01.2795-1.535.080139.05.536379.51.2586-1.034.196539.55.425180.01.2381-0.533.337840.05.316480.51.21800.032.503040.55.210281.01.19830.531.691541.05.106481.51.17891.030.902641.55.004982.01.15991.530.135542.04.905782.51.14122.029.389642.54.808883.01.12292.528.664443.04.714083.51.10503.027.959043.54.621384.01.08733.527.273044.04.530784.51.07004.026.605844.54.442185.01.05304.525.956745.04.355485.51.03635.025.325445.54.270786.01.01995.524.711146.04.187886.51.00386.024.113546.54.106887.00.98806.523.532047.04.027587.50.97257.022.966147.53.950088.00.95737.522.415448.03.874288.50.94248.021.879548.53.800089.00.92778.521.357949.03.727589.50.91339.020.850249.53.656590.00.89919.520.355950.03.587090.50.885210.019.874750.53.519091.00.871510.519.406351.03.452591.50.858111.018.950251.53.387592.00.845011.518.506052.03.323892.50.832012.018.073552.53.261593.00.819312.517.652353.03.200593.50.806813.017.242153.53.140894.00.794513.516.842654.03.082494.50.782514.016.453454.53.025295.00.770714.516.074355.02.969295.50.759015.015.704955.52.914496.00.747615.515.345056.02.860896.50.736416.014.994456.52.808297.00.725316.514.652857.02.756897.50.714517.014.319857.52.706598.00.703817.513.995458.02.657298.50.693318.013.679258.52.608999.00.683118.513.371059.02.561699.50.672919.013.070559.52.5153100.00.663019.512.777760.02.470020.012.492260.52.4255
3 分压公式
根据欧姆定律,电流I=U/R
可以求出I=(U总-U2)/R1
同样I=(U总/R1+R2)那么U2=(U总/R1+R2)*R2
同样R2=(U2*R1)/(U总-U2)以-15度为例,阻值是71.9558K,
那么电压U2=(U总/R1+R2)*R2
U2=(U总*71.9558)/(10+71.9558)
假设U总为3.3V,那么U2=2.89V,12位ADC对应的值是3595
4.1 快速生成温度表
4.1.1 利用excel将电阻阻值保存为.csv格式的文件
-复制所有NTC电阻阻值
-再新建一个test.csv文件,在第一行第一列选择性粘贴,粘贴内容转置
- 利用记事本打开test.csv,将电阻阻值复制粘贴到数组中。
以下是完整代码
#include#include#include"stdint.h"#defineLENGTH_OF_ARRAY(A) sizeof(A)/sizeof(A[0])#defineCONFIG_MIN_TEMP -15#defineCONFIG_MAX_TEMP 80#defineCONFIG_CNT_PRINTF_LNIE 5FILE *fp =0;floatres_values[] = {71.9558,68.0881,64.4499,61.0264,57.8038,54.7694,51.9111,49.2178,46.6792,44.2856,42.0279,39.8978,37.8873,35.9892,34.1965,32.503,30.9026,29.3896,27.959,26.6058,25.3254,24.1135,22.9661,21.8795,20.8502,19.8747,18.9502,18.0735,17.2421,16.4534,15.7049,14.9944,14.3198,13.6792,13.0705,12.4922,11.9425,11.4198,10.9227,10.4499,10,9.5718,9.1642,8.776,8.4063,8.0541,7.7184,7.3985,7.0935,6.8026,6.5251,6.2604,6.0077,5.7666,5.5363,5.3164,5.1064,4.8088,4.714,4.5307,4.3554,4.1878,4.0275,3.8742,3.7275,3.587,3.4525,3.3238,3.2005,3.0824,2.9692,2.8608,2.7568,2.6572,2.5616,2.47,2.382,2.2977,2.2167,2.139,2.0644,1.9928,1.924,1.8579,1.7944,1.7334,1.6747,1.6183,1.5641,1.512,1.4619,1.4136,1.3672,1.3225,1.2795,1.2381};staticint8_tres_to_voltage(int16_tstart_temperature,floatvol_ref,floatvol_total,floatres_pull,uint16_tadc_max){uint16_tget_cnt =LENGTH_OF_ARRAY(res_values);if((start_temperature
这样就生成了一个温度值对应的ADC数组,可以粘贴到应用程序中。
/*基准电压:3.300000V 总电压:3.30V 上拉电阻10.000000K ADC最大值4095*/constuint16_tntc_adc[]={3595,3570,3544,3518,3491,/*-15 -14 -13 -12 -11 */3462,3433,3403,3372,3340,/*-10 -9 -8 -7 -6 */3307,3274,3239,3204,3168,/*-5 -4 -3 -2 -1 */3131,3093,3055,3016,2976,/*0 1 2 3 4 */2935,2894,2852,2810,2767,/*5 6 7 8 9 */2724,2680,2636,2591,2546,/*10 11 12 13 14 */2501,2456,2411,2365,2320,/*15 16 17 18 19 */2274,2228,2183,2137,2092,/*20 21 22 23 24 */2047,2002,1958,1914,1870,/*25 26 27 28 29 */1826,1783,1741,1699,1657,/*30 31 32 33 34 */1616,1576,1536,1497,1459,/*35 36 37 38 39 */1421,1384,1329,1311,1276,/*40 41 42 43 44 */1242,1208,1175,1143,1111,/*45 46 47 48 49 */1081,1050,1021,992,964,/*50 51 52 53 54 */937,910,884,859,835,/*55 56 57 58 59 */811,787,765,743,721,/*60 61 62 63 64 */700,680,660,641,623,/*65 66 67 68 69 */604,587,570,553,537,/*70 71 72 73 74 */522,507,492,478,464,/*75 76 77 78 79 */451,/*80 */};
4.2 实际应用
int8_tget_temp(uint16_tadc_val){constuint16_t* buff = ntc_adc;int8_tlow =0;int8_tmid =0;int8_thigh =LENGTH_OF_ARRAY(ntc_adc) -1;while(low <= high) { mid = (high + low) >>1;if(buff[mid] < adc_val) { high = mid -1; }elseif(buff[mid] > adc_val) { low = mid +1; }else{break; } }returnmid -15; }
5 获取资源
在本公众号回复关键字”NTC”获取相关资源
6 总结
如果AD值不稳定,可以在硬件上加入Π型滤波器和电压跟随器,在软件上加入卡尔曼滤波算法,如果做一个工具可以提高做事效率,那么就值得花一些时间去做,不是为别人,只是为了节省自己的时间,时间就是我们的生命。
- 电阻
+关注
关注
85文章
5297浏览量
170599 - 热电偶
+关注
关注
5文章
907浏览量
75190 - 热敏电阻
+关注
关注
13文章
1074浏览量
101199 - NTC
+关注
关注
7文章
385浏览量
51843 - 环境温度
+关注
关注
0文章
24浏览量
7829
发布评论请先登录
相关推荐
评论