基于AT89C51单片机控制的万年历探究

合集下载

基于51单片机的键盘盘可调万年历

基于51单片机的键盘盘可调万年历

开放性实验报告题目:基于80C51的万年历设计_院系:专业班级:学号:姓名:指导老师:________________________ 时间:2014年9月8号电子万年历是一种非常广泛日常计时工具,对现代社会越来越流行。

它可以对年、月、日、周、时、分、秒进行计时,还具有闰年补偿等多种功能。

本系统选用DALLAS公司生产的日历时钟芯片DS1302来作为实时时数字万年历采用直观数字显示,可以同时显示年、月、日、周、时、分、秒等信息,还具有键盘时间校准等功能。

该电路采用AT89C52单片机作为核心,用以5V电压供电。

本系统硬件部分由AT89C52单片机、DS1302时钟芯片、LCD1602液晶显示环境下以C51语言编写,包括时间设置、时间显示、时间修正等功能。

在仿真的时候,以Proteus与Keil uVision4软件为基础,编写了MCS-51单片机对LCD1602显示控制的软件,绘制其原理图,并使用Proteus软件与Keil uVision4软件建立联合仿真。

本设计主要论述了原理图各个模块的作用,以及控制软件的各个模块的编程。

关键词:时钟芯片DS1302;单片机AT89C52;液晶显示1602;独立键盘等第1章绪论................................................ 错误!未定义书签。

1.1实时万年历的简介.................................... 错误!未定义书签。

1.2系统所实现的功能 .................................... 错误!未定义书签。

第2章开发工具软件简介.. (5)2.1K EIL U V ISION4软件简介 (5)2.2P ROTEUS软件简介 (5)2.3K EIL U V ISION4与P ROTEUS软件联合仿真 (6)第3章 LCD1602显示控制技术.............................. 错误!未定义书签。

《单片机C51项目设计与开发》电子教案 项目5 万年历的控制和制作

《单片机C51项目设计与开发》电子教案 项目5  万年历的控制和制作
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
任务1 PG160128A液晶显示
上一页 下一页 返回
• 任务分析
• 1.硬件电路分析 • 使用单片机的P1口传送数据DO~D7, P2.0, P2.1, P2.2, P2.3分别控
制PG160128A的CD, CE, WR和RD引脚,电路原理图如图5-1所示。 • 2.软件设计思路 • 软件程序设计需要按照PG160128A液晶显示器的读写操作时序来编
上一页 下一页 返回
任务1 PG160128A液晶显示
• SS:控制器运行检测可能性,1:可能,0:不能 • S6:屏读/拷贝出错状态,1:出错,0:正确 • S7:闪烁状态检测,1:正常显示,0:关显示 • 由于状态位作用不一样,因此执行不同指令必须检测不同状态位。在
CPU每一次读、写指令和数据时,S0和S1要同时有效,处于“准备 好”状态。 • 当CPU读、写数组时,判断S2或S3状态。 • 屏读、屏拷贝指令使用S6。 • SS和S7反映T6963C内部运行状态。 • (2)地址指针设置指令

毕业设计 基于51单片机的万年历设计1

毕业设计 基于51单片机的万年历设计1

基于51单片机的万年历设计单片机经过几十年的发展,已经广泛应用于生活中的各个领域。

单片机以其体积小、功能全、性价比高等诸多优点,在许多行业都得到了广泛应用。

在工业控制、家用电器、通信设备、信息处理、尖端武器等各种测控领域的应用中独占鳌头,单片机开发技术已成为电子信息、电气、通信、自动化、机电一体化等专业技术人员必须掌握的技术。

基于单片机的万年历作为设计的课题,因为它有很好的开放性和可发挥性,对作者的要求比较高,不仅考察了对单片机的掌握能力而且强调了对单片机扩展的应用。

另外液晶显示的万年历已经越来越流行,特别适合在家庭居室、办公室、大厅、会议室、车站和广场等地方使用,它具有显示清晰直观、走时准确、可以进行夜视等功能,并且还可以扩展出其它多种功能。

所以,电子万年历作为设计课题很有价值。

现在对于电子万年历的设计大多运用51单片机。

主要是因为51单片机种类齐全、结构体系完整、指令系统功能完善、性能优越、具有较高可靠性和高性价比等特点。

