基于单片机控制的数字钟课程设计_第1页
基于单片机控制的数字钟课程设计_第2页
基于单片机控制的数字钟课程设计_第3页
基于单片机控制的数字钟课程设计_第4页
基于单片机控制的数字钟课程设计_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

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

文档简介

基于单片机控制的数字钟设计学院:专业班级:学号:姓名:

目录1.设计目的2.设计任务和要求3.设计内容3.1数字电子钟基本原理3.2数字电子钟电路模块设计3.3数字电子钟电路图3.4数字电子钟的调试5.实验心得

设计目的:我们此次设计与制做数字钟就是为了了解数字钟的原理,从而学会制作数字钟.而且通过数字钟的制作进一步的了解各种在制作中用到的中小规模集成电路的作用及实用方法.通过设计数字钟可以进一步学习与掌握各种组合逻辑电路与时序电路的原理与使用方法,把理论知识运用到实践当中。并且提高实际操作能力,能学会排查电路错误,布局布线要清晰。要学会灵活使用VHDL语言和直接画图方法的结合使用。设计任务及要求:拥有正常的时、分、秒的计时功能。能利用实验板上的按键实现校时、校分及秒清零功能。能利用实验板上的扬声器做整点报时。闹钟功能。在MAXPLUSII中采用层次化设计方法进行设计。完成全部电路设计后在实验板上下载,验证设计课题的正确性。设计内容:数字钟基本原理图:闹时设置闹时设置清零较分校时1KHZ64HZ4HZ1HZ位位位位位位模块设计:可分成6个模块实现:计时模块、校时模块、整点报时模块、分频模块、动态显示模块、闹钟模块。计时模块:基准源产生1Hz的脉冲;输入至秒计数器,满六十后产生进位,即脉冲;驱动分计数器;同理,满六十后,产生脉冲驱动时计数器;时计数器到23后,若再来脉冲则置零。两个60进制计数器和一个24进制计数器,分别用2个74160连接。以上图为60进制计数器连接以及生成的器件以上图为24进制计数器连接以及生成器件(2)校时模块:按下校时、或校分键都是递增调节到所需的位,按下清零键,秒计数器清零。可以选择实验板上的3个脉冲按键进行锁定。选用D触发器消抖。libraryieee;useieee.std_logic_1164.all;entitydisport(d:instd_logic;clk:instd_logic;q:outstd_logic);endd;architecturebhvofdisbeginprocess(clk)beginif(clk'eventandclk='1')thenq<=d;endif;endprocess;endbhv;计时和校时,两种脉冲新号用两路选择器进行选择,选择条件为是否按键。1HZ驱动计数器,高频校时。2路选择器libraryieee;useieee.std_logic_1164.all;entitymux21isport(a,b,s:instd_logic;y:outstd_logic);endmux21;architecturebhvofmux21isbeginy<=awhens='0'elseb;endbhv;(3)分频模块:不同脉冲信号,高音报时以及1HZ几秒脉冲等。设计分频器,VHDLlibraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityfenpisport(clk:instd_logic; hz512,hz64,hz4,hz1:outstd_logic);endfenp;architecturebhvoffenpissignalhz:std_logic_vector(9downto0);beginprocess(clk)beginif(clk'eventandclk='1')thenif(hz="1111111111")thenhz<="0000000000";elsehz<=hz+1;endif;endif;endprocess;hz512<=hz(0);hz64<=hz(3);hz4<=hz(7);hz1<=hz(9);endbhv;报时模块当计时达到59’50时开始报时,50,52,54,56,58时鸣叫;整点时报时频率与其不同,用分频器得以实现libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitybaoshiisport(m1,m0,s1,s0:instd_logic_vector(3downto0);clk_500,clk_1k:outstd_logic);endbaoshi;architecturebhvofbaoshiisbeginprocess(m0)beginclk_500<='0';clk_1k<='0';ifm1="0101"andm0="1001"then ifs1="0101"and(s0="0000"ors0="0010"ors0="0100"ors0="0110"ors0="1000")then clk_500<='1';elseclk_500<='0';endif;endif;ifm1="0000"andm0="0000"ands1="0000"ands0="0000"thenclk_1k<='1';elseclk_1k<='0';endif;endprocess;endbhv;m1,m0,s1,s0分别为分的十位,个位,秒的十位,个位;当达到59’50时开始报时,50s,52s,54s,56s,58s时鸣叫;整点时,即m1,m0,s1,s0均为0,整点报时生成器件如下图:————动态显示模块动态显示模块由六进制计数器,38译码器,六选一多路选择器和七段译码器组成。通过计数器计数,经过38译码器译码,从而得到地址值,在多路选择器上选取该地址所对应的数据,再经过七段译码器译码,从而显示选取的数值。六进制计数器文件名为count6VHDL语言如下:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycount6isport(clk:instd_logic;q:outstd_logic_vector(2downto0);co:outstd_logic);endcount6;architecturebhvofcount6issignalcq:std_logic_vector(2downto0);beginprocess(clk)beginif(clk'eventandclk='1')thenif(cq="101")thencq<="000";elsecq<=cq+1;endif;endif;q<=cq;endprocess;process(clk)beginif(clk'eventandclk='1')thenif(cq="101")thenco<='1';elseco<='0';endif;endif;endprocess;endbhv;说明:clk为时钟脉冲信号;cq为计数信号,当来一个时钟脉冲时即加1,当其为5时,在下一个时钟脉冲作用下变为0;q为cq的输出。生成器件如下图:2)38译码器文件名为yima38VHDL语言如下:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityyima38isport(a:instd_logic_vector(2downto0);y:outstd_logic_vector(5downto0));endyima38;architecturebhvofyima38isbeginprocess(a)begincaseaiswhen"000"=>y<="000001";when"001"=>y<="000010";when"010"=>y<="000100";when"011"=>y<="001000";when"100"=>y<="010000";when"101"=>y<="100000";whenothers=>y<="000000";endcase;endprocess;endbhv;说明:a为上面六进制计数的输出,通过38译码器对其进行译码,生成y。生成器件如下图:3)六选一多路选择器文件名为xuan6VHDL语言如下:libraryieee;useieee.std_logic_1164.all;entityxuan6isport(no1,no2,no3,no4,no5,no6:instd_logic_vector(3downto0);st:instd_logic_vector(5downto0);yout:outstd_logic_vector(3downto0);sel:outstd_logic_vector(5downto0));endxuan6;architecturebhvofxuan6issignals:std_logic_vector(5downto0);begins<=st;process(s)begincasesiswhen"100000"=>yout<=no6;sel<="100000";when"010000"=>yout<=no5;sel<="010000";when"001000"=>yout<=no4;sel<="001000";when"000100"=>yout<=no3;sel<="000100";when"000010"=>yout<=no2;sel<="000010";when"000001"=>yout<=no1;sel<="000001";whenothers=>yout<="1111";sel<="000000";endcase;endprocess;endbhv;说明:no1,no2,no3,no4,no5,no6为数据的输入;sel为选择数据输出的地址值;yout为数据的输出。生成器件如下图:4)七段译码器文件名为yima7VHDL语言如下:libraryieee;useieee.std_logic_1164.all;entityyima7isport(a:inbit_vector(3downto0);dataout:outbit_vector(6downto0));endyima7;architecturebhvofyima7isbeginprocess(a)begincaseaiswhen"0000"=>dataout<="1111110";when"0001"=>dataout<="0110000";when"0010"=>dataout<="1101101";when"0011"=>dataout<="1111001";when"0100"=>dataout<="0110011";when"0101"=>dataout<="1011011";when"0110"=>dataout<="1011111";when"0111"=>dataout<="1110000";when"1000"=>dataout<="1111111";when"1001"=>dataout<="1111011";whenothers=>dataout<="0000000";endcase;endprocess;endbhv;说明:a为输入的数据;dataout为数据的七段译码形式的输出。生成器件如下图:动态显示的连线图为:生成器件如下图(器件名为dx):————闹时模块由设置时间和比较闹时两部分组成。设置时间连线图如下:说明:通过sets,setm,seth设置闹铃时间;clk可接4hz的时钟脉冲,便于调整时间。生成器件如下图(名为set):比较闹时文件名为naoVHDL语言如下:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitynaoisport(clk,en:instd_logic;h1,h0,m1,m0,s1,s0:instd_logic_vector(3downto0);sh1,sh0,sm1,sm0,ss1,ss0:instd_logic_vector(3downto0);nao:OUTSTD_LOGIC;hour1,hour0,min1,min0,second1,second0:outstd_logic_vector(3downto0));endnao;architecturebhvofnaoisbeginprocess(clk)beginif(clk'eventandclk='1')thenifen='1'thenhour1<=sh1;hour0<=sh0;min1<=sm1;min0<=sm0;second1<=ss1;second0<=ss0;elsehour1<=h1;hour0<=h0;min1<=m1;min0<=m0;second1<=s1;second0<=s0;if(sh1=h

温馨提示

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

评论

0/150

提交评论