多功能数字钟电路设计

多功能数字钟电路设计,第1张

数字钟的VHDL设计

1、设计任务及要求:

设计任务:设计一台能显示时、分、秒的数字钟。具体要求如下:

由实验箱上的时钟信号经分频产生秒脉冲;

计时计数器用24进制计时电路;

可手动校时,能分别进行时、分的校正;

整点报时;

2 程序代码及相应波形

Second1(秒计数 6进制和10进制)

Library ieee;

Use ieeestd_logic_1164all;

Use ieeestd_logic_unsignedall;

Entity second1 is

Port( clks,clr:in std_logic;

Secs,Secg: out std_logic_vector(3 downto 0);

cout1:out std_logic);

End second1;

Architecture a of second1 is

Begin

Process(clks,clr)

variable ss,sg: std_logic_vector(3 downto 0);

variable co: std_logic;

Begin

If clr='1' then ss:="0000"; sg:="0000";

Elsif clks'event and clks='1' then

if ss="0101" and sg="1001" then ss:="0000"; sg:="0000";co:='1';

elsif sg<"1001" then sg:=sg+1;co:='0';

elsif sg="1001" then sg:="0000";ss:=ss+1;co:='0';

end if;

end if;

cout1<=co;

Secs<=ss;

Secg<=sg;

end process;

End a;

Min1(分计数器 6进制和10进制 alm实现整点报时)

Library ieee;

Use ieeestd_logic_1164all;

Use ieeestd_logic_unsignedall;

Entity min1 is

Port(clkm,clr:in std_logic;

mins,ming:buffer std_logic_vector(3 downto 0);

enmin,alarm: out std_logic);

End;

Architecture a of min1 is

Begin

Process(clkm,clr)

variable ms,mg :std_logic_vector(3 downto 0);

variable so,alm :std_logic;

Begin

If clr='1' then ms:="0000"; mg:="0000";

Elsif clkm'event and clkm='1' then

if ms="0101" and mg="1001" then ms:="0000";mg:="0000"; so :='1'; alm:='1';

elsif mg<"1001" then mg:=mg+1; so :='0';alm:='0';

elsif mg="1001" then mg:="0000";ms:=ms+1; so :='0';alm:='0';

end if;

end if;

alarm<=alm;

enmin<= so;

mins<=ms;

ming<=mg;

End process;

End a;

Hour1(时计数器 4进制与2进制)

Library ieee;

Use ieeestd_logic_1164all;

Use ieeestd_logic_unsignedall;

Entity hour1 is

Port(clkh,clr:in std_logic;

hours,hourg:out std_logic_vector(3 downto 0));

End;

Architecture a of hour1 is

Begin

Process(clkh,clr)

variable hs,hg :std_logic_vector(3 downto 0);

Begin

If clr='1' then hs:="0000"; hg:="0000";

Elsif clkh'event and clkh='1' then

if hs="0010"and hg="0011" then hs:="0000";hg:="0000";

elsif hg<"1001" then hg:=hg+1;

elsif hg="1001" then hg:="0000";hs:=hs+1; end if;

end if;

hours<=hs;

hourg<=hg;

End process;

End;

Madapt(校分)

Library ieee;

Use ieeestd_logic_1164all;

Use ieeestd_logic_unsignedall;

Entity madapt is

Port(en,clk,secin,m1:in std_logic;

minset:out std_logic);

End;

Architecture a of madapt is

Begin

Process(en,m1)

Begin

if en='1' then

if m1='1' then minset<=clk;

else minset<=secin; end if;

else minset<=secin ;

end if;

End process;

end;

Hadapt (校时)

Library ieee;

Use ieeestd_logic_1164all;

Use ieeestd_logic_unsignedall;

Entity hadapt is

Port(en,clk,minin,h1:in std_logic;

hourset:out std_logic);

End;

Architecture a of hadapt is

Begin

Process(en,h1)

Begin

if en='1' then

if h1='1' then hourset<=clk;

else hourset<=minin; end if;

else hourset<=minin;

end if;

End process;