本篇论文主要介绍了运用单片机实现电子万年历的设计,万年历系统拟用STC89C51单片机控制,以DS1302时钟芯片计时、1602液晶屏显示。

系统主要由单片机控制电路,显示电路以及校正电路三个模块组成。

本文阐述了系统的硬件工作原理,所应用的各个接口模块的功能以及其工作过程,论证了设计方案理论的可行性。

目录第一章绪论 (1)1.1本课题主要的研究工作 (1)第二章系统的硬件设计与实现 (2)2.1电路设计框图 (2)2.2系统硬件概述 (2)2.3主要单元电路的设计 (2)2.3.1 单片机主控制模块的设计 (2)2.3.2时钟电路模块的设计 (3)2.3.3独立式键盘设计 (4)2.3.4显示模块的设计 (4)第三章系统的软件设计 (6)3.1程序流程图 (6)3.1.1 系统总流程图 (6)3.1.2 DS1302时钟程序流程图 (7)3.1.3 LCD显示程序流程图 (8)3.2程序的设计 (9)3.2.1 DS1302读写程序 (9)3.2.2 液晶显示程序 (11)第四章仿真与调试 (13)4.1K EIL软件调试流程 (13)4.2P ROTEUS软件运行流程 (13)4.3万年历的功能仿真 (13)致谢 (15)参考文献 (16)附录:主程序 (17)第一章绪论1.1 本课题主要的研究工作本项目是一种基于AT89C51片机的万年历设计,本方案以AT89C51片机作为主控核心,与时钟芯片DS1302、按键、LCD1602液晶显示器组成硬件系统。

基于51单片机的万年历

基于51单片机的万年历
二、系统的硬件设计与实现
洞洞板/万能板成品
图片左下角有地址-有录像
2.1电路设计框图
2.2 系统硬件概述
本电路是由AT89C52单片机为控制核心,具有在线编程功能,低功耗,能在3V超低压工作;本设计直接采用单片机定时计数器提供秒信号,它可以对年、月、日、星期、时、分、秒进行计时,具有闰年补偿功能,工作电压为2.5V~5.5V。显示部份由LCD1602完成。
写指令38H(不检测忙信号)以后每次写指令、读/写数据操作均需要检测忙信号
写指令38H:显示模式设置写指令08H:显示关闭写指令01H:显示清屏
写指令06H:显示光标移动设置写指令0CH:显示开及光标设置
三、系统的软件设计
3.1 程序流程框图
否否否
是是是
否否否
是是是
四、总结
在整个设计过程中,遇到了很多问题,但在自己的努力和同学的帮助下得到了解决,较好的完成了作品,勉强达到了预期的目的。并且在这一过程中也学到了许多之前没学过的知识。在电路焊接时虽然没什么大问题,但从中也知道了焊接在整个作品中的重要性,对电路的设计、布局要先有一个好的构思,然后再焊才可以使电路板美观并且可以减少飞线的使用,并且最好焊接一部分测试一部分。通过这次设计,特别是通过程序的编写,更深入地了解了单片机的内部结构和外围器件的应用。
sbit s1=P2^3;
sbit s2=P2^2;
sbit s3=P2^0;
unsigned char tt,s1num;
char miao,fen,shi,yue=1,ri=1,week,nian;
unsigned char a[]="2000-01-01MON";
char b[]=" 00:00:00";

基于51单片机的多功能电子万年历的设计结题报告

基于51单片机的多功能电子万年历的设计结题报告

基于51单片机的多功能电子万年历的设计作者1(哈尔滨工程大学,黑龙江省哈尔滨市150000)摘要:电子万年历是一种非常广泛日常计时工具,对现代社会越来越流行。

它可以对年、月、日、周日、时、分、秒进行计时,还具有闰年补偿等多种功能,而且DS1302的使用寿命长,误差小。

对于数字电子万年历采用直观的数字显示,可以同时显示年、月、日、周日、时、分、秒等信息,还具有时间校准等功能。

该电路采用STC89C51单片机作为核心,功耗小,电压可选用5V电压供电。

本设计是基于51系列的单片机进行的电子万年历设计,可以显示年月日时分秒及周信息,具有可调整日期和时间功能。

在设计的同时对单片机的理论基础和外围扩展知识进行了比较全面准备。

