基于51单片机的英文论文

the Real-Time Clock Based on AT89S51

Author: Class: ; Name:

Abstract: Digital clock has become indispensable in people's daily life, it is widely used in public places such as the family and the office, and it gives people great convenience in study , work and entertainment. Due to the development of digital integrated circuit technology and the advanced quartz technology, the digital clock has advantages of accurate, stable performance and easy to carry. It is also used in automatic control, automatic signal and etc. Although the digital clocks are already sold on the market, but the single chip microcomputer timer function also can complete the design of the digital clock circuit. So it is necessary to the design of the digital clock. By single chip microcomputer internal timer timing precision, the four digital tube display year, month, day, time, minutes and seconds. With the keyboard, users can be preset time, display the time, set the content, set time operation mode, etc.

Keywords: AT89S51; clock; digital tube; keyboard switch; function

Introduction: AT89S51 is a very suitable for the beginners of the single chip microcomputer, it is fully compatible with the traditional instruction system of 8051,8031.

Can realize the following functions:

1. Use the keyboard switch, show respectively the seconds, minutes, hour, day, month, year;

2. Use the keyboard preset year, month, day, time, minutes and seconds;

3. Can the countdown, the countdown units for minutes;

4. Every second , the four decimal point shine once;

5. Timing alarm clock function, a buzzer call reminder.

6. The clock error daily is not more than 1 second.

Methods:

1. The minimum single chip microcomputer system

AT89S51 has the following standard functions: 8 k bytes Flash, 256 bytes RAM, and 32-bit I/O lines, a watchdog timer, two data pointer, three 16 timer/counter, a level 6 vector 2 interrupt structure, full duplex serial port, piece of crystals and the clock circuit . In idle mode, the CPU stops working, allows RAM, timer/counter, serial port and interrupt continue to work. In fall protection mode, RAM content are stored, has been frozen, single chip microcomputer stops all work, until the next interruption or hardware reset.

2. The display

Display uses the method of dynamic LED digital tube to display , P0 port output characters code to display, position codes are controlled by P2.4 ~ P2.7. The cost of the dynamic display is very low, but the dynamic display occupies more resources of the CPU interface. The design uses 12 lines. In addition by the dynamic display refreshing, which takes part of the work time of the CPU. So for some higher demand control system, we should consider the time taken by the display.

3. The keyboard

Keyboard uses 4 * 4 matrix keyboard, by P2.0 ~ P2.3 for row line, P1.4 ~ P1.7 for column line, phalanxes of 4 * 4 are made, and using the method of scanning software can determine the key value of each key. In the design, each key can be used to input

data and commands.

4. The power supply

Control power supply can be provided by DC 12V voltage , the power supply can be used by stepping motor driver, at the same time through the three linear stabilizer 7805 to provide other circuit power supply; If you don't need to use stepper motor, the control system of the DC5V power supply can be collected from ordinary USB interface of the computer, as long as the USB connects a computer USB port, the other connects two core power interface of controller.

5. Programming interface

Microprocessor uses AT89S51. AT89S51 has ISP online programming function, and P1.5 ~ P1.7 are for the programming interface and software compilation and debugging includes two processes:

1. By using keil software programming, input source program, and then compile until no grammar mistakes, using compilation command hex into system files(suffix:hex).

2. After connecting the power cord and programming line, start USBASP programming software. Select the chip microprocessors model in the selection of AT89S51. Open and load in the flash. Load in the hex into system files. Use erase commands to erase chip in the original program, with programming command to write new programs in AT89S51. After finished, reset the program running, observing the consequence. If there is any error, it is needed to re-open the Medwin and modify the source program, to create the hex file, and then repeat the above operation, to meet the design requirements.

Results:

Key:

| 1 | 2 | 3 | 分秒 |

| 4 | 5 | 6 | 时分 |

| 7 | 8 | 9 | 月日 |

| 确定 | 0 | 倒计时 | 年 |

#include

#include

