基于单片机多功能创意万年历原理图
- 格式:pdf
- 大小:120.11 KB
- 文档页数:1
数字钟、万年历制作(基于单片机)电路原理图:程序://********************20131206****数字钟程序#pragma SMALL#include <reg51.h>#include <absacc.h>#include <intrins.h>//********************************************************* *********编译预处理void display(unsigned char *p); //显示函数,P为显示数据首地址unsigned char keytest(); //按键检测函数unsigned char search(); //按键识别函数void alarm(); //闹钟判断启动函数void ftion0(); //始终修改函数void ftion1(); //闹钟修改函数void ftion3(); //日期修改函数void cum(); //加1修改函数void minus(); //减1修改函数void jinzhi(); //进制修改函数void riqi(); //日期void stopwatch(); //秒表函数//********************************************************* *******函数声明sbit P2_7=P2^7;//********************************************************* *******端口定义unsigned char clockbuf[3]={0,0,0};unsigned char bellbuf[3]={0,0,0};unsigned char date[3]={1,1,1}; //日期存放数组unsigned char stop[3]={0,0,0};unsigned char msec1,msec2;unsigned char timdata,rtimdata,dtimdata;unsigned char count;unsigned char *dis_p;unsigned char or; //12进制控制标志unsigned char ri; //日期显示控制标志位unsigned char mb; //秒表控制标志位bit arm,rtim,rhour,rmin,hour,min,sec,day,mon,year; //定义位变量//********************************************************* *****全局变量定义void main(){unsigned char a;or=0; //12进制修改标志清零ri=0;mb=0;P2_7=0;arm=0;msec1=0;msec2=0;timdata=0;rtimdata=0;count=0;TMOD=0x12;TL0=0x06;TH0=0x06;TH1=(65536-10000)/256;TL1=(65536-10000)%256;EA=1;ET0=1;ET1=1;TR0=1;TR1=0;dis_p=clockbuf;while(1){a=keytest();if(a==0x78) //判断是否有键按下{display(dis_p);if(arm==1) alarm();}else{display(dis_p);a=keytest();if(a!=0x78){a=search();switch(a){case 0x00:ftion0();break;case 0x01:ftion1();break;case 0x02:cum();break;case 0x06:jinzhi();break;case 0x03:riqi();break;case 0x04:ftion3();break;case 0x05:minus();break;case 0x07:stopwatch();break;case 0x09:TR1=1;break;case 0x0a:TR1=0;break;case 0x0b:stop[0]=0;stop[1]=0;stop[2]=0;break;default:break;}}}}}//********************************************主函数【完】void display(unsigned char *p){unsigned char buffer[]={0,0,0,0,0,0};unsigned char k,i,j,m,temp;unsigned char led[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};buffer[0]=p[0]/10;buffer[1]=p[0]%10;buffer[2]=p[1]/10;buffer[3]=p[1]%10;buffer[4]=p[2]/10;buffer[5]=p[2]%10;if((sec==0)&&(min==0)&&(hour==0)&&(rmin==0)&&(rhour==0)&&( day==0)&&(mon==0)&&(year==0)) //没有修改标志,正常显示{for(k=0;k<3;k++){temp=0x01;for(i=0;i<6;i++){P0=0x00; //段选端口j=buffer[i];P0=led[j];P1=~temp; //位选端口temp<<=1;for(m=0;m<200;m++);}}}else //若有修改标志,则按以下标志分别显示{if(sec==1||day==1){P1=0x1f;i=buffer[5];P0=led[i];for(m=0;m<200;m++);P1=0x2f;j=buffer[4];P0=led[j];for(m=0;m<200;m++);}if(min==1||rmin==1||mon==1){P1=0x3b;i=buffer[2];P0=led[i];for(m=0;m<200;m++);P1=0x37;j=buffer[3];P0=led[j];for(m=0;m<200;m++);}if(hour==1||rhour==1||year==1) {P1=0x3e;i=buffer[0];P0=led[i];for(m=0;m<200;m++);P1=0x3d;j=buffer[1];P0=led[j];for(m=0;m<200;m++);}}}//**********************************LED显示函数【完】unsigned char keytest(){unsigned char c;P2=0x78; //检测是否有键按下c=P2;c=c&0x78;return(c);}//******************************************键盘检测函数【完】unsigned char search(){unsigned char a,b,c,d,e;c=0x3f;a=0; //行号while(1){P2=c;d=P2;d=d&0x07;if(d==0x03){b=0;break;} //列号else if(d==0x05){b=1;break;}else if(d==0x06){b=2;break;}a++;c>>=1;if(a==5){a=0;c=0x3f;}}e=a*3+b;do{display(dis_p);}while((d=keytest())!=0x78);return(e);}//***********************************************查键值函数【完】void alarm(){if((clockbuf[0]==bellbuf[0])&&(clockbuf[1]==bellbuf[1])){P2_7=1;rtim=1;if(count==10){count=0;P2_7=0;arm=0;rtim=0;}}}//****************************************闹钟判断启动函数【完】void ftion0(){TR0=0;rhour=0;rmin=0;dis_p=clockbuf;rtimdata=0;timdata++;switch(timdata){case 0x01:sec=1;break;case 0x02:sec=0;min=1;break;case 0x03:min=0;hour=1;break;case 0x04:timdata=0;hour=0;TR0=1;break;default:break;}}//*********************************************时钟设置函数【完】void ftion1(){if(TR0==0) TR0=1;sec=0;min=0;hour=0;dis_p=bellbuf;timdata=0;rtimdata++;switch(rtimdata){case 0x01:rmin=1;break;case 0x02:rmin=0;rhour=1;break;case 0x03:rtimdata=0;rhour=0;arm=1;dis_p=clockbuf;break;default:break;}}//*********************************************闹钟设置函数【完】void ftion3(){if(TR0==0) TR0=1;day=0;mon=0;year=0;dis_p=date;timdata=0;rtimdata=0;dtimdata++;switch(dtimdata){case 0x01:day=1;break;case 0x02:day=0;mon=1;break;case 0x03:mon=0;year=1;break;case 0x04:dtimdata=0;year=0;dis_p=clockbuf;break;default:break;}}//*************************************************日期修改函数【完】void minus(){if(sec==1){if(0==clockbuf[2]) clockbuf[2]=59;else clockbuf[2]--;}else if(min==1){if(0==clockbuf[1]) clockbuf[1]=59;else clockbuf[1]--;}else if(hour==1){if(or==0) //判断进制{if(0==clockbuf[0]) clockbuf[0]=23;else clockbuf[0]--;}if(or==1){if(1==clockbuf[0]) clockbuf[0]=12;else clockbuf[0]--;}}else if(rmin==1){if(bellbuf[1]==0) bellbuf[1]=59;else bellbuf[1]--;}else if(rhour==1){if(or==0){if(bellbuf[0]==0) bellbuf[0]=23;else bellbuf[0]--;}if(or==1){if(bellbuf[0]==1) bellbuf[0]=12;else bellbuf[0]--;}}else if(day==1){if(date[2]==1) date[2]=31;else date[2]--;}else if(mon==1){if(date[1]==1) date[1]=12;else date[1]--;}else if(year==1){if(date[0]==1) date[0]=99;else date[0]--;}}//*************************************减1修改功能函数【完】void cum(){if(sec==1){if(59==clockbuf[2]) clockbuf[2]=0;else clockbuf[2]++;}else if(min==1){if(59==clockbuf[1]) clockbuf[1]=0;else clockbuf[1]++;}else if(hour==1){if(or==0) //判断进制{if(23==clockbuf[0]) clockbuf[0]=0;else clockbuf[0]++;}if(or==1){if(12==clockbuf[0]) clockbuf[0]=1;else clockbuf[0]++;}}else if(rmin==1){if(bellbuf[1]==59) bellbuf[1]=0;else bellbuf[1]++;}else if(rhour==1){if(or==0){if(bellbuf[0]==23) bellbuf[0]=0;else bellbuf[0]++;}if(or==1){if(bellbuf[0]==12) bellbuf[0]=1;else bellbuf[0]++;}}else if(day==1){if(date[2]==31) date[2]=1;else date[2]++;}else if(mon==1){if(date[1]==12) date[1]=1;else date[1]++;}else if(year==1){if(date[0]==99) date[0]=0;else date[0]++;}}//*************************************加1修改功能函数【完】void jinzhi(){if(or==0) or=1;else or=0;}//***********************************进制修改控制函数【完】void riqi(){if(ri==0){dis_p=date;}if(ri==1){dis_p=clockbuf;}ri++;if(ri==2) ri=0;}//********************************日期控显示函数【完】void stopwatch(){if(mb==0){dis_p=stop;mb=1;}else{mb=0;dis_p=clockbuf;}}//************秒表**********秒表**********秒表函数【完】void clock() interrupt 1{EA=0;if(msec1!=0x14) msec1++; //6MHz晶振定时10mselse{msec1=0;if(msec2!=100) msec2++; //定时1selse{if(rtim==1) count++; //闹钟启动标志计时10smsec2=0;if(clockbuf[2]!=59) clockbuf[2]++;else{clockbuf[2]=0;if(clockbuf[1]!=59) clockbuf[1]++;else{clockbuf[1]=0;if(or==0){if(clockbuf[0]!=23) clockbuf[0]++;else{clockbuf[0]=0;if((date[1]==1)||(date[1]==1)||(date[1]==1)||(date[1]==3)||(date[ 1]==5)||(date[1]==7)||(date[1]==8)||(date[1]==10)||(date[1]==12)){if(date[2]!=30) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}if((date[1]==4)||(date[1]==6)||(date[1]==9)||(date[1]==11)){if(date[2]!=29) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}if(date[1]==2){if((((date[0]%4==0)&&(date[0]%100!=0))||(date[0]%400==0))){if(date[2]!=28) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}else{if(date[2]!=27) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}}}}if(or==1){if(clockbuf[0]!=12) clockbuf[0]++;else{clockbuf[0]=0;if((date[1]==1)||(date[1]==1)||(date[1]==1)||(date[1]==3)||(date[ 1]==5)||(date[1]==7)||(date[1]==8)||(date[1]==10)||(date[1]==12)){if(date[2]!=30) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}if((date[1]==4)||(date[1]==6)||(date[1]==9)||(date[1]==11)){if(date[2]!=29) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}if(date[1]==2){if((((date[0]%4==0)&&(date[0]%100!=0))||(date[0]%400==0))){if(date[2]!=28) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}else{if(date[2]!=27) date[2]++;else{date[2]=1;if(date[1]!=11) date[1]++;else{date[1]=1;date[0]++;}}}}}}}}}}EA=1;}//*******************************定时器0中断函数【完】void miaobiao() interrupt 3{TH1=(65536-10000)/256;TL1=(65536-10000)%256;if(stop[2]!=99) stop[2]++;else{stop[2]=0;if(stop[1]!=59) stop[1]++;else{stop[1]=0;if(stop[0]!=59) stop[0]++;else stop[0]=0;}}}//***********************************定时器1中断函数【完】。
51单片机做的12864万年历这是我花了一个星期时间做的万年历;一开始是一些图片,后面是这个制作的C语言源程序;希望大家稀饭:Main.c#include "reg52.h"#include "macroconst.h"#include "keyscan.h"#include "screen.h"#include "18b20.h"#include "ds1302.h"#include "atao_12864.h"#include "24c02.h"idata unsigned char state1[1];unsigned char screennum=1;//屏幕号#define time_task_sec 200 //节拍200Hz#define clock 24000000 //晶振#define max_task 4 //最大任务数idata unsigned char task_delay[4];#define task_delay0 time_task_sec/1 //2赫兹18b20 #define task_delay1 time_task_sec/5 //10赫兹屏幕#define task_delay2 time_task_sec/3 //4赫兹1302 #define task_delay3 time_task_sec/20 //20赫兹键盘void init(){unsigned char i;init18b20();ds1302_init();initina1(); //---------------------------LCD字库初始化程序RdFromROM(state1,8,1);state[0]=state1[0]; //-------界面RdFromROM(state1,15,1);state[1]=state1[0];//------- 闹钟RdFromROM(state1,11,1);key_sound=state1[0];//-------按键音// state[2]=state1[2];// state[3]=state1[3];screennum=1;//------默认一号屏for(i=0;i<max_task;i++)//清除任务延时{task_delay[i]=0;}TMOD=0x11;EA=1;TH0=255-clock/time_task_sec/12/526;TL0=255-clock/time_task_sec/12%526;ET0=1;TR0=1;}void main(){init();while(1){ if(task_delay[0]==0){readtemp(); task_delay[0]=task_delay0;} if(task_delay[3]==0){MenuCheckKey();task_delay[3]=task_delay1;}if(task_delay[1]==0){screen_select(screennum);task_delay[1]=task_delay1;} if(task_delay[2]==0){ds1302_read_time(); task_delay[2]=task_delay0;} }}void timer0() interrupt 1{uchar i=0;TH0=255-clock/time_task_sec/12/526;TH1=255-clock/time_task_sec/12%526;for(i=0;i<max_task;i++)if(task_delay[i]) task_delay[i]--; // miao=21,fen=33,xiaomiao=94;if(ma_start==1){tt++;if(tt==8){tt=0;xiaomiao++;if(xiaomiao==99){xiaomiao=0;miao++;if(miao==60){miao=0;fen++;if(fen==99){fen=0;}}}}}}Screen.c:#include "reg52.h"#include "macroconst.h"#include "delay.h"#include "18b20.h"#include "atao_12864.h"#include "ds1302.h"#include "24c02.h"#include "festival.h"#include "keyscan.h"idata unsigned char miao=0,fen=78,xiaomiao=0,tt=0;idata unsigned char bai,shi,ge,shinian,genian,shiyue,geyue,shiri,geri,shishi,geshi,shifen,gefen,shimi ao,gemiao;idata unsigned char Number[4];unsigned char code mainmenu[]={" 主菜单""3.查询 4.温度""1.调时 2.秒表""5.设置 6.返回"};unsigned char code setmenu[]={" 设置""3.查温 4.按键""1.界面 2.闹铃""5.报时 6.返回"};void gettime(){shinian=(time_buf1[1]%100)/10;genian=(time_buf1[1]%100)%10;shiyue=(time_buf1[2])/10;geyue=(time_buf1[2])%10;shiri=(time_buf1[3])/10;geri=(time_buf1[3])%10;shishi=(time_buf1[4])/10;geshi=(time_buf1[4])%10;shifen=(time_buf1[5])/10;gefen=(time_buf1[5])%10;shimiao=(time_buf1[6])/10;gemiao=(time_buf1[6])%10;}void screen_select(uchar num){// initina1();gettime() ;if(num==1) //----------主界面{Lcd_Set_Post(1,0);TransferData(shinian+48,1);//----------------------年TransferData(genian+48,1);TransferData('/',1);TransferData(shiyue+48,1);//----------------------月TransferData(geyue+48,1);TransferData('/',1);TransferData(shiri+48,1);//----------------------日TransferData(geri+48,1);Lcd_Set_Post(1,4);if(state[1]==1)//----------------闹铃的状态图标{TransferData(' ',1);TransferData(14,1);}Lcd_Set_Post(1,5);if(key_sound==1){TransferData(13,1);}if(state[0]==0){Lcd_Set_Post(1,7); //----------------农历年nian(0);Lcd_Set_Post(2,0);//----------------------- 农历日月LCD_WRITE_CHAR("农历");Conversion(0,time_buf[1],time_buf[2],time_buf[3]);TransferData(month_moon/16+'0',1);TransferData(month_moon%16+'0',1);TransferData('/',1);TransferData(day_moon/16+'0',1);TransferData(day_moon%16+'0',1);}if(state[0]==1){Lcd_Set_Post(3,5);}else {Lcd_Set_Post(2,5);}LCD_WRITE_CHAR("星期");//----------------------星期if(time_buf1[7]==7) {LCD_WRITE_CHAR("日");}if(time_buf1[7]==6) {LCD_WRITE_CHAR("六");}if(time_buf1[7]==5) {LCD_WRITE_CHAR("五");}if(time_buf1[7]==4) {LCD_WRITE_CHAR("四");}if(time_buf1[7]==3) {LCD_WRITE_CHAR("三");}if(time_buf1[7]==2) {LCD_WRITE_CHAR("二");}if(time_buf1[7]==1) {LCD_WRITE_CHAR("一");}Lcd_Set_Post(3,0);TransferData(shishi+48,1);//----------------------时TransferData(geshi+48,1);TransferData(58,1);TransferData(shifen+48,1);//----------------------分TransferData(gefen+48,1);TransferData(58,1);TransferData(shimiao+48,1);//----------------------秒TransferData(gemiao+48,1);if(state[0]==0){bai=(temph/100); //---------------------------------温度shi=(temph%100)/10;ge=(temph%100)%10;Lcd_Set_Post(3,4);if(zerotemp==0){TransferData(' ',1);TransferData(' ',1);} Lcd_Set_Post(3,5);TransferData(shi+48,1);TransferData(ge+48,1);TransferData('.',1);TransferData(templ+48,1);TransferData(0xa1,1);TransferData(0xe6,1);Lcd_Set_Post(4,0);festival(time_buf[2],time_buf[3],time_buf[4]);//农历}}if(num==3)//----------主菜单{Lcd_Set_Post(1,0);//--------设置显示位置LCD_WRITE_CHAR(mainmenu);}if(num==4)//----------设置菜单{Lcd_Set_Post(1,0);//--------设置显示位置LCD_WRITE_CHAR(setmenu);}if(num==5)//----------时间设置{Lcd_Set_Post(1,2);//--------设置显示位置LCD_WRITE_CHAR("时间设置");Lcd_Set_Post(2,1);TransferData(shinian+48,1);//----------------------年TransferData(genian+48,1);LCD_WRITE_CHAR("年");TransferData(shiyue+48,1);//----------------------月TransferData(geyue+48,1);LCD_WRITE_CHAR("月");TransferData(shiri+48,1);//----------------------日TransferData(geri+48,1);LCD_WRITE_CHAR("日");TransferData(time_buf1[7]+48,1);//---------------星期Lcd_Set_Post(3,2);TransferData(shishi+48,1);//--------------------时TransferData(geshi+48,1);LCD_WRITE_CHAR("时");TransferData(shifen+48,1);//---------------------分TransferData(gefen+48,1);LCD_WRITE_CHAR("分");TransferData(shimiao+48,1);//--------------------秒TransferData(gemiao+48,1);}if(num==6)//----------秒表{uchar shi1,shi2,shi3,ge1,ge2,ge3;Lcd_Set_Post(1,3);//--------设置显示位置LCD_WRITE_CHAR("秒表");Lcd_Set_Post(3,2);shi1=fen/10;ge1=fen%10;TransferData(shi1+48,1);TransferData(ge1+48,1);TransferData(':',1);shi2=miao/10;ge2=miao%10;TransferData(shi2+48,1);TransferData(ge2+48,1);TransferData(':',1);shi3=xiaomiao/10;ge3=xiaomiao%10;TransferData(shi3+48,1);TransferData(ge3+48,1);}if(num==8){Lcd_Set_Post(1,2);//--------农历查询LCD_WRITE_CHAR("温度查询");Lcd_Set_Post(3,0);//--------农历查询LCD_WRITE_CHAR("最高温度"); TransferData(':',1);RdFromROM(Number,0,4);if(Number[3]==0){TransferData('-',1);}Lcd_Set_Post(3,5);TransferData(Number[0]+48,1); TransferData(Number[1]+48,1); TransferData('.',1);TransferData(Number[2]+48,1); TransferData(0xa1,1);TransferData(0xe6,1); Lcd_Set_Post(4,0);//--------农历查询LCD_WRITE_CHAR("最低温度"); TransferData(':',1);RdFromROM(Number,4,4);if(Number[3]==0){TransferData('-',1);}Lcd_Set_Post(4,5);TransferData(Number[0]+48,1); TransferData(Number[1]+48,1); TransferData('.',1);TransferData(Number[2]+48,1); TransferData(0xa1,1);TransferData(0xe6,1); }if(num==9)//----------界面菜单{Lcd_Set_Post(1,2);//--------设置显示位置LCD_WRITE_CHAR("界面选择");Lcd_Set_Post(2,0);TransferData(1+48,1);TransferData('.',1);LCD_WRITE_CHAR("多功能界面");Lcd_Set_Post(3,0);TransferData(2+48,1);TransferData('.',1);LCD_WRITE_CHAR("简洁界面");}。
嵌入式系统概述题目:基于单片机的万年历设计班级:自动化1304班一、系统功能概述此设计以AT89C51为控制芯片,用RTC定时器实现万年历的控制与设计。
所进行控制的语句是通过C语言实现的,并且用串口助手显示能动态地显示当前时间信息,包括年、月、日、时、分、秒。
二、硬件设计原理图:1.万年历电路图设计如下:三、软件设计:1.设计思路:本设计主要由3大部分电路组成:单片机最小系统电路、时钟显示电路和参数修改电路。
其中单片机最小系统主要由复位电路和时钟电路组成。
设计中,当接收到修改参数的指令,将停止时钟的继续,转而进行指令程序,在指令结束后转回断点处继续进行计时。
2.流程图:四、基于单片机万年历的源代码:#include <reg52.h>#include <intrins.h>#include <string.h>#define uint unsigned int#define uchar unsigned charsbit IO = P1^0;sbit SCLK = P1^1;sbit RST = P1^2;sbit RS = P2^0;sbit RW = P2^1;sbit EN = P2^2;sbit KEY1=P3^4;sbit KEY2=P3^5;sbit KEY3=P3^6;uchar*WEEK[]={"SUN","***","MON","TUS","WEN"," THU","FRI","SAT"};uchar LCD_DSY_BUFFER1[]={"DATE 00-00-00 "};uchar LCD_DSY_BUFFER2[]={"TIME 00:00:00 "};uchar DateTime[7]; //秒,分,时,日,月,周,年ucharflag,flag_1,i,miao,fen,shi,ri,yue,zhou,nian; void DelayMS(uint ms){uchar i;while(ms--){for(i=0;i<120;i++);}}/*********************************************** ******/ //函数名称:Write_A_Byte_TO_DS1302(uchar x)//函数功能: 向1302写入一个字节//入口参数: x//出口参数: 无//调用子程序: 无/*********************************************** ******/void Write_A_Byte_TO_DS1302(uchar x){uchar i;for(i=0;i<8;i++){IO=x&0x01;SCLK=1;SCLK=0;x>>=1;}}void Write_DS1302(uchar add,uchar num) {SCLK=0;RST=0;RST=1;Write_A_Byte_TO_DS1302(add);Write_A_Byte_TO_DS1302(num);RST=0;SCLK=1;}/*********************************************** ******///函数名称:Get_A_Byte_FROM_DS1302()//函数功能: 从1302读一个字节//入口参数: 无//出口参数: b/16*10+b%16 //调用子程序: 无/*********************************************** ******/uchar Get_A_Byte_FROM_DS1302(){uchar i,b=0x00;for(i=0;i<8;i++){b |= _crol_((uchar)IO,i);SCLK=1;SCLK=0;}return b/16*10+b%16;}/*********************************************** ******///函数名称: Read_Data(uchar addr)//函数功能: 指定位置读数据//入口参数: addr//出口参数: dat//调用子程序: Write_Abyte_1302(addr) /*********************************************** ******/uchar Read_Data(uchar addr){uchar dat;RST = 0;SCLK=0;RST=1;Write_A_Byte_TO_DS1302(addr);dat = Get_A_Byte_FROM_DS1302();SCLK=1;RST=0;return dat;}/*********************************************** ******///函数名称: GetTime()//函数功能: 读取时间//入口参数: 无//出口参数: 无//调用子程序: 无/*********************************************** ******/void GetTime(){uchar i,addr = 0x81;for(i=0;i<7;i++){DateTime[i]=Read_Data(addr);addr+=2; }}uchar Read_LCD_State(){uchar state;RS=0;RW=1;EN=1;DelayMS(1);state=P0;EN = 0;DelayMS(1);return state;}void LCD_Busy_Wait(){while((Read_LCD_State()&0x80)==0x80); DelayMS(5);}void Write_LCD_Data(uchar dat) //写数据到1602{LCD_Busy_Wait();RS=1;RW=0;EN=0;P0=dat;EN=1;DelayMS(1); EN=0;}void Write_LCD_Command(uchar cmd) //写命令{LCD_Busy_Wait();RS=0;RW=0;EN=0;P0=cmd;EN=1;DelayMS(1); EN=0;}void Init_LCD() //1602 初始化{Write_LCD_Command(0x38);DelayMS(1);Write_LCD_Command(0x01);DelayMS(1);Write_LCD_Command(0x06);DelayMS(1);Write_LCD_Command(0x0c);DelayMS(1);}void Set_LCD_POS(uchar p){Write_LCD_Command(p|0x80);}void Display_LCD_String(uchar p,uchar *s) //1602显示{uchar i;Set_LCD_POS(p);for(i=0;i<16;i++){Write_LCD_Data(s[i]);DelayMS(1);}}void write_com(uchar com){RS=0;P0=com;DelayMS(5);EN=1;DelayMS(5);EN=0;}void write_date(uchar date){RS=1;P0=date;DelayMS(5);EN=1;DelayMS(5);EN=0;}void display(uchar add,uchar date){uchar shi,ge;shi=date/10;ge=date%10;write_com(0x80+0x40+add);write_date(0x30+shi);write_date(0x30+ge);}void display1(uchar add,uchar date) {uchar shi,ge;shi=date/10;ge=date%10;write_com(0x80+add);write_date(0x30+shi);write_date(0x30+ge);}void Format_DateTime(uchar d,uchar *a) {a[0]=d/10+'0';a[1]=d%10+'0';}uchar ZH(uchar dat){uchar tmp;tmp=dat/10;dat=dat%10;dat=dat+tmp*16;return dat;}void Keyscan(){flag_1=1;while(flag_1){if(KEY1==0){DelayMS(5);while(!KEY1);flag=(flag+1)%8;switch(flag){case(1): Write_LCD_Command(0x0f);Write_LCD_Command(0x80+0x40+11);break;case(2):Write_LCD_Command(0x80+0x40+8);break;case(3):Write_LCD_Command(0x80+0x40+5);break;case(4):Write_LCD_Command(0x80+13);break;case(5):Write_LCD_Command(0x80+11);break;case(6):Write_LCD_Command(0x80+8);break;case(7):Write_LCD_Command(0x80+5);break;case(0): flag_1=0;Write_LCD_Command(0x0c);//miaoWrite_DS1302(0x8e,0x00);Write_DS1302(0x80,ZH(DateTime[0]));Write_DS1302(0x8e,0x80);//fenWrite_DS1302(0x8e,0x00);Write_DS1302(0x82,ZH(DateTime[1]));Write_DS1302(0x8e,0x80);//shiWrite_DS1302(0x8e,0x00);Write_DS1302(0x84,ZH(DateTime[2]));Write_DS1302(0x8e,0x80);//riWrite_DS1302(0x8e,0x00);Write_DS1302(0x86,ZH(DateTime[3]));Write_DS1302(0x8e,0x80);// yueWrite_DS1302(0x8e,0x00);Write_DS1302(0x88,ZH(DateTime[4]));Write_DS1302(0x8e,0x80);//nianWrite_DS1302(0x8e,0x00);Write_DS1302(0x8c,ZH(DateTime[6]));Write_DS1302(0x8e,0x80);break;}}if(flag!=0){if(KEY2==0){DelayMS(5);if(KEY2==0)while(!KEY2);if(flag==1) //miao{DateTime[0]++;if(DateTime[0]==60)DateTime[0]=0;write_com(0x80+0x40+11);display(11,DateTime[0]);}if(flag==2) //fen{DateTime[1]++;if(DateTime[1]==60)DateTime[1]=0;write_com(0x80+0x40+8);display(8,DateTime[1]);}if(flag==3) //shi{DateTime[2]++;if(DateTime[2]==24)DateTime[2]=0;write_com(0x80+0x40+5);display(5,DateTime[2]);}/* if(flag==4) //zhou {DateTime[0]++;if(DateTime[0]==60)DateTime[0]=0;write_com(0x80+0x40+11);display(11,DateTime[0]);} */if(flag==5) // ri{DateTime[3]++;if(DateTime[3]==30)DateTime[3]=0;write_com(0x80+11);display1(11,DateTime[3]); }if(flag==6) //yue{DateTime[4]++;if(DateTime[4]==13)DateTime[4]=0;write_com(0x80+8);display1(8,DateTime[4]);}if(flag==7) //nian{DateTime[6]++;if(DateTime[6]==100)DateTime[6]=0;write_com(0x80+5);display1(5,DateTime[6]);}}}if(flag!=0){if(KEY3==0){DelayMS(5);if(KEY3==0)while(!KEY3);if(flag==1) //miao{DateTime[0]--;if(DateTime[0]==-1)DateTime[0]=0;write_com(0x80+0x40+11);display(11,DateTime[0]);}if(flag==2) //fen{DateTime[1]--;if(DateTime[1]==-1)DateTime[1]=0;write_com(0x80+0x40+8);display(8,DateTime[1]);}if(flag==3) //shi{DateTime[2]--;if(DateTime[2]==-1)DateTime[2]=0;write_com(0x80+0x40+5);display(5,DateTime[2]);}/* if(flag==4) //zhou {DateTime[0]++;if(DateTime[0]==60)DateTime[0]=0;write_com(0x80+0x40+11);display(11,DateTime[0]);} */if(flag==5) // ri{DateTime[3]--;if(DateTime[3]==-1)DateTime[3]=0;write_com(0x80+11);display1(11,DateTime[3]); }if(flag==6) //yue{DateTime[4]--;if(DateTime[4]==-1)DateTime[4]=0;write_com(0x80+8);display1(8,DateTime[4]);}if(flag==7) //nian{DateTime[6]--;if(DateTime[6]==-1)DateTime[6]=0;write_com(0x80+5);display1(5,DateTime[6]);}}}}}void main() {Init_LCD(); while(1) {EA=1;EX0=1;GetTime();Format_DateTime(DateTime[6],LCD_DSY_BUF FER1+5); //年Format_DateTime(DateTime[4],LCD_DSY_BUF FER1+8); //月Format_DateTime(DateTime[3],LCD_DSY_BUF FER1+11); //日strcpy(LCD_DSY_BUFFER1+13,WEEK[DateTim e[5]]); //周Format_DateTime(DateTime[2],LCD_DSY_BUF FER2+5); //时Format_DateTime(DateTime[1],LCD_DSY_BUF FER2+8); //分Format_DateTime(DateTime[0],LCD_DSY_BUF FER2+11); //秒Display_LCD_String(0x00,LCD_DSY_BUFFER1);Display_LCD_String(0x40,LCD_DSY_BUFFER2); }}void int0() interrupt 0{Keyscan();}五、运行结果:。
基于单片机的多功能数字万年历的设计摘要随着电子技术的迅速发展,特别是大规模集成电路出现,新一代电子产品给人类生活带来了根本性的改变。
尤其是单片机技术的应用产品已经走进了千家万户,而数字万年历的出现给人们的生活带来的诸多方便。
本文首先描述系统硬件工作原理,并附以系统结构框图加以说明,着重介绍了本系统所应用的各硬件接口技术和各个接口模块的功能及工作过程,其次,详细阐述了程序的各个模块和实现过程。
本设计以数字集成电路技术为基础,单片机技术为核心。
本文编写的主导思想是软硬件相结合,在硬件基础上来进行软件各功能模块的编写。
本系统以单片机的C语言进行软件设计,增加了程序的可读性和可移植性,为了便于扩展和更改,软件的设计采用模块化结构,使程序设计的逻辑关系更加简洁明了。
系统通过点阵式液晶为载体显示数据,所以具有人性化的操作和美观的页面效果,可以显示时间、公农历日期、星期、温度、节气,天干地支,并有闹铃功能。
关键词:单片机;万年历;液晶技术;农历Design of Multifunctional digital Perpetual Calendar Based on MCUAbstractWith the rapid development of electronic technology,especially with the emergence of large-scale integrated circuits,a new generation of electronic products has brought about a fundamental change to our human beings. In particular,products based on Microcontroller single-chip technology have entered tens of thousands of households and the emergence of digital calendar have brought about a lot of convenience to people's lives.This article will first describe the working principle of the hardware system with the system block diagram to illustrate the structure,and highlighted by the application of the system interface technology of the hardware and the interface module functions and work processes. Secondly,I described the program in detail and how I did it. The design is based on digital integrated circuits technology,with single-chip technology as the core. The essence of this article is the combination of the hardware and the software. We proceed programming based on hardware.The system uses C-language software programming,which increases the readability and portability. In order to facilitate the expansion and changes to the design of modular software structure,the design of the software adopts module programming which made the logic of the program is more concise.The system adopts the vector dot-matrix liquid crystal to display data and therefore have a user-friendly operation and aesthetically pleasing results,which can show the time,the Chinese date,week,temperature,weather,Heavenly Stems and Earthly Branches,and also include alarm functions.Keywords: microcontroller single-chip; calendar; crystal technology; Chinese date目录引言 (1)第1章绪论 (2)1.1课题的背景与意义 (2)1.2数字万年历的现状与发展 (2)1.3论文的主要工作及章节安排 (2)1.4本章小结 (3)第2章系统方案论证 (4)2.1多功能数字万年历系统概述 (4)2.2设计任务与要求 (4)2.3系统方案论证 (4)2.3.1计时方案 (5)2.3.2测温方案 (5)2.3.3显示方案 (5)2.4本章小结 (5)第3章硬件电路的设计 (6)3.1主控制器 (6)3.2时钟电路DS1302 (6)3.3温度检测DS18B20 (7)3.4液晶显示 (8)3.5按键接口 (8)3.6语音闹铃模块 (8)3.7电源模块 (9)3.8本章小结 (11)第4章系统软件设计 (12)4.1公历计算显示程序设计 (13)4.1.1DS1302内部寄存器 (14)4.1.2时间读取程序设计 (15)4.2农历转换程序设计 (17)4.2.1公历转农历算法研究 (17)4.2.2干支纪年法简介 (18)4.2.3公历转农历程序 (19)4.3温度测量程序设计 (21)4.3.1DS18B20测温原理 (21)4.3.2温度程序 (21)4.4二十四节气算法研究 (24)4.5本章小结 (25)结论与展望 (26)致谢 (27)参考文献 (28)附录A 总体电路图 (29)附录B 外文文献及译文 (30)附录C 参考文献题录及摘要 (35)附录D 源程序 (37)插图清单图2-1 数字万年历系统框图 (4)图3-1 DS1302与ATMEGA16连接图 (7)图3-2 DS18B20与ATMEGA16连接图 (8)图3-3 报时电路 (9)图3-4 稳压电源原理图 (10)图3-5 电源电路 (10)图4-1 系统程序流程图 (13)图4-2 公历程序流程图 (14)图4-3 DS18B20测温原理 (21)表格清单表3-1 LCD12864显示内容 (8)表4-1 DS1302的寄存器及其控制字 (14)表4-2 RS位配置 (15)引言人类的日常生活离不开时间,任何具有周期性变化的自然现象都可以用来测量时间。
1. 前言1.1 课题研究背景伴随着科技的快速发展,时间的流逝,从观察太阳、摆钟到现在电子钟,人类不断的研究,不断的创新纪录。
随着人们的生活水平的提高和生活节奏加快,对时间的要求也越来越高,精准数字计时的消费需求也就越来越多。
二十一世纪的今天,最具有代表性的计时产品就是电子数字万年历,它是近代世界钟表业界的第三次革命。
第一次是摆和摆轮游丝的发明,相对较稳定的机械振荡频率源使钟表的走时差从分级缩小至秒级,代表性的产品是带有摆或摆轮游丝的机械钟或者表。
第二次革命则是石英晶体振荡器的应用,发明了走时精度更高的石英电子钟表,也使钟表的走时月差从分级缩小到秒级。
第三次革命就是单片机数码计时技术的应用(电子数字万年历),使计时产品的走时日差从分级缩小至1/600万秒,从原有的传统指针计时的方式发展成为人们日常更为熟悉的夜光数字显示方式,直观明了,并且增加了全自动日期、星期、温度以及其他日常附属带来了钟表计时业界跨跃性的进步。
国产的电子万年历有很多种,总体上来说以研究多功能电子数字万年历为主,使万年历除了原有的显示时间,日期等基本功能之外,还具有闹铃,报警等功能。
商家生产的电子数字万年历更从质量,价格,实用上考虑,不断的改进电子万年历的设计,使其更加的具有市场。
本设计为软硬件相结合的一组设计。
在软件设计过程中,应对硬件部分有相关了解,有助于对设计题目的更深了解和软件设计。
要了解一些主要器件的基本功能和作用。
除了采用集成化的时钟芯片之外,利用AT89系列单片机制成万年历电路,采用软硬件结合的方法,分别用来显示年、月、日、时、分、秒,其最大特点是:硬件电路简单,安装方便易于实现,软件设计独特,可靠。
AT89C51单片机是由ATMEL公司推出的一种小型单片机。
95年出现在中国市场。
主要特点为采用了Flash存贮器技术,降低了制造成本,其软硬件与MCS-51完全兼容,可以很快被中国广大用户接受。
1 / 331.2课题研究目的与意义二十一世纪是数字化技术高速发展的时期,同时单片机在数字化高速发展的时期扮演着非常重要的地位。
基于单片机控制的电子万年历设计1设计要求功能:电子万年历能显示阳历、时间、室温,并能表明是否是闰年,通过按键实现切换。
本课题以单片机为核心,设计并制作出智能LCD电子钟,具有以下基本功能:计时、秒、分、时、天、周、月、年;能进行时间、年份、日期、星期显示;能区分是否闰年;能检测室温并显示。
扩展功能部分可以通过控制按键使时间暂停、可以调整校正时间并通过按键切换轮流显示时间、年份、日期、星期。
2方案论证与对比2.1液晶显示器控制方式选择采用LCD液晶显示,具有超精致影像画质、十足平面显示、节省空间、节省能源等优点,但按控制方式不同,LCD可分为被动矩阵式LCD及主动矩阵式LCD两种。
可根据不同需要采用不同的方式。
方案一被动矩阵式LCD被动矩阵式LCD在亮度及可视角方面受到较大的限制,反应速度也较慢。
由于画面质量方面的问题,使得这种显示设备不利于发展为桌面型显示器,但成本低廉。
方案二主动矩阵式LCD目前应用比较广泛的主动矩阵式LCD,也称TFT-LCD(Thin Film Transistor-LCD,薄膜晶体管LCD)。
TFT液晶显示器是在画面中的每个像素内建晶体管,可使亮度更明亮、色彩更丰富及更宽广的可视面积。
与CRT显示器相比,LCD显示器的平面显示技术体现为较少的零件、占据较少的桌面及耗电量较小,但CRT技术较为稳定成熟。
相比之下,本设计当中选用方案二主动矩阵式LCD方式。
2.2 并行接口动态显示电路选择可以采取串行接口动态显示电路或者并行接口动态显示电路,比较如下:方案一串行接口动态显示电路利用8051系列单片机内部的串行接口,也可以实现动态显示及键盘处理。
这样不但可以节省8051的并行I/O接口,而且在大多数不用单行口的情况下,可免于扩展接口。
在这种方法中,串行口工作在方式0状态,相当于一个移位寄存器,其输入/输出通过RXD引脚,移位脉冲则由TXD输出。
每次输入或输出8位数据(一个字节)。
基于单片机的万年历制作-图文基于DS1302和ATmega16的万年历制作一、题目分析以及器件选择1、设计要求:电子万年历(a)、基本功能要求:1>能够正确进行日历记录和显示2>能够输入设定年份3>能够通过按键进行日历的调整4>能够进行整点报时5>每年1月1日进行新年报时(b)、扩展功能要求:1>能够调整每天的定时长短2>能够同时显示对应的农历3>能够将通过计算机调整具体的计时和日历2、方案选择:1>时钟芯片的选择在这个系统中,最重要的就是时钟芯片的选择,在电子时钟设计中,常用的时钟芯片有DS1302、DS1216、DS1643、DS1302。
每种芯片的主要功能基本相同,只是在引脚数量、备用电池的安装方式、计时精度和扩展功能等方面略有不同。
DS12877与DS1216芯片都有内嵌式锂电池作为备用电源:某1203引脚少,没有嵌入式锂电池,跟DS1302芯片功能相似,只是相比较之下,某1203与AT89S51搭配使用时占用I/O口较多。
DS1643为带有全功能实时时钟的非易失性型SRAM,集成了非易失性型SRAM、实时时钟、晶振、电源掉电控制电路和锂电池电源,BCD码表示的年、月、日、星期、时、分、秒,带闰年补偿。
同样。
DS1643拥有28只管脚,硬件连起来占用微处理器I/O口较多,不方便系统功能拓展和维护。
故而从性价比和货源上考虑,本设计采用实时时钟芯片DS1302。
2>显示器件的选择显示器件的选择范围很广,成本最低的就是采用八位数码管进行显示,但是使用八位数码管,经过评估和计算需要至少八个,这占用了太大的空间,而且很不美观。
第二个选择就是使用液晶,采用12864大液晶是普遍的选择,但是成本太高,而且函数调用不便,程序较长,因此从节约成本的角度考虑,使用小液晶1602进行设计。
3>设计评估本次设计完成了基本要求规定那个的所有内容,能够正确进行日历记录和显示、能够输入设定年份、能够通过按键进行日历的调整、能够进行整点报时、每年1月1日进行新年报时。
基于单片机设计的万年历显示电路电路原理图:程序:#include<reg51.h>#include"lcd1602.h"#include"ds1302.h"#include"ds18b20.h"#define uint unsigned int#define uchar unsigned charuint b[6];//年、月、日、时、分、秒uchar code row1[]={"2009-01-01"};uchar code row2[]={"00:00:00"};uchar year1[12]={31,28,31,30,31,30,31,31,30,31,30,31};//平年uchar year2[12]={31,29,31,30,31,30,31,31,30,31,30,31};//润年uchar j[6]={0x85,0x88,0x8b,0x84+0x40,0x87+0x40,0x8a+0x40};//LCD地址uchar i,k,jj=0,w,clock=0,bigclock=0,c=0,num;//i循环数,k温度缓存,jj地址位uint temp;sbit b1=P3^0;//设置sbit b2=P3^1;//上调sbit b3=P3^2;//下调sbit b4=P3^3;//转换sbit b5=P3^4;//闹钟sbit speaker=P3^5;lcdscan(){for(i=0;i<6;i++){ lcdwrite(j[i]);lcdshuju(a[11-i*2]+0x30);lcdwrite(j[i]+0x01);lcdshuju(a[10-i*2]+0x30);}}void key(){ if(b1==0){ dsaddshuju(0x80,(a[1]<<4)+a[0]+0x80);while(b1==0){for(i=0;i<6;i++){b[i]=a[11-i*2+clock]*10+a[10-i*2+clock];}if(b4==0){ delay(3);jj++;if(jj==6){jj=0;}}if(b2==0){ delay(3);b[jj]++;if(b[5]==60)b[5]=0;if(b[4]==60)b[4]=0;if(b[3]==24)b[3]=0;if((b[0]%4==0&&b[0]%100!=0)||b[0]%400==0){if(b[2]>year2[b[1]-1])b[2]=1;} else {if(b[2]>year1[b[1]-1])b[2]=1;}if(b[1]==13)b[1]=1;if(b[0]==100)b[0]=0;}if(b3==0){ delay(3);b[jj]--;if(b[5]==-1)b[5]=59;if(b[4]==-1)b[4]=59;if(b[3]==-1)b[3]=23;if((b[0]%4==0&&b[0]%100!=0) || b[0]%400==0){if(b[2]<=0)b[2]=year2[b[1]-1];}else {if(b[2]<=0)b[2]=year1[b[1]-1];}if(b[1]==0)b[1]=12;if(b[0]==-1)b[0]=99;}for(i=0;i<6;i++){ a[11-i*2+clock]=b[i]/10;a[10-i*2+clock]=b[i]%10;}lcdwrite(j[jj]);lcdshuju(0);lcdwrite(j[jj]+1);lcdshuju(0);delay(200);lcdwrite(j[jj]);lcdshuju(a[11-2*jj+clock]+0x30);lcdwrite(j[jj]+1);lcdshuju(a[10-2*jj+clock]+0x30);delay(200);if(b1==1){ dsaddshuju(0x80,(a[1]<<4)+a[0]);dson();}if(b5==0)clock=12;} }}void main(){ speaker=0;lcdrw=0;dson();lcdon();lcdwrite(0x83);for(i=0;i<10;i++){ lcdshuju(row1[i]);delay(1);}lcdwrite(0x84+0x40);for(i=0;i<8;i++){lcdshuju(row2[i]);delay(1);}dsrst=0;dssclk=0;while(1){for(i=0;i<5;i++){ dsrst=1;dswrite(0x81+i*2);k=dsread();dsrst=0;a[i*2]=k&0x0f;a[i*2+1]=(k>>4)&0x0f;}dsrst=1;dswrite(0x8d);k=dsread();dsrst=0;a[10]=k&0x0f;a[11]=(k>>4)&0x0f;delay(100);lcdscan();key();if(b5==0){ for(i=0;i<12;i++){if(a[i+12]==a[i])num++; }if(num==12)bigclock=1;else num=0;lcdwrite(0x8e);lcdshuju('&');}else{lcdwrite(0x8e);lcdshuju(0x00);}if(bigclock==1){ speaker=1;c++;if(c==100){bigclock=0;speaker=0;}}temp=readtemperature();//temp是uint型的。
基于单片机万年历设计基于单片机的万年历设计二、实验要求设计一个万年历,将时钟显示在LCD1602的显示屏上并且可以进行年、月、日以及时、分、秒的设置。
此外还可以通过按键进行闹钟设置以及事件提醒功能,用蜂鸣器进行闹铃提醒。
最后附加一个温湿度检测的功能,用温湿度传感器检测室内的温湿度并将温湿度数据在显示屏上显示出来。
三、实验设备和仪器1.用STC89C52芯片作为系统板的主控芯片2.DHT11温湿度传感器3.DS1302时钟芯片4.LCD1602显示屏四、实验各模块原理介绍4.1STC89C52单片机STC89C52是STC公司生产的一种低功耗、高性能CMOS8位微控制器,具有8K字节系统可编程Flah存储器。
STC89C52使用经典的MCS-51内核,具有传统51单片机不具备的功能。
在单芯片上,拥有灵巧的8位CPU和在系统可编程Flah,使得STC89C52为众多嵌入式控制应用系统提供高灵活、超有效的解决方案。
2.工作电压:5.5V~3.3V(5V单片机)/3.8V~2.0V(3V单片机) 3.工作频率范围:0~40MHz,相当于普通8051的0~80MHz,实际工作频率可达48MHz4.用户应用程序空间为8K字节5.片上集成512字节RAM6.通用I/O口(32个),复位后为:P1/P2/P3是准双向口/弱上拉,P0口是漏极开路输出,作为总线扩展用时,不用加上拉电阻,作为I/O口用时,需加上拉电阻。
8.具有EEPROM功能9.共3个16位定时器/计数器。
即定时器T0、T1、T2。
10.外部中断4路,下降沿中断或低电平触发电路,PowerDown模式可由外部中断低电平触发中断方式唤醒。
11.通用异步串行口(UART),还可用定时器软件实现多个UART。
12.工作温度范围:-40~+85℃(工业级)/0~75℃(商业级)13.PDIP封装1、STC89C52单片机引脚图图4.1STC89C52单片机引脚图①主电源引脚(2根) VCC(Pin40):电源输入,接+5V电源GND(Pin20):接地线②外接晶振引脚(2根) 某TAL1(Pin19):片内振荡电路的输入端某TAL2(Pin20):片内振荡电路的输出端③控制引脚(4根) RST/VPP(Pin9):复位引脚,引脚上出现2个机器周期的高电平将使单片机复位。
摘要电子万年历是一种使用非常广泛日常计时工具,对现代社会越来越流行。
它可以对年、月、日、周、时、分、秒进行计时,还具有闰年补偿等多种功能,是现代生活中必不可少的一种工具。
本次设计利用AT89S52单片机结合C语言来实现万年历的制作,主要模块有时钟模块-DS1302、温度模块-DS18B20、显示模块- LCD1602、红外接收模块。
该万年历主要实现在LCD显示屏上显示日期与时间、当前温度、该系统还具备设定闹钟的功能,利用遥控器来实现对时间日期以及闹铃的设定。
万年历的设计的软件方面通过C语言来编写程序并利用Keil C软件进行程序调试来实现以上功能。
关键词:DS1302;DS18B20;单片机;AT89S52AbstractElectronic calendar is a very wide daily timing tool which is more and more popular in modern society. It can be for year, month, day, week, when, minutes and seconds for timing.Also has a variety of functions such as compensation for leap. Electronic calendar is a essential item in our life.This design using C language AT89S52 single-chip combination to realize the calendar.The main modules are DS1302、temperature module -DS18B20、display module - LCD1602、infrared receiving module。
This calendar on the LCD display in the main show the date and time, the temperature.This system has set the alarm clock function, using remote control to achieve the date and time of the alarm set.The design of the software in motion by C language write programs and use the Keil software programs to debug to C than realizing function.Keywords:DS1302;DS18B20;;AT89S52目录第1章概述 (1)1.1研究的背景和意义 (1)1.2万年历的发展状况 (1)1.3研究内容 (2)1.4论文安排 (2)第2章系统的硬件设计与实现 (3)2.1电路设计框图 (3)2.2系统硬件概述 (4)2.3主要单元电路的设计 (4)2.4电路原理及说明 (13)2.5完成结果 (15)2.6本章小结 (15)第3章系统的软件设计 (16)3.1程序流程框图 (16)3.2时钟程序设计 (18)第4章指标测试 (20)4.1测试仪器 (20)4.2硬件测试 (20)4.3软件测试 (20)4.4测试结果分析与结论 (21)结论 (22)参考文献 (23)致谢 (24)附录程序 (25)第1章概述1.1 研究的背景和意义在日新月异的二十一世纪,家用电子产品的得到了迅速的发展。