在硬件与软件设计时,没有良好的基础知识和实践经验会受到很大限制,每项功能实现时需要哪种硬件,程序该如何编写,算法如何实现等,没有一定的基础就不可能很好的实现。

在编写程序过程中发现以现有的相关知识要独自完成编写任务困难重重,在老师和同学的帮助下才完成了程序部分的编写。

关键词:电子时钟;DS1602;STC89C51中图分类号:(作者本人填写)文献标识码:A 文章编号:1006-7043 (2004) xx-xxxx-xThe Design of electronics clock according to 51 MCUNAME Name1Xiangkai Xu,2Xinchi Dun,3Binkai Y u,4Yuehu Liu (Harbin Engineering university, Harbin City Heilongjiang Province , 150000, China) Abstract:E-calendar day time is a very wide range of tools, increasingly popular in modern society. It can be year, month, day, Sunday, hours, minutes, seconds for time, but also has a leap year compensation to a variety of functions, and the DS1302's long life, small error. For the digital electronic calendar using an intuitive digital display can simultaneously display year, month, day, Sunday, hours, minutes, seconds, and other information, but also a time-calibration and other functions. The circuit uses STC89C51 microcontroller as the core, power consumption, the voltage can choose 5V voltage supply.The design is based on 51 series of microcontrollers to the design of electronic calendar, you can display date information on when the minutes and seconds, and weeks, with adjustable date and time functions. At the same time in the design of the theoretical basis of the MCU and peripheral expansion of knowledge of the more comprehensive preparation. The hardware and software design, there is no good basic knowledge and practical experience will be greatly limited, each feature is required to achieve the kind of hardware, procedures, how to write, how to implement such algorithms, there is no certain foundation can not be good implementation. Found during the preparation process to the existing knowledge to complete the preparation of the task alone difficult,In the help of teachers and students to complete the program part of the preparation.Key words:Clock electric clock:DS1302;STC89C51引言:随着科技的快速发展,时间的流逝,至从观太阳、摆钟到现在的电子钟,人类不断研究,不断创新纪录。

基于At89C系列的电子万年历毕业论文

基于At89C系列的电子万年历毕业论文

基于At89C系列的电子万年历毕业论文目录摘要 (2)关键字 (2)第一章概述 (4)1.1 课题的背景研究意义 (4)1.2 本课题实现的功能及要求 (4)1.3 方案论证 (4)1.4 章节安排 (4)第二章系统硬件设计2.1 硬件电路设计总框图 (5)2.2 主控制器AT89C52的介绍 (5)2.3 其余应用电路的介绍 (8)第三章软件设计3.1 软件设计总述 (13)3.2 程序模块介绍 (13)第四章调试和总结4.1 硬件调试 (20)4.2 软件调试 (20)4.3 联调 (21)第五章心得体会 (22)参考文献附录一汇编源程序 (23)附录二仿真电路图 (35)附录三参考文献 (36)第一章概述1.1 课题的背景、研究意义随着电子技术的迅速发展,时间的流逝,从观察太阳、摆钟到现在的电子钟, 人类不断研究、不断创新。

现市场的电子钟具有低功耗的实时时钟电路,它们可以对年、月、日、周日、时、分、秒进行计时,还具有润年补偿等功能,且使用寿命长、误差小、使用方便。

电子万年历的出现给人们的生活带来的诸多方便。

目前,国际上的电子万年历正从模拟式向数字式、由集成化向智能化的方向飞速发展。

综上所述此万年历具有读取方便、显示直观、功能多样、电路简洁、成本低廉等诸多优点,符合电子仪器仪表的发展趋势,具有广阔的市场前景。

1.2实现的功能及要求(1)基本要求①具有年、月、日、星期、时、分、秒等功能;②具备年、月、日、星期、时、分、秒校准功能。

③校准时具有闪烁功能。

( 2 ) 创新要求①具有上、下课响铃功能;1.3 方案论证显示模块选择方案和论证:方案一:采用LED数码管动态扫描,LED数码管价格适中,对于显示数字最合适,而且采用动态扫描法与单片机连接时,占用的单片机口线少。

但这里显示位数多,所要求的数码管多,成本更高。

方案二:采用LCD液晶显示屏,液晶显示屏的显示功能强大,可显示大量文字,图形,显示多样,清晰可见,虽价格昂贵,但接口线多,所以在此设计中采用LCD液晶显示屏。