end;

Topclock(元件例化 顶层文件)

Library ieee;

Use ieeestd_logic_1164all;

Use ieeestd_logic_arithall;

Use ieeestd_logic_unsignedall;

Entity topclock is

Port(clk,clr,en,m1,h1:in std_logic;

alarm:out std_logic;

secs,secg,mins,ming,hours,hourg:buffer std_logic_vector(3 downto 0));

End;

Architecture one of topclock is

Component second1

Port( clks,clr:in std_logic;

secs,secg: buffer std_logic_vector(3 downto 0);

cout1: out std_logic);

End Component;

Component min1

Port(clkm,clr:in std_logic;

mins,ming:buffer std_logic_vector(3 downto 0);

enmin,alarm: out std_logic);

End Component;

Component hour1

Port(clkh,clr:in std_logic;

hours,hourg:buffer std_logic_vector(3 downto 0));

End Component;

Component madapt

Port(en,m1,clk,secin:in std_logic;

minset:out std_logic);

End Component;

Component hadapt

Port(en,h1,clk,minin:in std_logic;

hourset:out std_logic);

End Component;

signal a,b,c,d: std_logic;

begin

u1:second1 port map(clr=>clr,

secs=>secs,secg=>secg,clks=>clk, cout1=>a);

u2:min1 port map(clr=>clr,alarm=>alarm,

mins=>mins,ming=>ming,clkm=>b,enmin=>c);

u3:hour1 port map(clr=>clr,

hours=>hours,hourg=>hourg,clkh=>d);

u4:madapt port map(en=>en,m1=>m1,clk=>clk,secin=>a,minset=>b);

u5:hadapt port map(en=>en,h1=>h1,clk=>clk,minin=>c,hourset=>d);

end;

3 电路图

4 实验心得

程序全部都给你写好了啊,只 要你自己仿真,再下载到实验箱就OK了啦

设计原理

计数时钟由模为60的秒计数器模块、模为60的分计数模块、模为24的小时计数器模块、指示灯与报警器的模块、分/小时设定模块及输出显示模块等组成。秒计数器模块的进位输出为分计数器模块的进位输入,分计数器模块的进位输出为小时计数器模块的进位输入。其中秒计数器模块中应有分钟的设定,分计数器模块中应有小时的设定。

内容

设计一个计数时钟,使其具有24小时计数功能。通过“多功能复用按键F1-F12”信号接线组“F1_12(T)”的F9~F12的任意引线插孔可设置小时和分钟的值,并具有整点报时的功能。

电路原理图

模块说明:计数时钟由60秒计数器模块XSECOND、60分计数器模块XMINUTE、24小时计数器模块XHOUR等六个模块构成。秒计数器模块的进位输出为分计数器模块的进位输入,分计数器模块中有小时的设定。通过SW1、SW2、SW3、SW4可设定小时和分钟的值,并具有整点报时的功能。

输入信号:SETMIN为分钟设置信号;SETHOUR为小时设置信号;RESET为全局复位信号;CLK为全局时钟信号;CKDSP为数码管动态扫描信号。

输出信号:SPEAK为蜂鸣器报时信号;LAMP[20]为指示灯信号;A~G为数码管七个段位信号;SS[20]为数码管段位译码控制信号。

说明与电路连线

指示灯信号LAMP2~LAMP0为独立扩展下载板上CPLD器件的第11、10、9脚,内部已连接并已锁定,无需外接连线。

蜂鸣器报时信号SPEAK为独立扩展下载板CPLD器件的第31脚,内部已连接并已锁定,无需外接连线。

拨码开关SW1~SW7内部已连接并已锁定,无需外接连线。

数码管七个段位信号A~G为独立扩展下载板上CPLD器件的第86、87、88、89、90、92、93脚,应接数码管段位引线接线组KPL_AH,从左到右依次对应的A、B、C、D、E、F、G引线插孔。

数码管段位译码控制信号SS0、SS1、SS2为独立扩展下载板上CPLD器件的第68、69、70脚,为数码管的位选扫描信号,分别接信号接线组DS1-8A(T)的SS0、SS1、SS2引线插孔(即在电源引线插孔组GND孔处)。

