基于单片机的英文论文_第1页
基于单片机的英文论文_第2页
基于单片机的英文论文_第3页
基于单片机的英文论文_第4页
基于单片机的英文论文_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 the Real-Time Clock Based on AT89S51Author: 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 developmen

2、t 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 singl

3、e 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 keyb

4、oard, users can be preset time, display the time, set the content, set time operation mode, etc.Keywords: AT89S51; clock; digital tube; keyboard switch; functionIntroduction: AT89S51 is a very suitable for the beginners of the single chip microcomputer, it is fully compatible with the traditional in

5、struction 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 ,

6、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 systemAT89S51 has the following standard functions: 8 k bytes Flash, 256 bytes RAM, and 32-bit I/O lines, a wa

7、tchdog 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

8、content are stored, has been frozen, single chip microcomputer stops all work, until the next interruption or hardware reset.2. The displayDisplay 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 o

9、f 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

10、by the display.3. The keyboardKeyboard 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. T

11、he power supplyControl 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 po

12、wer 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 interfaceMicroprocessor uses AT89S51. AT89S51 has ISP online programming function, and P1.5 P1.7 are for

13、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 programm

14、ing 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 fi

15、nished, 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 |

16、8 | 9 | 月日 | | 确定 | 0 | 倒计时 | 年 | #include <reg51.h>#include<stdio.h>#define uchar unsigned charsbit P1_3=P13;sbit P3_2=P32;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;

17、uchar c;uchar a10=0x81,0xED,0x43,0x49,0x2D,0x19,0x11,0xCD,0x01,0x09;uchar p5;void delay(int MS) int i,j; for( i=0;i<MS;i+) for(j=0;j<1141;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 0x

18、21: 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(

19、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=aj; P2=P2&0x0f; P2|=1<<

20、(i+3);void show(uchar i,uchar j,uchar k,uchar l) uchar a10=0x81,0xED,0x43,0x49,0x2D,0x19,0x11,0xCD,0x01,0x09; uchar b,c,d,e; b=ai; c=aj; d=ak; e=al; 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(k

21、ey()=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; TL0=0x00;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) TM

22、OD=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; TMOD=0x01; while(key()=0) show1(4,t2/10); delay(1);show1(3,t2%10);

23、 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) pk1=c;show1(4,c);delay(1);void sure(void)while(key()=0)show(p1,p2,p3,p4);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=

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论