基于51单片机的万年历设计流程

基于51单片机的万年历设计流程
基于51单片机的万年历设计流程可以分为以下几个步骤:
1. 确定需求:首先,你需要明确你的万年历需要有哪些功能。

例如,是否需要显示日期、时间、星期,是否需要闹钟功能,是否需要手动或自动校准等。

2. 选择硬件:选择合适的单片机作为主控制器。

常用的单片机有8051系列,如AT89C51、AT89S52等。

此外,还需要选择适当的显示模块、按键模块、实时时钟模块等。

3. 设计硬件电路:根据选择的硬件设备,设计电路原理图和PCB图。

需要
考虑单片机的引脚连接、电源供给、时钟源、外部扩展等问题。

4. 编写软件程序:根据硬件电路和需求,编写相应的软件程序。

这包括初始化程序、主程序、中断服务程序等。

5. 调试和测试:将编写好的程序下载到单片机中,进行实际测试。

根据测试结果,对程序进行调试和修改,直到满足设计要求。

6. 生产:完成调试后,就可以进行批量生产了。

在生产过程中,还需要对产品进行质量检测,确保每个产品都能正常工作。

7. 后期维护:在产品上市后,可能需要对产品进行维护或升级。

例如,如果用户在使用过程中发现了问题,或者有新的需求,就需要对产品进行改进或升级。

以上是基于51单片机的万年历设计的基本流程,但具体的步骤可能会根据具体的需求和硬件设备有所不同。

基于AT89C51单片机设计的电子万年历

