傻大方


首页 > 学习 >

基于|基于单片机的太阳能热水器水温监控系统( 六 )



按关键词阅读: 系统 单片机 基于 监控 太阳能热水器 水温



32、经完成了一个比较完整的温度检测预与报警系统 。
它可以通过键盘输入温度上限、下限值 , 然后计算其上限和下限的中间值作为最适温度值 。
不断的采集温度值 , 显示温度值 , 如果发现采集的温度值高于上限值就通过相应的提示灯亮 。
如果采集的温度值低于下限值 , 那么也有相应的灯提示操作人员 。
如果并没有超过上下限则不会报警 。
致此本人设计基本完成了预期的目标 , 系统在温度采集、温度处理和键盘处理方面做的比较好 , 而在数据的存储和数码管的显示方面不够理想 。
主要存在以下几个方面:(1) 程序的代码不够精练 , 浪费AT89S52内的FLASH ROM;(2) 未对以前的温度数值进行存储 , 使以后不能利用这些数据;(3) 对数码管的控制考虑 。

33、不周 , 以致出现闪烁现象;参考文献1 李国勇 过程控制系统 电子工业出版社 20092 何立民.单片机应用系统设计系统配置与接口技术M.北京:北京航空航天大学 , 1990.3 李晓荃.单片机原理与应用M. 北京:电子工业出版社 , 2000.4谢自美.电子线路设计.实验.测试(第二版) M.武汉:华中科技大学出版社 , 2000.5 马忠梅,刘滨,戚军,马岩.单片机C语言Windows环境编程宝典M.北京:北京航空航天大学出版社,20036 Richard c.Dorf.modern conctrol systermM.BEIJING:Science Publishing House , 2002.附录一:系 。

34、统原理图附录二: 程序代码#include /52系列头文件#include #define uchar unsigned char#define uint unsigned intsbit ds=P34;
sbit dula=P26;
sbit beep=P14;
/定义蜂鸣器sbit led=P11;
sbit jdq=P10;
uint temp,t,w;
/定义整型的温度数据uchar flag;
float f_temp;
/定义浮点型的温度数据uint low;
/定义温度下限值 是温度乘以10后的结果uint high;
/定义温度的上限值sbit led1=P10;
/控制发光二极管sb 。

35、it led2=P11;
/控制发光二极管sbit s1=P35;
sbit s2=P36;
sbit s3=P37;
uchar flag1,flag2,flag3,flag4,s1num,qian,bai,shi,ge;
uchar code table=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xc6;
/共阳数码管段码表uchar code table1=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10;
/带小数点的编码 void delay(uchar z) /延时函数uchar a, 。

36、b;
for(a=z;
a0;
a-)for(b=100;
b0;
b-);
void init()EA=1;
ET1=1;
TR1=1;
TMOD=0x10;
TH1=(65536-4000)/256;
TL1=(65536-4000)%256;
flag=0;
high=100;
jdq=1;
void didi()beep=0;
led=0;
delay(500);
beep=1;
led=1;
delay(500);
void dsreset(void) /DS18b20复位 ,初始化函数uint i;
ds=0;
i=103;
/延时最短480uswhile(i0) i-;
ds=1;
/等待16-60us , 收到低电平一个约60- 。

37、240us则复位成功i=4;
while(i0) i-;
bit tempreadbit(void) /读1位数据函数uint i;
bit dat;
ds=0;
i+;
ds=1;
i+;
i+;
/i+起到延时作用dat=ds;
i=8;
while(i0)i-;
return(dat);
uchar tempread(void)/读1字节的数据函数uint i,j,dat;
dat=0;
for(i=1;
i1);
/读出的数据最低位在最前面 , 这样刚好一个字节在dat里return(dat);
void tempwritebyte(uchar dat) /向DS18B20写一个字节的数据函数uint i;
uchar j;


38、bit testb;
for(j=1;
j1;
if(testb) /写1ds=0;
i+;
i+;
ds=1;
i=8;
while(i0)i-;
else /写0ds=0;
i=8;
while(i0) i-;
ds=1;
i+;
i+;
void tempchange(void) /DS18B20开始获取温度并转换dsreset();
delay(1);
tempwritebyte(0xcc);
/写跳过读ROM指令tempwritebyte(0x44);
/写温度转换指令uint get_temp()/读取寄存器中存储的温度数据uchar a,b;
dsreset();
delay(1);
tempwritebyte(0xcc 。

39、);
/写跳过读ROM指令tempwritebyte(0xbe);
/写温度转换指令a=tempread();
/读低8位b=tempread();
/读高8位 temp=256*b+a;
f_temp=temp*0.0625;
/温度在寄存器中为12位 , 分辨率为0.0625temp=f_temp*10+0.5;
/乘以10表示小数点后面只取一位return temp;
/temp是整型void keyscan()if(s1=0)P2=0xff;
delay(5);
if(s1=0) while(!s1);
s1num+;
if(s1num=1) flag=1;
if(s1num=2)s1num=0;
fl 。

40、ag=0;
if(s1num=1)flag=1;
if(s2=0) delay(5);
if(s2=0)while(!s2);
high+=10;
if(high=1000)high=100;
if(s3=0)delay(5);
if(s3=0)while(!s3);
high-=10;
if(high=0)high=100;
void main()/主函数init();
while(1)tempchange();
/温度转换函数if(temp=high-10)&(temphigh)&(temphigh+10)jdq=1;
didi();
void time1() interrupt 3TH1=(65536-4000) 。

41、/256;
TL1=(65536-4000)%256;
t+;


稿源:(未知)

【傻大方】网址:/a/2021/0902/0024074601.html

标题:基于|基于单片机的太阳能热水器水温监控系统( 六 )


上一篇:青峰|青峰岭实习报告

下一篇:消防|消防道路施工方案#陕西