ntc 电阻计算软件 有砖头例程
本帖最后由 lihw2@ 于 2012-9-21 10:57 编辑做一个温度计 用到了ntc 在网上找到了一个ntc热电阻计算软件还不错。
#include <USART.h>
#include<intrins.h>
#include "adc.h"
#define uchar unsigned char
#define uint unsigned int
#define u32 unsigned long int
uint code AD_Result = {
982,980,978,976,974,0x3CB,0x3C9,0x3C6,0x3C4,0x3C1,
0x3BE,0x3BB,0x3B8,0x3B5,0x3B2,0x3AE,0x3AB,0x3A7,0x3A4,0x3A0,
0x39C,0x398,0x394,0x390,0x38C,0x387,0x383,0x37E,0x37A,0x375,
0x370,0x36B,0x366,0x360,0x35B,0x355,0x350,0x34A,0x344,0x33E,
0x338,0x332,0x32C,0x326,0x31F,0x319,0x312,0x30B,0x305,0x2FE,
0x2F7,0x2F0,0x2E9,0x2E2,0x2DB,0x2D3,0x2CC,0x2C5,0x2BD,0x2B6,
0x2AE,0x2A7,0x29F,0x298,0x290,0x288,0x281,0x279,0x271,0x269,
0x262,0x25A,0x252,0x24B,0x243,0x23B,0x234,0x22C,0x224,0x21D,
0x215,0x20E,0x206,0x1FF,0x1F7,0x1F0,0x1E9,0x1E2,0x1DA,0x1D3,
0x1CC,0x1C5,0x1BE,0x1B7,0x1B0,0x1AA,0x1A3,0x19C,0x196,0x18F,
0x189,0x183,0x17C,0x176,0x170,0x16A,0x164,0x15E,0x158,0x153,
0x14D,0x147,0x142,0x13D,0x137,0x132,0x12D,0x128,0x123,0x11E,
0x119,0x114,0x10F,0x10B,0x106,0x102,0xFD,0xF9,245,241,
0xED
};
char code Temp_Value = {
-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99,
100,101,102,103,104,105,106,107,108,109,
110,111,112,113,114,115,116,117,118,119,
120
};
uint next;
uint temp;
uint volat;
int tempx;
uint volatx;
int tempy;
uint volaty;
char code dx516 _at_ 0x00ff;
void tempcl();
void volatcl();
uint temcha(uint dat);
void t0() interrupt 1 //计数器0.计时
{
TR0=0;
TH0=(65535-59090)/256;
TL0=(65535-59090)%256; //重装计时值
if(next<10)
{
temp=adc_dat(0);
}
if((next>=10)&&(next<20))
{
volat=adc_dat(4);
}
next++;
if(next==12)
{
tempcl();
}
if(next==22)
{
volatcl();
next=0;
}
WDT_CONTR=0x3b;
TR0=1;
}
//*******************************主函数******************************/
main() //主函数
{
float vv;
P0M0=0XFF;
P1M1=0XFF;
UartInit();
adc_pwon();
//START_HT1621();
SETUP_HT1621();
TMOD &= 0XF0;
TMOD |= 0X01; //
TH0=(65535-60000)/256;
TL0=(65535-60000)%256;
TR0=1; //定时器0 启动
ET0=1; //定时器0中断允许
while(1)
{
vv = 196.0/1024.0;
tempy=temcha(tempx);
// volaty = volatx*(150/1024);
volaty = volatx*vv;
display(tempy,volaty);
//全显示
}
}
uint temcha(uint dat)
{ uchar j;
for (j=0;j<130;j++)
{
if( (dat<=AD_Result) && (dat>AD_Result) )
{
break;
}
}
return(Temp_Value );
}
void tempcl()
{
uchar i,j;
uint tem;
for (j=0;j<9;j++)
{
for (i=j;i<9;i++)
{
if(temp>temp)
{
tem = temp;
temp = temp;
temp = tem;
}
}
}
tempx= (temp+temp+temp+temp+temp+temp)/6;
}
void volatcl()
{
uchar i,j;
uint tem;
for (j=0;j<5;j++)
{
for (i=0;i<5;i++)
{
if ( volat>volat )
{
tem = volat;
volat = volat;
volat = tem;
}
}
}
volatx = (volat+volat+volat+volat+volat+volat)/6;
SendDec(volatx);
}
自己顶顶一下 ,还有 那位大大能给个插值的算法啊? 好东西哦。{:handshake:}{:victory:} http://www.amobbs.com/forum.php?mod=viewthread&tid=5499024&highlight=ntc 楼主,你分享的正是我用得着的.谢谢了. MARK!NTC插值计算器 不同的系统误差不知道会有多大? 金山毒霸,报毒啊!
楼主杀毒试试。 不错,以后用到时算算,谢了楼主 我一直用的卡巴,没有报毒。 找了很久,感谢分享 不错,收藏 NTC插值计算器 设个软件很好用 哦,精度很高! 好东西啊,收藏收藏,实用! 标记看看 好东西啊,收藏收藏,实用! 试用了一下不错。。。以前都用Excel。。。。姿势+1咯 正好需要 找了好久了. 先学习一下了 标记,以后应该会用到。 不错支持回复 这个软件不错,感谢分享~~~ 支持楼主!!! 不错不错,很实用的东西,谢谢分享 谢谢分享 win7下运行不了呢? ntc计算软件,谢谢分享 mark, ntc 温度计算 好东西谢谢分享 谢谢分享 好软件,收藏了,感谢分享 收藏了哈 好东西,主楼顶{:smile:}{:handshake:} {:smile:}谢谢 需要 用这种技术的温度控制器还有很多,水浴锅上面的都是这种温控! 谢谢分享
页:
[1]