复位信号RESET为独立扩展下载板上CPLD器件的第71脚,应接“多功能复用按键F1-F12”信号接线组“F1_12(T)”的F9~F12的任意一个插孔。

小时设置信号SETHOUR为独立扩展下载板CPLD器件的第73脚,应接“多功能复用按键F1-F12”信号接线组“F1_12(T)”的F9~F12的任意一个插孔。

分钟设置信号SETMIN为独立扩展下载板上CPLD器件的第74脚,应接“多功能复用按键F1-F12”信号接线组“F1_12(T)”的F9~F12的任意一个插孔。

时钟信号CLK为独立扩展下载板上CPLD器件的183脚(即GCLK2),应接时钟信号接线组“CLOCK(T)”的“FRQ(21)”引线插孔。

数码管动态扫描信号CKDSP为独立扩展下载板上CPLD器件的79脚(即GCLK1),应接时钟信号接线组“CLOCK(T)”的“FRQ(11)”引线插孔。

参考源程序

library IEEE;

use IEEEstd_logic_1164all;

use ieeestd_logic_unsignedall;

use ieeestd_logic_arithall;

entity xsecond is

port (

clk: in STD_LOGIC;

clkset: in STD_LOGIC;

setmin: in STD_LOGIC;

reset: in STD_LOGIC;

secout: out STD_LOGIC_VECTOR (6 downto 0);

enmin: out STD_LOGIC

);

end xsecond;

architecture xsecond_arch of xsecond is

signal sec : std_logic_vector(6 downto 0);

signal emin : std_logic;

signal sec1 : std_logic;

begin

-- <<enter your statements here>>

process(reset,sec,emin,setmin,clkset)

begin

if reset='0' then

enmin<='0';

secout<="0000000";

sec1<='1';

else

sec1<='0';

secout<=sec;

if clkset='1' and clkset'event then

if setmin='0' then

enmin<='1';

else

enmin<=emin;

end if;

end if;

end if;

end process;

process(clk,sec1)

alias lcount : std_logic_vector(3 downto 0) is sec(3 downto 0);

alias hcount : std_logic_vector(2 downto 0) is sec(6 downto 4);

begin

if sec1='1' then

sec<="0000000";

else