With the improvement of people's living standard and life rhythm accelerate, the time requirements of increasingly high, precision digital timing consumption demand is increasing.The production of electronic calendar has many kinds, general to study of multi-function electronic calendar, the calendar in addition to the original display time, date and other basic functions, also has the alarm, alarm and other functions. Business production of electronic calendar from the quality, price, and practical considerations, constantly improve the design of the electronic perpetual calendar, making it more with the market.The design for the software, hardware with a combination of a set of design. In software design, the hardware part should have relevant knowledge, which helps to design a deeper understanding, contribute to software design. Basic to understand some of the main devices of the basic functions and role. In addition to using integrated clock chip, and adopts the scheme of MCU, using AT89series single-chip microcomputer made perpetual calendar circuit, use a combination of hardware and software methods, control of LED digital tube output, are used to show the year, month, day, hours, minutes and seconds, the main point is: the hardware circuit is simple, the installation convenient and easy to realize, the software design is unique, reliable. AT89C51 is offered by the ATMEL a small microcontroller. 95 years in China market. Its main characteristics is the Flash memory technology, reduces the manufacturing cost of the hardware, software, fully compatible with the MCS-51, can very quickly by the Chinese majority of user acceptance. This paperintroduces the design of the electronic perpetual calendar based on AT89C51.1 design schemesThis article proposed one kind based on the AT89C51MCU calendar design, the program to AT89C51single-chip microcomputer as a controlling core, and the clock chip DS1302, keyboard, LED display modules and hardware system. In the hardware system with a separate keyboard and LED display, can display a wealth of information, according to the needs of users at any time on time calibration, choice of time, to sum up this calendar is convenient, intuitive display, multiple functions, simple circuit, low cost and many other advantages, comply with the development trend of electronic instrumentation, has broad market prospect.2 functional requirementsElectronic calendar can dynamically display the year, month, day, week, hour, minute, second.3 technical feasibilityWith the domestic large scale integrated circuits, the microprocessor and its peripheral chip had rapid development. Integrated technology most recent development is one of the CPU and peripheral chips, such as program memory, data memory, parallel I/O port, serial I/O port, timer / counter, an interrupt controller and other control components are integrated in a chip, made of monolithic computer ( Single-Chip Microcomputer ). But in recent years the introduction of some high-end chip also includes many special function unit, such as A/D, D/A converter, modem, communicationcontroller, phase locked loop, DMA, PWM floating-point unit, output control unit, PWM output when the dead programmable control function. Therefore, so long as the external expansion circuit and the necessary channel interface can make all kinds of computer application systems, such as industrial production line control system of household appliances, as the main controller, distributed control system terminal node or as its main control node up relay used, data acquisition system, automatic testing system. The appearance of single chip microcomputer, and the technology in the field of such rapid development, and the single chip computer application system formed by the following characteristics: (1) single chip computer application system has higher reliability. The reliability of the obtained in addition to rely on the chip itself the high reliability and application have the least connection, also can be conveniently made of soft, hardware technology. (2) extension of the system, system configuration is typical, specification, easy to scale a variety of application system, application system has high utilization coefficient of soft, hardware. (3) in the form of application system is a computer system, a considerable measure, control functions are realized by software, so with flexible features, do not have to change the hardware system can properly change system function. (4) have superior performance, price ratio.The 4 chip selectThe main control chip using51 Series MCU clock chip using AT89C51, American DALLAS company introduced a high performance, low power consumption, with the RAM real-time clock DS1302. Using DS1302 asthe timing chip, can achieve accurate timing. More importantly, DS1302can be in a very small current back-up power supply (2.5~ 5.5V power supply,2.5V power consumption less than 300nA), and DS1302 Can be programmed to select a variety of charging current to power for slow charge, can guarantee the basic power backup power supply.Display driver using MAX7219, MAX7219 is a microprocessor and a common cathode eight eight LED digital tube display, graph bar / column chart displays or64 dot matrix display interface small serial input / output chip. Sheet including BCD decoder, multiple scan controller, word and bit drive and 8x 8static RAM. External resistor only need one set all LED displays current field. MAX7219 and microprocessor only three wires to connect, each show has an address by the digital microprocessor write. Allow users to choose each BCD decoding or not decoding. Users can also choose to shutdown mode, the digital brightness control, from 1 to8to select the scan number and LED displays for all the test mode. Display module using ordinary common cathode four in one of the eight LED digital tube.The 5 display driver MAX7219(1) MAX7219 and single chip computer is connected with three wires ( DIN, CLK, LOAD ), using16 bit data serial shift receiving mode(2) eight LED display, graph bar / column chart displays or64 dot matrix display(3) including a BCD decoder, multiple scan controller, word and bit drive and 8x 8static RAM(4) may choose to shutdown mode, the digital brightness control, from 1 to8to select the scan number and LED displays for all the test mode(5) can drive8LED display(6) the internal RAM address 01~ 08H respectively corresponding to DIG0 ~DIG7.(7) scan register ( address:0BH ) the register in the D0 ~ D3 bits of data of the set value is 0 ~ 7H, set the value of said display dynamic scanning digital from 1 to8.(8) stop register ( address:0CH ) when D0=0, MAX721is in a halt state; when D0=1, in a normal working state.(9) showed the test register ( address:0FH ) when D0=0, MAX7219according to a set pattern in normal work; when D0=1, in beta status. In this state, regardless of the MAX7219in what mode, all of the LED will be the maximum brightness display.(10) the brightness register ( address:0AH ) luminance can use the hardware and software of the two methods to regulate brightness registers in the D0 ~D3can control LED display.LED display register by an internal8x 8static RAM, the operator can direct positioning of individually addressable register, to refresh and keep the data, as long as more than 2 V ( V + for + 5V ).Control register includes: decoding mode, display brightness adjustment, scan limits ( select scan digits), shutdown and display the test register.6 DS1302working mode and data operation principleDS1302can be years, months, days, weeks, when, minutes and seconds for time, and has a leap year compensation function, wide voltage up to 2.5~5.5V. Using a three wire interface synchronization with CPU communication, and may use a burst mode a transmission of multiple byte clock signal or RAM data. DS1302has a33x8for temporary storage of data RAM register. DS1302 is a DS1202 upgrade products, compatible with DS1202, but the increase of main power supply dual power supply pins / back to back, while providing a power supply current trickle charging capability.DS1302 clock chip includes a real time clock / calendar and31 bytes of static RAM. It passes through a simple serial interface and communication. Real time clock / calendar with seconds, hours, days, weeks, months and years of information. For less than 31days at the end of the month and the date is automatically adjusted, also includes a leap year correction function. The operation of the clock can be used with AM/PM24< > or12 hour format. Using a three wire interface synchronization with CPU communication, and may use a burst mode a transmitted byte clock signal or RAM data.DS1302 in any transmission of data must be initialized, the RST foot placement is high, then the8 bits of the address and command words into the shift register, the data at the rising edge of SCLK was access to. At the beginning of the 8clock cycle, the command byte loaded into the shift register, another clock cycle during a read operation when the output data, in a write operation for writing data. The number of clock pulses in single byte mode for8+8, in multiple byte mode for8+ bytes, the maximum is 248bytes. If the transmissionof the mid-mounted RST feet for low level, it will terminate the data transmission, and the I/O pin into a high resistance state. Power on run time, the Vcc ≥2.5V, RST foot must be kept low level. Only when the SCLK is low, can be set to high level RST.DS1302 total of12 registers, which has 7registers and calendar, clock, stored data bits for BCD code.Clock seconds pause: register bit7bit clock pause a definition. When it is 1, DS1302stops oscillating, entering the low power backup, usually in the DS1302write operation (such as entering a clock adjustment procedures ), oscillation stopped. When it is 0, the clock will start.AM-PM/12-24hour: hour register bit7is defined as 12or 24hour mode select bit. It is in high level,12hour. In this way, a5 for the second10 hours of bits (20 ~ 23h).The crystals DS1302choose 32768Hz, capacitor recommended values for6pF. Because of low frequency, can also be connected capacitor, the timing precision effect.The 7endingWhen I finally finished all the typing, typesetting, proofreading, drawing the task after all very tired, but at the same time looking at the computer screen graduation design manuscript my heart is sweet, I feel it all worth it.I will never forget this unforgettable several months. I am here to find information on the day, in the face of countless books list, the most memorable is each time finding information on the thrill and excitement. I'm from data collection, to master a lot ofmicrocomputer and its interface application knowledge, let me for what I have learned to consolidate and improve, and let me on the SCM new technology knowledge. Throughout the process, I learned new knowledge, the growth of knowledge. In the future days, I still have to continue to enrich themselves, for in the academic field dosomethinpreviouslyunreleased.Stand on solid ground, serious learning attitude, seek truth from facts, not afraid of difficulties, unremittingly, hard-working spirit is my in this design the maximum benefits. I think this is a willpower, is to my actual ability of a promotion, also for my future study and work of great help.随着人们生活水平的提高和生活节奏的加快,对时间的要求越来越高,精准数字计时的消费需求也是越来越多。

