NTC热敏电阻的应用

描述

1 NTC热敏电阻
NTC热敏电阻一般用于环境温度的测量,可以识别-20到100度,如果要采集更高的温度就需要用到热电偶了。

2 NTC热敏电阻R/T对照表

T(℃)    R(KΩ)        T(℃)   R(KΩ)       T(℃)    R(KΩ)
    -20.0   95.3370        20.5   12.2138        61.0    2.3820   
    -19.5   92.6559        21.0   11.9425        61.5    2.3394   
    -19.0   90.0580        21.5   11.6778        62.0    2.2977   
    -18.5   87.5406        22.0   11.4198        62.5    2.2568   
    -18.0   85.1009        22.5   11.1681        63.0    2.2167   
    -17.5   82.7364        23.0   10.9227        63.5    2.1775   
    -17.0   80.4445        23.5   10.6834        64.0    2.1390   
    -16.5   78.2227        24.0   10.4499        64.5    2.1013   
    -16.0   76.0689        24.5   10.2222        65.0    2.0644   
    -15.5   73.9806        25.0   10.0000        65.5    2.0282   
    -15.0   71.9558        25.5    9.7833        66.0    1.9928   
    -14.5   69.9923        26.0    9.5718        66.5    1.9580   
    -14.0   68.0881        26.5    9.3655        67.0    1.9240   
    -13.5   66.2412        27.0    9.1642        67.5    1.8906   
    -13.0   64.4499        27.5    8.9677        68.0    1.8579   
    -12.5   62.7122        28.0    8.7760        68.5    1.8258   
    -12.0   61.0264        28.5    8.5889        69.0    1.7944   
    -11.5   59.3908        29.0    8.4063        69.5    1.7636   
    -11.0   57.8038        29.5    8.2281        70.0    1.7334   
    -10.5   56.2639        30.0    8.0541        70.5    1.7037   
    -10.0   54.7694        30.5    7.8842        71.0    1.6747   
     -9.5   53.3189        31.0    7.7184        71.5    1.6462   
     -9.0   51.9111        31.5    7.5565        72.0    1.6183   
     -8.5   50.5445        32.0    7.3985        72.5    1.5910   
     -8.0   49.2178        32.5    7.2442        73.0    1.5641   
     -7.5   47.9298        33.0    7.0935        73.5    1.5378   
     -7.0   46.6792        33.5    6.9463        74.0    1.5120   
     -6.5   45.4649        34.0    6.8026        74.5    1.4867   
     -6.0   44.2856        34.5    6.6622        75.0    1.4619   
     -5.5   43.1403        35.0    6.5251        75.5    1.4375   
     -5.0   42.0279        35.5    6.3912        76.0    1.4136   
     -4.5   40.9474        36.0    6.2604        76.5    1.3902   
     -4.0   39.8978        36.5    6.1326        77.0    1.3672   
     -3.5   38.8780        37.0    6.0077        77.5    1.3447   
     -3.0   37.8873        37.5    5.8858        78.0    1.3225   
     -2.5   36.9246        38.0    5.7666        78.5    1.3008   
     -2.0   35.9892        38.5    5.6501        79.0    1.2795   
     -1.5   35.0801        39.0    5.5363        79.5    1.2586   
     -1.0   34.1965        39.5    5.4251        80.0    1.2381   
     -0.5   33.3378        40.0    5.3164        80.5    1.2180   
      0.0   32.5030        40.5    5.2102        81.0    1.1983   
      0.5   31.6915        41.0    5.1064        81.5    1.1789   
      1.0   30.9026        41.5    5.0049        82.0    1.1599   
      1.5   30.1355        42.0    4.9057        82.5    1.1412   
      2.0   29.3896        42.5    4.8088        83.0    1.1229   
      2.5   28.6644        43.0    4.7140        83.5    1.1050   
      3.0   27.9590        43.5    4.6213        84.0    1.0873   
      3.5   27.2730        44.0    4.5307        84.5    1.0700   
      4.0   26.6058        44.5    4.4421        85.0    1.0530   
      4.5   25.9567        45.0    4.3554        85.5    1.0363   
      5.0   25.3254        45.5    4.2707        86.0    1.0199   
      5.5   24.7111        46.0    4.1878        86.5    1.0038   
      6.0   24.1135        46.5    4.1068        87.0    0.9880   
      6.5   23.5320        47.0    4.0275        87.5    0.9725   
      7.0   22.9661        47.5    3.9500        88.0    0.9573   
      7.5   22.4154        48.0    3.8742        88.5    0.9424   
      8.0   21.8795        48.5    3.8000        89.0    0.9277   
      8.5   21.3579        49.0    3.7275        89.5    0.9133   
      9.0   20.8502        49.5    3.6565        90.0    0.8991   
      9.5   20.3559        50.0    3.5870        90.5    0.8852   
     10.0   19.8747        50.5    3.5190        91.0    0.8715   
     10.5   19.4063        51.0    3.4525        91.5    0.8581   
     11.0   18.9502        51.5    3.3875        92.0    0.8450   
     11.5   18.5060        52.0    3.3238        92.5    0.8320   
     12.0   18.0735        52.5    3.2615        93.0    0.8193   
     12.5   17.6523        53.0    3.2005        93.5    0.8068   
     13.0   17.2421        53.5    3.1408        94.0    0.7945   
     13.5   16.8426        54.0    3.0824        94.5    0.7825   
     14.0   16.4534        54.5    3.0252        95.0    0.7707   
     14.5   16.0743        55.0    2.9692        95.5    0.7590   
     15.0   15.7049        55.5    2.9144        96.0    0.7476   
     15.5   15.3450        56.0    2.8608        96.5    0.7364   
     16.0   14.9944        56.5    2.8082        97.0    0.7253   
     16.5   14.6528        57.0    2.7568        97.5    0.7145   
     17.0   14.3198        57.5    2.7065        98.0    0.7038   
     17.5   13.9954        58.0    2.6572        98.5    0.6933   
     18.0   13.6792        58.5    2.6089        99.0    0.6831   
     18.5   13.3710        59.0    2.5616        99.5    0.6729   
     19.0   13.0705        59.5    2.5153       100.0    0.6630   
     19.5   12.7777        60.0    2.4700      
     20.0   12.4922        60.5    2.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"