#define uchar unsigned char

sbit P1_3=P1^3;

sbit P3_2=P3^2;

unsigned char t=0;

unsigned char t1=50;

unsigned char t2=59;

unsigned char t3=23;

unsigned char t4=7;

unsigned char t5=60;

unsigned char t6=60;

unsigned char k1=4;

uchar i;

uchar c;

uchar a[10]={0x81,0xED,0x43,0x49,0x2D,0x19,0x11,0xCD,0x01,0x09};

uchar p[5];

void delay(int MS)

{

int i,j;

for( i=0;i

for(j=0;j

}

uchar encoder(uchar num)

{

uchar i;

switch(num)

{

case 0x11:

i=0x11;break;

case 0x12:

i=0x12;break;

case 0x14:

i=0x13;break;

case 0x18:

i=0x14;break;

case 0x21:

i=0x15;break;

case 0x22:

i=0x09;break;

case 0x24:

i=0x06;break;

case 0x28:

i=0x03;break;

case 0x41:

i=0x00;break;

case 0x42:

i=0x08;break;

case 0x44:

i=0x05;break;

case 0x48:

i=0x02;break;

case 0x81:

i=0x16;break;

case 0x82:

i=0x07;break;

case 0x84:

i=0x04;break;

case 0x88:

i=0x01;break;

}

return(i);

}

uchar key_value()

{

uchar tem,s,t,n;

P1&=0x0f;

P2|=0x0f;

;

tem=P2;

tem|=0xf0;

s=~tem;

P2&=0xf0;

P1|=0xf0;

;

tem=P1;

tem|=0x0f;

t=~tem;

s=s+t;

n=encoder(s);

return(n);

}

uchar key(void)

{

uchar i;

P2|=0x0f;

P1&=0x0f;

;

i=P2;

i|=0xf0;

i=~i;

return(i);

}

void show1(uchar i,uchar j)

{

P0=a[j];

P2=P2&0x0f;

P2|=1

}

void show(uchar i,uchar j,uchar k,uchar l) {

uchar a[10]={0x81,0xED,0x43,0x49,0x2D,0x19,0x11,0xCD,0x01,0x09};

uchar b,c,d,e;

b=a[i];

c=a[j];

d=a[k];

e=a[l];

P2&=0x0f;

P2=0x1f;

P0=b;

delay(1);

P2&=0x0f; P2=0x2f;

P0=c;

delay(1);

P2=0x4f;

P0=d;

delay(1);

P2=0x8f;

P0=e;

delay(1);

}

void year(void)

{

while(key()==0) {

show1(4,2);

delay(1);

show1(3,0);

delay(1);

show1(2,1);

delay(1);

show1(1,3);

delay(1);

}

}

void monthday(void) {

TMOD=0X01; TH0=0x4c;

TR0=1;

IE=0X82;

TMOD=0x01; while(key()==0) {

show1(4,0);

delay(1);

show1(3,1);

delay(1);

show1(2,0);

delay(1);

show1(1,t4%10); delay(1);

}

}

void hourminute(void) {

TMOD=0X01; TH0=0x4c;

TL0=0x00;

TR0=1;

IE=0X82;

TMOD=0x01; while(key()==0) {

show1(4,t3/10); delay(1);

show1(3,t3%10); delay(1);

show1(2,t2/10); delay(1);

show1(1,t2%10); delay(1);

}

}

void minutesecond() {

TMOD=0X01; TH0=0x4c;

TL0=0x00;

TR0=1;

IE=0X82;

while(key()==0) {

show1(4,t2/10); delay(1);

show1(3,t2%10); delay(1);

show1(2,t1/10); delay(1);

show1(1,t1%10); delay(1);

}

}

void jishi(void)

{

TMOD=0X01; TH0=0x4c;

TL0=0x00;

TR0=1;

IE=0X82;

TMOD=0x01; while(key()==0) {

show1(2,t5/10); delay(1);

show1(1,t5%10); delay(1);

}

}

void shuru(void)

{

--k1;

if(k1==0)k1=4;

while(key()==0)

{

p[k1]=c;

show1(4,c);

delay(1);

}

}

void sure(void)

{

while(key()==0)

{

show(p[1],p[2],p[3],p[4]); delay(1);

}

}

void timer0(void) interrupt 1 {

t++;

if(t==20)

{

t=0;

t1++;

t5--;

if(t5==0)

{

while(key()==0) {

show1(2,0);

delay(1);

show1(1,0);

delay(1);

P3_2=~P3_2;

delay(1);

P1_3=~P1_3;

delay(1);

}

}

t6--;

if(t6==0)

{

}

if(t1==60)

{

t1=0;

t2++;

if(t2==60)

{

t2=0;

t3++;

if(t3==24)

{

t3=1;

t4++;

if(t4==30)t4==1;

}

}

}

}

TH0=0x4c;

TL0=0x00;

}

void main()

{

while(1)

{

i=key();

while(i!=0)

{

if(i==key())

{

uchar k;

k=key_value();

c=k;

if(c==0x11)year();

else

if(c==0x12)monthday();

else

if(c==0x13)hourminute();

else

if(c==0x14)minutesecond();

else

if(c==0x15)jishi();

else

if(c==0x16)sure();

else

if(c==0x00||0x01||0x02||0x03||0x04||0x05||0x06||0x07||0x08||0x09)

shuru();

else;

}

else

break;

}

}

}

Conclusion: Through the single chip microcomputer can accurately realize the accurate per time, can realize the countdown, display determined year, month, day , hour, minutes, seconds, and some other functions.

Reference:

[1]郭晓林. 基于单片机的电子时钟设计[J].中国科技博览,2010,(9).

[2]何立民. 单片机应用技术选编(11)[M ].北京航天航空大学出版社,2006.

[3]刘守义. 单片机应用技术[M ].西安电子科技大学出版社,2009.

[4]时钟芯片DS1302中文资料,http://www.dz3w.com/info/commonIC/0083003.html

the Real-Time Clock Based on AT89S51

Author: Class: ; Name:

Abstract: Digital clock has become indispensable in people's daily life, it is widely used in public places such as the family and the office, and it gives people great convenience in study , work and entertainment. Due to the development of digital integrated circuit technology and the advanced quartz technology, the digital clock has advantages of accurate, stable performance and easy to carry. It is also used in automatic control, automatic signal and etc. Although the digital clocks are already sold on the market, but the single chip microcomputer timer function also can complete the design of the digital clock circuit. So it is necessary to the design of the digital clock. By single chip microcomputer internal timer timing precision, the four digital tube display year, month, day, time, minutes and seconds. With the keyboard, users can be preset time, display the time, set the content, set time operation mode, etc.

Keywords: AT89S51; clock; digital tube; keyboard switch; function

Introduction: AT89S51 is a very suitable for the beginners of the single chip microcomputer, it is fully compatible with the traditional instruction system of 8051,8031.

Can realize the following functions:

1. Use the keyboard switch, show respectively the seconds, minutes, hour, day, month, year;

2. Use the keyboard preset year, month, day, time, minutes and seconds;

3. Can the countdown, the countdown units for minutes;

4. Every second , the four decimal point shine once;

5. Timing alarm clock function, a buzzer call reminder.

6. The clock error daily is not more than 1 second.

Methods:

1. The minimum single chip microcomputer system

AT89S51 has the following standard functions: 8 k bytes Flash, 256 bytes RAM, and 32-bit I/O lines, a watchdog timer, two data pointer, three 16 timer/counter, a level 6 vector 2 interrupt structure, full duplex serial port, piece of crystals and the clock circuit . In idle mode, the CPU stops working, allows RAM, timer/counter, serial port and interrupt continue to work. In fall protection mode, RAM content are stored, has been frozen, single chip microcomputer stops all work, until the next interruption or hardware reset.

2. The display

Display uses the method of dynamic LED digital tube to display , P0 port output characters code to display, position codes are controlled by P2.4 ~ P2.7. The cost of the dynamic display is very low, but the dynamic display occupies more resources of the CPU interface. The design uses 12 lines. In addition by the dynamic display refreshing, which takes part of the work time of the CPU. So for some higher demand control system, we should consider the time taken by the display.

3. The keyboard

Keyboard uses 4 * 4 matrix keyboard, by P2.0 ~ P2.3 for row line, P1.4 ~ P1.7 for column line, phalanxes of 4 * 4 are made, and using the method of scanning software can determine the key value of each key. In the design, each key can be used to input

data and commands.

4. The power supply

Control power supply can be provided by DC 12V voltage , the power supply can be used by stepping motor driver, at the same time through the three linear stabilizer 7805 to provide other circuit power supply; If you don't need to use stepper motor, the control system of the DC5V power supply can be collected from ordinary USB interface of the computer, as long as the USB connects a computer USB port, the other connects two core power interface of controller.

5. Programming interface

Microprocessor uses AT89S51. AT89S51 has ISP online programming function, and P1.5 ~ P1.7 are for the programming interface and software compilation and debugging includes two processes:

1. By using keil software programming, input source program, and then compile until no grammar mistakes, using compilation command hex into system files(suffix:hex).

2. After connecting the power cord and programming line, start USBASP programming software. Select the chip microprocessors model in the selection of AT89S51. Open and load in the flash. Load in the hex into system files. Use erase commands to erase chip in the original program, with programming command to write new programs in AT89S51. After finished, reset the program running, observing the consequence. If there is any error, it is needed to re-open the Medwin and modify the source program, to create the hex file, and then repeat the above operation, to meet the design requirements.

Results:

Key:

| 1 | 2 | 3 | 分秒 |

| 4 | 5 | 6 | 时分 |

| 7 | 8 | 9 | 月日 |

| 确定 | 0 | 倒计时 | 年 |

#include

#include

#define uchar unsigned char

sbit P1_3=P1^3;

sbit P3_2=P3^2;

unsigned char t=0;

unsigned char t1=50;

unsigned char t2=59;

unsigned char t3=23;

unsigned char t4=7;

unsigned char t5=60;

unsigned char t6=60;

unsigned char k1=4;

uchar i;

uchar c;

uchar a[10]={0x81,0xED,0x43,0x49,0x2D,0x19,0x11,0xCD,0x01,0x09};

uchar p[5];

void delay(int MS)

{

int i,j;

for( i=0;i

for(j=0;j

}

uchar encoder(uchar num)

{

uchar i;

switch(num)

{

case 0x11:

i=0x11;break;

case 0x12:

i=0x12;break;

case 0x14:

i=0x13;break;

case 0x18:

i=0x14;break;

case 0x21:

i=0x15;break;

case 0x22:

i=0x09;break;

case 0x24:

i=0x06;break;

case 0x28:

i=0x03;break;

case 0x41:

i=0x00;break;

case 0x42:

i=0x08;break;

case 0x44:

i=0x05;break;

case 0x48:

i=0x02;break;

case 0x81:

i=0x16;break;

case 0x82:

i=0x07;break;

case 0x84:

i=0x04;break;

case 0x88:

i=0x01;break;

}

return(i);

}

uchar key_value()

{

uchar tem,s,t,n;

P1&=0x0f;

P2|=0x0f;

;

tem=P2;

tem|=0xf0;

s=~tem;

P2&=0xf0;

P1|=0xf0;

;

tem=P1;

tem|=0x0f;

t=~tem;

s=s+t;

n=encoder(s);

return(n);

}

uchar key(void)

{

uchar i;

P2|=0x0f;

P1&=0x0f;

;

i=P2;

i|=0xf0;

i=~i;

return(i);

}

void show1(uchar i,uchar j)

{

P0=a[j];

P2=P2&0x0f;

P2|=1

}

void show(uchar i,uchar j,uchar k,uchar l) {

uchar a[10]={0x81,0xED,0x43,0x49,0x2D,0x19,0x11,0xCD,0x01,0x09};

uchar b,c,d,e;

b=a[i];

c=a[j];

d=a[k];

e=a[l];

P2&=0x0f;

P2=0x1f;

P0=b;

delay(1);

P2&=0x0f; P2=0x2f;

P0=c;

delay(1);

P2=0x4f;

P0=d;

delay(1);

P2=0x8f;

P0=e;

delay(1);

}

void year(void)

{

while(key()==0) {

show1(4,2);

delay(1);

show1(3,0);

delay(1);

show1(2,1);

delay(1);

show1(1,3);

delay(1);

}

}

void monthday(void) {

TMOD=0X01; TH0=0x4c;

TR0=1;

IE=0X82;

TMOD=0x01; while(key()==0) {

show1(4,0);

delay(1);

show1(3,1);

delay(1);

show1(2,0);

delay(1);

show1(1,t4%10); delay(1);

}

}

void hourminute(void) {

TMOD=0X01; TH0=0x4c;

TL0=0x00;

TR0=1;

IE=0X82;

TMOD=0x01; while(key()==0) {

show1(4,t3/10); delay(1);

show1(3,t3%10); delay(1);

show1(2,t2/10); delay(1);

show1(1,t2%10); delay(1);

}

}

void minutesecond() {

TMOD=0X01; TH0=0x4c;

TL0=0x00;

TR0=1;

IE=0X82;

while(key()==0) {

show1(4,t2/10); delay(1);

show1(3,t2%10); delay(1);

show1(2,t1/10); delay(1);

show1(1,t1%10); delay(1);

}

}

void jishi(void)

{

TMOD=0X01; TH0=0x4c;

TL0=0x00;

TR0=1;

IE=0X82;

TMOD=0x01; while(key()==0) {

show1(2,t5/10); delay(1);

show1(1,t5%10); delay(1);

}

}

void shuru(void)

{

--k1;

if(k1==0)k1=4;

while(key()==0)

{

p[k1]=c;

show1(4,c);

delay(1);

}

}

void sure(void)

{

while(key()==0)

{

show(p[1],p[2],p[3],p[4]); delay(1);

}

}

void timer0(void) interrupt 1 {

t++;

if(t==20)

{

t=0;

t1++;

t5--;

if(t5==0)

{

while(key()==0) {

show1(2,0);

delay(1);

show1(1,0);

delay(1);

P3_2=~P3_2;

delay(1);

P1_3=~P1_3;

delay(1);

}

}

t6--;

if(t6==0)

{

}

if(t1==60)

{

t1=0;

t2++;

if(t2==60)

{

t2=0;

t3++;

if(t3==24)

{

t3=1;

t4++;

if(t4==30)t4==1;

}

}

}

}

TH0=0x4c;

TL0=0x00;

}

void main()

{

while(1)

{

i=key();

while(i!=0)

{

if(i==key())

{

uchar k;

k=key_value();

c=k;

if(c==0x11)year();

else

if(c==0x12)monthday();

else

if(c==0x13)hourminute();

else

if(c==0x14)minutesecond();

else

if(c==0x15)jishi();

else

if(c==0x16)sure();

else

if(c==0x00||0x01||0x02||0x03||0x04||0x05||0x06||0x07||0x08||0x09)

shuru();

else;

}

else

break;

}

}

}

Conclusion: Through the single chip microcomputer can accurately realize the accurate per time, can realize the countdown, display determined year, month, day , hour, minutes, seconds, and some other functions.

Reference:

[1]郭晓林. 基于单片机的电子时钟设计[J].中国科技博览,2010,(9).

[2]何立民. 单片机应用技术选编(11)[M ].北京航天航空大学出版社,2006.

[3]刘守义. 单片机应用技术[M ].西安电子科技大学出版社,2009.

[4]时钟芯片DS1302中文资料,http://www.dz3w.com/info/commonIC/0083003.html


相关内容

  • 2015科技小论文模板
  • 自动化工程学院毕业设计(论文) 科 技 论 文 学生姓名: 学 号: 专 业:□自动化 □测控技术与仪器 论文题目: 指导教师: 2014年6月 数控直流恒流源的设计 学生姓名,导师姓名 (1.东北电力大学自动化工程学院自动化专业15届毕业生,吉林,吉林 132012: 2. 东北电力大学自动化工程 ...

  • 全自动坐便器电器控制系统设计
  • 全自动坐便器电器控制系统设计 杨景芝,付丽娟 (莱芜职业技术学院 山东莱芜 271100) 摘要:基于AT89C51单片机的全自动坐便器控制系统,主要由红外感应系统,单片机控制系统和外围设备及其驱动 电路3部分组成.该系统通过2个红外感应中断,分别感应到人的靠近和人体停留的时间,并将信息传送给单片机 ...

  • 大学生创新训练论文
  • 大学生创新训练论文 摘 要:基于项目的大学生创新训练计划的实践能够提高大学生的创新能力,调动学生的主动性.积极性和创造性. 关键词:大学生创新 缺陷检测 训练计划 为培养学生的创新创业意识,调动学生学习的积极性.主动性和增强其创新创业能力,教育部和地方教育行政部门在"十二五"期间 ...

  • 基于GSM网络智能家居系统设计_毕业论文
  • 天津工业大学 毕业设计(毕业设计(论文)论文) 基于GSM网络智能家居系统设计 网络智能家居系统设计 姓 名 名: 院(系)别: 电子与信息工程学院 电子与信息工程学院 专 业 业: 通信工程 通信工程 通信工程 班 级 级: 通信 通信 通信 指导教师:指导教师: 2012年 6 月 6 日 天津 ...

  • 智能温控调速风扇的设计
  • 第12卷第4期2009年12月 上海电机学院学报 J OURNAL OF SHANGHA I D I AN JI UN I RS I TY ol .12No.4D ec . 2009文章编号1671-2730 2009 04-0297-04 智能温控调速风扇的设计 陈富忠1! 翁桂琴2 ! 1. 上 ...

  • 水轮机调速器研究概述
  • 2009年第6期液压与气动 3 水轮机调速器研究概述 张海明,林义忠,莫代新 SummaryofHydro-turbineGovernorResearch ZHANGHai-ming,LINYi-zhong,MODai-xin (广西大学机械工程学院,广西南宁530004) 摘要:水轮机调速器是水电 ...

  • 文献综述写作指导
  • 文献综述写作指导 一. 文献综述的意义和特征 文献综述是对某一方面的专题搜集大量情报资料后经综合分析而写成的一种学术论文,它是科学文献的一种. 文献综述是反映当前某一领域中某分支学科或重要专题的最新进展.学术见解和建议以及该专题的新动态.新趋势.新水平.新原理和新技术等等. 写作文献综述的意义在于通 ...

  • 文件检索课题报告
  • 计算机与控制工程学院学 术文献检索 实 验 报 告 姓名___ __ _ 学号_ __ 成绩____________ 一.实验要求: 1.实验前要认真复习课堂所学知识,重点复习计算机检索技术.各种中外文数据库的使用方法.网络学术信息资源查询等内容. 2.检索实验中应按照检索实验步骤,逐步进行实验,认 ...

  • CO2焊熔滴过渡特征的分析和研究
  • 1 文章编号:( ) 焊熔滴过渡特征的分析和研究 华中理工大学(武汉・ )朱六妹 肖孝菊 王 伟 谢明立 ! ! ! " # $% [摘要]介绍了熔滴过渡的数据采集系统,采用多种数据处理方法对焊接电压波形和电流波形进行分析,并从中提取 出短路过渡的熔滴过渡特征.重点阐述了各种方法的实现和应 ...