基于51单片机的万年历设计

一、引言万年历是一种日历工具,能够显示任何一个公历日期的星期、年、月和日,并且能够自动判断闰年。

在本设计中,我们将使用51单片机设计一个基于LCD显示屏的万年历。

它将能够显示当前的日期和星期,并且具备一些附加功能,如闹钟、计时器等。

二、设计目标本设计的主要目标是通过51单片机实现以下功能:1.显示当前日期和星期:使用LCD显示屏显示当前的年、月、日和星期。

2.闰年判断:根据公历算法判断是否为闰年,并在显示屏上进行标识。

3.闹钟功能:设置一个闹钟时间,并在指定时间到达时发出提醒。

4.计时器功能:实现一个简单的计时器,能够显示经过的时间。

三、系统框图```+------------------+51单片+---+----------+---++--v--++--v--+LCD ,, Keypa+-----++-------+```四、系统设计1.时钟模块:使用定时器模块实现系统的主时钟,根据预设的频率进行中断,更新时间和日期。

2.LCD模块:使用51单片机的IO口控制LCD显示屏,实现对日期、星期和其他功能的显示。

3.按键模块:通过按键模块实现对系统功能的操作,包括设置闹钟、切换功能等。

4.闹钟模块:根据预设的时间进行判断,判断是否到达闹钟时间并触发相应的操作。

5.计时器模块:通过计时器模块实现计时功能,显示经过的时间。

五、代码实现以下是基于51单片机的万年历的主要代码实现的伪代码:1.时钟模块:```初始化定时器;定时器中断中获取当前的日期和时间;```2.LCD模块:```定义LCD引脚;初始化LCD显示;定时刷新LCD内容;```3.按键模块:```定义按键引脚;初始化按键;判断按键事件并执行相应的操作;```4.闹钟模块:```设置闹钟时间;判断当前时间是否与闹钟时间相等;触发相应操作;```5.计时器模块:```设置起始时间;计算当前时间与起始时间的差值;显示计时时间;```六、实验结果通过上述的代码实现和电路连接,我们可以成功地实现了基于51单片机的万年历。

