44、基于51单片机的热敏电阻的数字温度计(AD1674)(程序+Proteus仿真)

编号:44

基于51单片机的热敏电阻的数字温度计(AD1674)

功能描述:

      本设计由51单片机最小系统+AD1674模块+热敏电阻模块+液晶1602显示模块
1、主控制器是89C82单片机
2、AD1674模块模数转换器进行A/D转换,读取热敏电阻值电压数据,将模拟量转换为温度,温度精度(0.5℃);
3、液晶1602显示温度

Proteus7.8以上版本均可使用

视频演示链接:

仿真图:

44、基于51单片机的热敏电阻的数字温度计(AD1674)(程序+Proteus仿真)_第1张图片

程序源码:

#include "reg52.h"
#include "LCD1602.h"
#include "delay.h"
#include "AD1674.h"
#include "math.h"


code unsigned int VOL[]={		
343,	339,	339,	335,	332,	332,	328,	324,	320,	320,	
316,	312,	312,	308,	304,	300,	300,	296,	292,	292,
289,	285,	285,	281,	277,	273,	273,	269,	265,	265,	
261,	257,	257,	253,	250,	250,	246,	242,	242,	238,
234,	234,	230,	230,	226,	222,	222,	218,	218,	214,	
210,	210,	207,	207,	203,	199,	199,	195,	195,	191,
191,	187,	187,	183,	179,	179,	175,	175,	171,	171,	
167,	167,	164,	164,	160,	160,	160,	156,	156,	152,
152,	148,	148,	144,	144,	140,	140,	140,	136,	136,	
132,	132,	132,	128,	128,	125,	125,	125,	121,	121,
121,	117,	113,	109,	109,	105,	101,	101,	97,		97,
93,		89,		89,		85,		85,		82,		82,		78,		78,		74,	
74,		70,		70,		66,		66,		66,		62,		62,		58,		58,	
58,		54,		54,		54,		50,		50,		50,		46,		46,		46,	
42,		42,		42,		42,		39,		39,		39,		39,		35,		35};

code unsigned int Temper[]={		
100,	150,	200,	250,	300,	350,	400,	450,	500,	550,	
600,	650,	700,	750,	800,	850,	900,	950,	1000,	1050,
1100,	1150,	1200,	1250,	1300,	1350,	1400,	1450,	1500,	1550,	
1600,	1650,	1700,	1750,	1800,	1850,	1900,	1950,	2000,	2050,
2100,	2150,	2200,	2250,	2300,	2350,	2400,	2450,	2500,	2550,	
2600,	2650,	2700,	2750,	2800,	2850,	2900,	2950,	3000,	3050,
3100,	3150,	3200,	3250,	3300,	3350,	3400,	3450,	3500,	3550,	
3600,	3650,	3700,	3750,	3800,	3850,	3900,	3950,	4000,	4050,
4100,	4150,	4200,	4250,	4300,	4350,	4400,	4450,	4500,	4550,	
4600,	4650,	4700,	4750,	4800,	4850,	4900,	4950,	5000,	5050,
5100,	5200,	5300,	5400,	5500,	5600,	5700,	5800,	5900,	6000,
6100,	6200,	6300,	6400,	6500,	6600,	6700,	6800,	6900,	7000,	
7100,	7200,	7300,	7400,	7500,	7600,	7700,	7800,	7900,	8000,	
8100,	8200,	8300,	8400,	8500,	8600,	8700,	8800,	8900,	9000,	
9100,	9200,	9300,	9400,	9500,	9600,	9700,	9800,	9900,	10000};


void main(void)
{
	
	unsigned char i,flag=0;
	unsigned int result,temp1,temp2;
	unsigned int AD_Result = 0;	 					//A/D转换结果
	unsigned int Voltage0 = 0;						//电压值 这个值是扩大了一百倍的 为了方便显示	
	Lcd1602_Init();		  							//LCD1602液晶初始化
	Lcd1602_String(0,0,"             ");
	Lcd1602_String(0,1,"             ");
	while(1)
	{		
		AD_Result = AD1674_Read();					//读取AD1674A/D转换结果数据		
		Voltage0 = (float)AD_Result * 1000/ 4095 ; ;  	//转换为电压值 10.00是对应0-10V范围
		Voltage0 = Voltage0 -1;		  					//修复误差

		temp1 = abs(Voltage0-VOL[0]);
		for(i=1;i<150;i++)
		{
			temp2=abs(Voltage0-VOL[i]);
			if(temp1>=temp2)
			{
				temp1=temp2;
				flag=i;
			}
		}
		Lcd1602_String(0,0,"Temp:");	  				//显示温度
		Lcd1602_Write_Data(Temper[flag]/1000+0x30);
		Lcd1602_Write_Data(Temper[flag]%1000/100+0x30);
		Lcd1602_Write_Data('.');
		Lcd1602_Write_Data(Temper[flag]%1000%100/10+0x30);
		Lcd1602_Write_Data(Temper[flag]%1000%100%10+0x30);
		Lcd1602_Write_Data(0xdf);
		Lcd1602_Write_Data('C');
		delay_ms(100);

	}
}

软件免费下载地址:

1、Proteus仿真软件
文件内容:Proteus7.8安装包、Proteus8.6安装包、Proteus.8.10安装包、Proteus Professional 8.11 SP0安装包

链接:https://pan.baidu.com/s/11LNUZ9BJXWvXf1C4dPc3_w 
提取码:2756 


3、KEIL5 MDK软件(STM32开发软件)
链接:https://pan.baidu.com/s/1t3eY-3yRdTa7jZMlijq_jg 

提取码:ab58 

文件下载:

链接:https://pan.baidu.com/s/18WjjHdplcP4JDmiLXGlw4A?pwd=ke5n 
提取码:ke5n

你可能感兴趣的:(项目合集,51单片机,proteus,嵌入式硬件)