#define LENGTH_OF_ARRAY(A) sizeof(A)/sizeof(A[0])


#define CONFIG_MIN_TEMP         -15
#define CONFIG_MAX_TEMP         80
#define CONFIG_CNT_PRINTF_LNIE  5


FILE *fp = 0;


float res_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
};




static int8_t res_to_voltage(int16_t start_temperature,float vol_ref,float vol_total,float res_pull,uint16_t adc_max)
{
    uint16_t get_cnt = LENGTH_OF_ARRAY(res_values);


    if ((start_temperature

这样就生成了一个温度值对应的ADC数组,可以粘贴到应用程序中。

/*基准电压:3.300000V 总电压:3.30V 上拉电阻10.000000K ADC最大值4095*/ 
const uint16_t ntc_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_t get_temp(uint16_t adc_val)
{
    const uint16_t* buff = ntc_adc;
    int8_t low = 0;
    int8_t mid = 0;
    int8_t high = LENGTH_OF_ARRAY(ntc_adc) - 1;


    while (low <= high)
    {
        mid = (high + low) >> 1;


        if (buff[mid] < adc_val)
        {
            high = mid - 1;
        }
        else if (buff[mid] > adc_val)
        {
            low = mid + 1;
        }
        else
        {
            break;
        }
    }


    return mid - 15;
}

5 获取资源
在本公众号回复关键字”NTC”获取相关资源

6 总结
如果AD值不稳定,可以在硬件上加入Π型滤波器和电压跟随器,在软件上加入卡尔曼滤波算法,如果做一个工具可以提高做事效率,那么就值得花一些时间去做,不是为别人,只是为了节省自己的时间,时间就是我们的生命。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分