电子万年历毕业设计(基于AT89C51单片机和DS1302时钟芯片)

鹤壁职业技术学院毕业设计论文论文题目:电子时钟学院:机电工程学院专业:电气自动化班级:2009级01班学生姓名:贾贯可学号:0902511005 指导教师:司新生2011年10月 18 日目录摘要 (3)绪论 (5)第1章设计要求与方案论证 (7)1.1 引言 (7)1.2 功能要求 (7)1.3方案论证 (7)第2章系统硬件电路设计 (11)2.1 电路设计 (11)2.2 系统硬件概述 (15)2.3主要单元电路的设计 (15)第3章系统的软件设计 (22)3.1程序设计 (22)3.2程序设计流程图 (22)第4章结束语 (24)附录一(电路原理图)…………………………………………..……………附录二(程序清单) (27)摘要随着社会、科技的发展,人类得知时间,从观太阳、摆钟到现在电子钟,不断研究、创新。

为了在观测时间,能够了解与人类密切相关的信息,比如星期、日期等,电子时钟诞生了,它集时间、日期、星期等功能于一身,具有读取方便、显示直观、功能多样、电路简洁等诸多优点,符合电子仪器仪表的发展趋势,具有广阔的市场前景。

该电子时钟主要采用STC89C52RC单片机作为主控核心,由DS1302时钟芯片提供时钟、LED动态扫描显示屏显示。

STC89C52RC单片机是由Atmel公司推出的,功耗小,电压可选用4~6V电压供电;DS1302时钟芯片是美国DALLAS公司推出的具有涓细电流充电功能的低功耗实时时钟芯片,它可以对年、月、日、星期、时、分、秒进行计时,还具有闰年补偿等多种功能,而且DS1302的使用寿命长,误差小;数字显示是采用的LED显示屏来显示,可以同时显示年、月、日、星期、时、分、秒和温度等信息。

此外,该电子时钟还具有时间校准等功能。

关键词:时钟电路;时钟芯片DS1302;LED动态扫描;单片机STC89C52RC;绪论随着人们生活水平的提高和生活节奏的加快,对时间的要求越来越高,精准数字计时的消费需求也是越来越多。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

33 22H 65H 00H(2011) 22 21H 25H 41H(2012) 40 24H 52H 00H(2013)
30 52H 42H 91H(2014) 49 55H 05H 00H(2015) 38 26H 44H 00H(2016)
27 53H 50H 60H(2017) 46 53H 24H 00H(2018) 35 25H 54H 00H(2019)











二进
0
1
0
0
1
0
1
1
0
1
0
1
天数 30
29
30
30
29
30
29
29
30
29
30
29
十六
2
2
6
5
2012 年第 2 期(总第 62 期)
27
基于 AT89C51 单片机控制的万年历探究
2011 年春节和元旦相差 33 天:2011 年表示成为 33,22H,65H,00H。
2011- 2050 年的关系对应表
键盘由三个按键完成:控制键、加键、减键;接 10K 上 期在一年中的天数来计算阴历日期。阳历每月为 30 天或 31
拉电阻;查询法完成读键功能。
天(2 月除外,闰年 2 月为 29 天,平年为 28 天),阴历一
4 系统程序设计
年有 12 个月或 13 个月(含闰月),一个月为 30 天或 29 天。 把一个只有 29 天的月称为小月,用 1 为标志,把 30 天的月
同样,紧跟 8 位的下一个 SCL K 时钟的下降沿读出 DS1302
数据,读出数据从低位到高位;当复位端为低电平时,所有
的数据传送将被中止,且 I/ O 变为高阻状态。
DS1302 有 12 个寄存器,其中 7 个寄存器与日历、时钟 相关,存放数据为 BCD 码形式。
26
2012 年第 2 期(总第 62 期)
阴历程序的设计采用推算阳历来实现:根据阳历当前日 2011年阴历和阳历对应关系表
月份
1
2
3
4
5
6
7
8
9
10
11
12
大小












