教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 互联网资料 >

基于AT89C51的智能电风扇调速器的设计2(5)

来源:网络收集 时间:2026-09-07
导读: 宿州学院毕业论文 基于AT89C51电风扇智能调速器的设计 附录一 数字温度传感器模块和显示子模块程序: #include #define uchar unsigned char #define uint unsigned int sfr Dat_Port=0x80; sbit ge=P2^6; sbit shi=

宿州学院毕业论文 基于AT89C51电风扇智能调速器的设计

附录一

数字温度传感器模块和显示子模块程序:

#include

#define uchar unsigned char #define uint unsigned int sfr Dat_Port=0x80; sbit ge=P2^6; sbit shi=P2^7; sbit TMDAT= P3^7;

uchar code table[]={0x3F,0x06,0x5B,0x4F,

0x66,0x6D,0x7D,0x07,

0x7F,0x6F}; uchar tmpbuf[2]; void Delay(int useconds) { }

uchar Reset_Bus(void) {

int s;

for (s=0; s

uchar presence; TMDAT=0; Delay(29); TMDAT=1; Delay(3); presence=TMDAT;

21

宿州学院毕业论文 基于AT89C51电风扇智能调速器的设计

Delay(25); return(presence);

}

void Write_Bit(char bitval) { TMDAT=0;

if(bitval==1) TMDAT=1; Delay(5); TMDAT=1;

}

void Write_Byte(char val) { uchar I; uchar temp; for (i=0;i<8;i++) { temp=val>>i; temp&=0x01; Write_Bit(temp);

}

Delay(5);

}

uchar Read_Bit(void) { uchar i; TMDAT=0;

TMDAT=1;

22

宿州学院毕业论文 基于AT89C51电风扇智能调速器的设计

}

uchar Read_Byte(void) {

uchar i; }

uint DS18B20_Tmp_Read(void) {

for(i=0;i<3;i++); return(TMDAT);

uchar value=0; for (i=0;i<8;i++) { }

return(value);

if(Read_Bit()) value|=0x01<

uint TEMP;

uchar TEMP_LSB,TEMP_MSB; Reset_Bus(); Write_Byte(0xCC); Write_Byte(0x44); Delay(5); Reset_Bus(); Write_Byte(0xCC); Write_Byte(0xBE);

TEMP_LSB=Read_Byte(); TEMP_MSB=Read_Byte();

23

宿州学院毕业论文 基于AT89C51电风扇智能调速器的设计

TEMP=TEMP_MSB; TEMP=TEMP<<8;

TEMP=TEMP|TEMP_LSB; return TEMP;

}

void Display(void) { uchar j; j=tmpbuf[0]; Dat_Port=table[j]; shi=0; Delay(5); shi=1; Delay(5); j=tmpbuf[1]; Dat_Port=table[j]; ge=0; Delay(5); ge=1;

}

void main(void) { uint tmp; uchar I,tmph; while(1) {

tmp=DS18B20_Tmp_Read();

24

宿州学院毕业论文 基于AT89C51电风扇智能调速器的设计

tmph=(uchar)((tmp>>4)&0xff); tmpbuf[1]=tmph; tmpbuf[0]=(tmph0)/10; for(i=0;i<20;i++) { Display();

}

}

}

附录二

电机调速与控制子模块主程序: #include #define uchar unsigned char #define uint unsigned int sbit Fan=P3^2; uchar t1; void init() { uint tmp;

tmp=DS18B20_Tmp_Read();

Fan=1; /* TMOD=0x01;

TH0=(65536-50000)/256; TL0=(65536-50000)%6; EA=1;

EX0=1;

25

导通*/

基于AT89C51的智能电风扇调速器的设计2(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/445168.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)