if (clk='1' and clk'event) then

if lcount=9 then

lcount<="0000";

if hcount/=5 then

hcount<=hcount+1;

emin<='0';

else

hcount<="000";

emin<='1';

end if;

else

lcount<=lcount+1;

emin<='0';

end if;

end if;

end if;

end process;

end xsecond_arch;

library IEEE;

use IEEEstd_logic_1164all;

use ieeestd_logic_unsignedall;

use ieeestd_logic_arithall;

entity xminute is

port (

clkmin: in STD_LOGIC;

reset: in STD_LOGIC;

sethour: in STD_LOGIC;

clk: in STD_LOGIC;

minout: out STD_LOGIC_VECTOR (6 downto 0);

enhour: out STD_LOGIC

);

end xminute;

architecture xminute_arch of xminute is

signal min : std_logic_vector(6 downto 0);

signal ehour : std_logic;

signal min1 : std_logic;

begin

-- <<enter your statements here>>

process(reset,clk,sethour,min,ehour)

begin

if reset='0' then

enhour<='0';

minout<="0000000";

min1<='0';

else

min1<='1';

minout<=min;

if clk='1' and clk'event then

if sethour='0' then

enhour<='1';

else

enhour<=ehour;

end if;

end if;

end if;

end process;

process(clkmin,min1)

alias lcountm : std_logic_vector(3 downto 0) is min(3 downto 0);

alias hcountm : std_logic_vector(2 downto 0) is min(6 downto 4);

begin

if min1='0' then

min<="0000000";

else

if (clkmin='1' and clkmin'event) then

if lcountm=9 then

lcountm<="0000";

if hcountm/=5 then

hcountm<=hcountm+1;

ehour<='0';

else

hcountm<="000";

ehour<='1';

end if;

else

lcountm<=lcountm+1;

ehour<='0';

end if;

end if;

end if;

end process;

end xminute_arch;

library IEEE;

use IEEEstd_logic_1164all;

use ieeestd_logic_unsignedall;

use ieeestd_logic_arithall;

entity xhour is

port (

clkhour: in STD_LOGIC;

reset: in STD_LOGIC;

hourout: out STD_LOGIC_VECTOR (5 downto 0)

);

end xhour;

architecture xhour_arch of xhour is

signal hour : std_logic_vector(5 downto 0);

begin

-- <<enter your statements here>>

process(reset,clkhour,hour)

alias lcount : std_logic_vector(3 downto 0) is hour(3 downto 0);

alias hcount : std_logic_vector(1 downto 0) is hour(5 downto 4);

begin

if reset='0' then

hourout<="000000";

hour<="000000";

else

if (clkhour='1' and clkhour'event) then

if lcount=9 then

lcount<="0000";

hcount<=hcount+1;

else

if hour="100011" then

hour<="000000";

else

lcount<=lcount+1;

end if;

end if;

end if;

hourout<=hour;

end if;

end process;

end xhour_arch;

library IEEE;

use IEEEstd_logic_1164all;

use ieeestd_logic_unsignedall;

use ieeestd_logic_arithall;

entity xalert is

port (

clk: in STD_LOGIC;

d_in: in STD_LOGIC_VECTOR (6 downto 0);

speak: out STD_LOGIC;

d_out: out STD_LOGIC_VECTOR (2 downto 0)

);

end xalert;

architecture xalert_arch of xalert is

type state is (s1,s2,s3,s4);

signal next_state,current_state : state;

begin

-- <<enter your statements here>>

process(clk,current_state,d_in)

begin

if d_in/="0000000" then

speak<='0';

next_state<=s1;

current_state<=s1;

d_out<="000";

else

if clk='1' and clk'event then

speak<='1';

current_state<=next_state;

end if;

case current_state is

when s1 =>

d_out<="000";

next_state<=s2;

when s2 =>

d_out<="001";

next_state<=s3;

when s3 =>

d_out<="010";

next_state<=s4;

when s4 =>

d_out<="100";

next_state<=s1;

when others =>

d_out<="000";

null;

end case;

end if;

end process;

end xalert_arch;

library IEEE;

use IEEEstd_logic_1164all;

use ieeestd_logic_unsignedall;

use ieeestd_logic_arithall;

entity xsettime is

port (

hour: in STD_LOGIC_VECTOR (5 downto 0);

min: in STD_LOGIC_VECTOR (6 downto 0);

sec: in STD_LOGIC_VECTOR (6 downto 0);

reset: in STD_LOGIC;

clk: in STD_LOGIC;

sel: out STD_LOGIC_VECTOR (2 downto 0);

d_out: out STD_LOGIC_VECTOR (3 downto 0)

);

end xsettime;

architecture xsettime_arch of xsettime is

signal sel1 : std_logic_vector(2 downto 0);

begin

-- <<enter your statements here>>

process(clk,reset,sel1,hour,min,sec)

begin

if reset='0' then

sel<="000";

d_out<="0000";

sel1<="000";

else

if (clk='1' and clk'event) then

if sel1<5 then

sel1<=sel1+1;

else

sel1<="000";

end if;

end if;

sel<=sel1;

case sel1 is

when "000" =>

d_out(3)<='0';

d_out(2)<='0';

d_out(1)<=hour(5);

d_out(0)<=hour(4);

when "001" =>

d_out<=hour(3 downto 0);

when "010" =>

d_out(3)<='0';

d_out(2)<=min(6);

d_out(1)<=min(5);

d_out(0)<=min(4);

when "011" =>

d_out<=min(3 downto 0);

when "100" =>

d_out(3)<='0';

d_out(2)<=sec(6);

d_out(1)<=sec(5);

d_out(0)<=sec(4);

when "101" =>

d_out<=sec(3 downto 0);

when others =>

null;

end case;

end if;

end process;

end xsettime_arch;

library IEEE;

use IEEEstd_logic_1164all;

entity xdeled is

port (

d_in: in STD_LOGIC_VECTOR (3 downto 0);

a: out STD_LOGIC;

b: out STD_LOGIC;

c: out STD_LOGIC;

d: out STD_LOGIC;

e: out STD_LOGIC;

f: out STD_LOGIC;

g: out STD_LOGIC

);

end xdeled;

才五分啊,太少了吧

此电子报警器,是在TND-MD教学系统上实现的。所使用的芯片主要有8253定时计数器、8255A并行接口电路芯片。通过系统通过按动键盘某一键使得内扬声器发出警报声,使得8个LED指示灯忽明忽暗,并通过液晶显示器显示相关警报信息。

一、 设计要求

设想制作一个防盗器件。具体要求:按动键盘某任一数字键使得内扬声器发出警报声,使得

8个LED指示灯忽明忽暗,并通过液晶显示器显示相关警报信息。程序运行后,触动键盘上的数字键,8个LED不停光闪,光闪周期为2秒,同时在液晶显示器上显示相应的警报信息;程序按CTRL+C推出后声不响光不闪。

二、设计思想

根据设计任务和要求,在设计前必须对微机原理与接口技术中的8255和8253芯片熟悉了解和掌握。设计中主要要完成的是发声报警和发光报警这两个部分功能,故在程序设计中只要设计触动键盘重的数字键即8个LED不停光闪,同时内扬声器发出警报声,且在屏幕上显示警报信息。在设计发声报警时利用了8253可编程定时定时记数器。在设计发光报警时利用了8255芯片。在程序设计中利用INT 10H实现在屏幕上显示相关的警报信息

三、教学实验系统连线

用8253的CLK2端口与系统总线的OPCLK相连

用8253的OUT2输出端口与内置扬声器SPK端口相连

用8255的A端口的8个引脚与8LED灯相连

四:所用芯片工作原理

INTER 8253是可编程间隔定时器,同样也可以用作事件计数器。每个8253芯片有3个独立的16位计数器通道,每个计数器有6种工作方式,都可以按二进制或十进制计数。

要程序,原理图回话!~

题目:单片机电子时钟的设计与实现

课程设计的目的和意义

课程设计的目的与意义在于让我们将理论与实践相结合。培养我们综合运用电子课程中的理论知识解决实际性问题的能力。让我们对电子电路、电子元器件、印制电路板等方面的知识进一步加深认识,同时在软件编程、排错调试、焊接技术、相关仪器设备的使用技能等方面得到较全面的锻炼和提高,为今后能够独立完成某些单片机应用系统的开发和设计打下一个坚实的基础。

课程设计的基本任务

利用89S51单片机最小系统,综合应用单片机定时器、中断、数码显示、键盘输入、蜂鸣报警等知识,设计一款单片机和简单外设控制的电子时钟。

主要功能要求

最基本要求

1)使用6位数码管,前两位显示小时(24小时制),中间两位显示分钟,后两位显示秒。时钟每走1秒,秒数码管加1显示,60秒后分钟数码管加1显示,60分钟后小时数码管加1显示。

2)设计89S51单片机最小系统

3)掌握使用Protel99 绘制原理图和布板的过程、方法和技巧。

4)掌握单片机开发软件(Keil C51或 Wave)的使用和调试。

5)编写并调试单片机定时及其中断程序,以实现电子时钟的功能。

6)设计八段数码管显示电路并编写驱动程序,输入并调试拆字程序和数码显示程序。

7)掌握硬件和软件联合调试的方法。

8)完成系统硬件电路的设计和制作。

9)完成系统程序的设计。

10)完成整个系统的设计、调试和制作。

11)完成课程设计报告。

以上就是关于多功能数字钟电路设计全部的内容,包括:多功能数字钟电路设计、数字电子时钟、利用8253定时器的0通道设计一个具有时、分、秒显示的电子时钟等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9313128.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存