二进
1
0
1
0
1
0
0
1
0
1
0
1
天数
29
30
29
30
29
30
30
29
30
29
30
29
十六
5
2
2
5
2011年阴历和阳历对应关系表
月份
1
2
3
4
5
6
7
8
9
10
11
12
大小 大
随着经济发展,人们对生活质量要求不断提高,厂家也 不断推出了各种电子产品以满足人们的需要,而电子万年历 则顺应了人们对时间方面的要求。
1 系统构成与原理
1. 1 系统构成 系统采用 3 个 8 位 74LS164 串行接口外接 LED 液晶显
示器和矩阵键盘扫描电路,RESPACK-8 对单片机 AT89C51 进行 供 电 ,时 钟 电 路( 时 间芯 片 DS1302 ) 连 接单 片机 AT89C51,从而实现电子万年历的功能。
清屏 归 HOM E 位 输 入方 式设 置
0
0
0000 00 01
0
0
0000 00 1*
0
0
0 0 0 0 0 1 I/D S
1.64ms 1.64ms
40us
显 示状 态设 置
0
0
0000 1D C B
40us
光 标画 面滚 动 工 作方 式设 置 C GRAM 设置
0
0
0 0 0 1 S/C R/L * *
3 显示电路与键盘的设计
主控制器 AT89C51 主要特性:
显示部分采用字符型液晶显示模块,显示驱动控制器
(1)与 MCS-51 兼容;(2)4K 字节可编程闪烁存储器; HD44780U 操作指令见下表:
指令 名称
控制 信号 RS RW
控制 代码 D7 D6 D5 D4 D3 D2 D1 D0
运行 时 间 250khz
则表示存取日历时钟数据;为 1 表示存取 RAM 数据;位 5、
位 1 指示操作单元的地址;最低有效位(位 0)如果为 0,表
示要进行写操作,为 1 表示读操作。
DS1302 数据传送是把复位端 RST 置高电平,芯片写入
或读出由命令字节引导。控制命令输入后的下一个 SCL K 时
钟的上升沿时数据被写入 DS1302 ,数据输入从低位开始;
技术报告
海峡科学
HAI XI A KE XUE
DS1302 的日历、时钟寄存器及其控制字
(3)寿命:1000 写/擦循环;(4)数据保留时间:10 年; (5)全静态工作:0Hz-24Hz;(6)三级程序存储器锁定; (7)128*8 位内部 RAM;(8)32 可编程 I/O 线;(9)两 个 16 位定时器/计数器;(10)5 个中断源;(11)可编程串 行通道;(12)低功耗的闲置和掉电模式;(13)片内振荡 器和时钟电路。
时 钟电 路
1. 2 原理
A T89C51
键 盘扫 描与主控制器 AT89C51
DS1302 的控制的控制字节如下表所示:
7
6
5
4
3
2
1
0
1 RAM/CK A4
A3
A2
A1
A0 RAM/K
控制字节的最高有效位(位 7)是逻辑 1;位 6 如果为 0,
基于 AT89C51 单片机控制的万年历探究
基 于 AT89C51 单 片 机 控 制 的 万 年 历 探 究
福建省三明市农业学校 段 磊
[摘要] 介绍了基于 AT89C51 单片机控制的多功能电子万年历的硬件结构和软硬件设计方法。系统以 AT89C51 单片机为控制 器、以串行时钟日历芯片 DS1302 记录日历和时间;它可以对年、月、日、时、分、秒进行计时。万年历采用直观的数字显示, 可以在 LED 上同时显示年、月、日、周日、时、分、秒,还具有时间校准等功能。此万年历具有读取方便、显示直观、功能 多样、电路简洁、成本低廉等诸多优点,具有广阔的市场前景。 [关键词] AT89C51 电子万年历 DS1302
4. 1 阳历程序设计
称为大月,用 0 为标志。如有闰月,则把闰月的年份作为高
阳历程序只需从 DS1302 各寄存器中读出年、周、月、 四位,低四位表示闰月的大小,大月为 0,小月为 1。春节和
日、时、分、秒等数据。
元旦相差的天数用一个字节表示。总共用 4 字节存储一年中
4. 2 阴历程序设计
任一天阳历和阴历的对应关系的有关数据:
0
0
0 0 1 DL N F
**
0
0
0 1 A5 A4 A3 A2 A1 A0
40us 40us 40us
DDRAM 设置
0
0
1 A6 A5 A4 A3 A2 A1 A0
40us
读BF和 AC值 写 数据
0
1
BF A6 A5 A4 A3 A2 A1 A0
1
0
数据
40us 40us
读 数据
1
1
数据
40us
相关文档
最新文档