用EXCEL计算NTC、BS、电压等AD参数
2023-12-14 19:35:46
前言
之前计算NTC的AD值算得很麻烦,因为51内核的单片机不支持除法运算,更别说浮点运算了。
EXCEL自动算出参数就显得很方便了。
有纰漏请指出,转载请说明。
学习交流请发邮件 1280253714@qq.com
理论基础
参考这篇文章NTC热敏电阻温度采集与adc转换_adc温度转换-CSDN博客
根据NTC的AD值算温度
//编译环境 https://c.runoob.com/compile/11/
#include <stdio.h>
#define NUM_TEMP_BUFF 136
//NTC3435从-30到105,136个数据的计算值。
unsigned short tempBuff[NUM_TEMP_BUFF] = {
3959,3951,3942,3934,3925,3915,3906,3895,3885,3873, //-30~-21
3862,3850,3837,3824,3811,3797,3782,3767,3751,3735, //-20~-11
3718,3701,3683,3665,3646,3626,3606,3585,3564,3542, //-10~-1
3520,3497,3473,3449,3424,3398,3372,3346,3319,3291, //0~9
3263,3234,3205,3175,3145,3115,3083,3052,3020,2988, //10~19
2955,2922,2888,2855,2821,2786,2752,2717,2682,2647, //20~29
2612,2576,2541,2505,2469,2434,2398,2362,2326,2291, //30~39
2255,2220,2185,2149,2114,2080,2045,2010,1976,1942, //40~49
1909,1875,1842,1809,1777,1745,1713,1682,1651,1620, //50~59
1590,1560,1530,1501,1472,1444,1416,1389,1362,1335, //60~69
1309,1283,1258,1233,1208,1184,1161,1137,1115,1092, //70~79
1070,1049,1028,1007,986,966,947,928,909,890, //80~89
872,855,837,820,804,787,771,756,741,726, //90~99
711,697,683,669,655,642, //100~105
};
unsigned short tempData = 2000;
short returnTemp = 0;
//返回值,-88为大于105度,-99为小于-30度
short CaclTemp(unsigned short tempData1)
{
short i = 0;
while (1)
{
if (tempData1>tempBuff[0]) {
return -88;
} else if (tempData1<tempBuff[NUM_TEMP_BUFF-1]){
return -99;
}
if (tempBuff[i] >= tempData1) {
i++;
} else {
return i-31;
}
}
}
int main()
{
returnTemp = CaclTemp(tempData);
printf("%d",returnTemp);
return 0;
}
文章来源:https://blog.csdn.net/weixin_45817947/article/details/135001938
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!