课程设计封面
- 格式:doc
- 大小:5.19 MB
- 文档页数:19
课程设计封面
2
课程设计(论文)
题 目 名 称 基于单片机的电子时钟设计
课 程 名 称 单片机原理及应在电气测控学科中的应用
学 生 姓 名 曾翰捷
学 号 1041201195
系 、专 业 电气工程及其自动化
指 导 教 师 王跃球
2012年5月30日
3
4
5 系 电气工程及其自动化
专业班级 10电三
题目名称
基于单片机的电子时钟设计
课程名称
单片机原理在电气测控学科中的应用
一、学生自我总结
通过本此次单片机课程设计的学习,在做本次课程设计的过程中,我感触最深的当属查阅大量的设计资料了。为了让自己的设计更加完善,查阅这方面的设计资料是十分必要的,同时也是必不可少的。
其次,在这次课程设计中,我们运用到了以前所学的专业课知识,如:C语言、模拟和数字电路知识等。虽然过去从未独立应用过它们,但在学习的过程中带着问题去学我发现效率很高,这是我做这次课程设计的又一收获。后,要做好一个课程设计,就必须做到:在设计程序之前,对所用单片机的内部结构有一个系统的了解,知道该单片机内有哪些资源;要有一个清晰的思路和一个完整的的软件流程图;在设计程序时,不能妄想一次就将整个程序设计好,反复修改、不断改进是程序设计的必经之路; 学生签名: 曾翰捷 2012 年 5 月 30日
二、指导教师评定
评分项目 平时成绩 论文 答辩 综合成绩
权
重 30 40 30 单项成绩
指导教师评语:
指导教师(签名):
6 年 月 日
注:1、本表是学生课程设计(论文)成绩评定的依据,装订在设计说明书(或论文)的“任务书”页后面;
2、表中的“评分项目”及“权重”根据各系的考核细则和评分标准确定。
中文摘要
单片机是集CPU、RAM、ROM、定时、计数和多种接口于一体的微控制器。近年来随着计算机在社会领域的渗透和大规模集成电路的发展,单片机的应用正在不断地走向深入而51 单片机是各单片机中最为典型和最有代表性的一种。由于它具有功能强,体积小,功耗低,价格便宜,工作可靠,使用方便等特点,因此特别适合于与控制有关的系统,越来越广泛地应用于自动控制,智能化仪器,仪表,数据采集,军工产品以及家用电器等各个领域,本文介绍单片机AT89C51结合74LS373设计时钟定时控制器实现的方案。74LS373为三态输出的八组缓冲器。本系统将单片机AT89C51内部时钟读出并通过七段数码管(LED)显示出来,通过按键设定的时间来改变系统的闹钟时间,单片机依据设定的时间来响铃,从而实现了系统的智能化。
Abstract
MCU is a CPU、RAM、ROM、 timing、 counting and multiple interfaces
in one microcontroller. In recent years, with the field of computer
penetration in the community and the development of large-scale
integrated circuits, single-chip applications is steadily moving
toward depth and 51 single-chip is the most typical and most
representative one. Because of its strong functions, small size, low
power consumption, cheap, reliable and easy to use and so on, it is
particularly suited to control systems and, more widely used in
automatic control, intelligent instruments, meters, data
7 acquisition, military products, as well as household appliances and
other fields, This article describes the design of single-chip
microcomputer AT89C51 combination 74LS373 clock timing of the
program controller. 74LS373 tri-state output for the eight sets of
buffers . AT89C51 single-chip microcomputer of the system will read
out the internal clock and through the LED display, through the
button to set the alarm clock to change the system time, single-chip
based on the time to set alarm clock processing, thus realizing the
intelligent system.
目 录
一、设计内容 5
二、电路图 5
三、软件程序 6
四、程序流程图 12
五、实物图 15
8
一、设计内容
该课程设计是利用89C51系列单片机内部的定时/计数器、中断系统、以及外围的按键和LED显示器等部件,设计一个单片机电子时钟。设计的电子时钟通过数码管显示,并能通过按键实现设置时间和暂停、启动控制等。
二、电子时钟硬件图
9
三、软件程序
#include
#define uchar unsigned char
#define uint unsigned int
sbit key1=P3^0;
sbit key2=P3^1;
sbit key3=P3^2;
sbit aa=P1^0;
sbit bb=P1^1;
sbit cc=P1^2;
sbit dd=P1^3;
10 sbit ee=P1^4;
sbit ff=P1^5;
uchar t,i,j;
uchar i,datp;
uchar code smg_table[]={
~0x3f,~0x06,~0x5b,~0x4f,
~0x66,~0x6d,~0x7d,~0x07,
~0x7f,~0x6f};
char miao,fen,shi;
uchar keynum;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void smg_wei(uchar i)
{
switch(i)
{
case 0:P1=0xef; break;
case 1:P1=0x02; break;
case 2:P1=0x04; break;
case 3:P1=0x08; break;
case 4:P1=0x10; break;
case 5:P1=0x20; break;
}
}
void smg_num(uchar num)
{
P0=smg_table[num];
if(datp==1)
{
datp=0;P0=(smg_table[num])&0x7f;
}
}
void smg_dispaly(uchar add,uchar su)
{
smg_wei(add);
11 smg_num(su/10);
delay(4);
P0=0x00;//消重影
if((add==0)||(add==2))
{datp=1;}
smg_wei(add+1);
smg_num(su%10);
delay(4);
P0=0x00;//消重影
}
void T0_time()interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
t++;
if(t==18)
{
t=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{
shi=0;
}
}
}
}
}
void init()
{
P3=0xff;