数字电路综合实验简易微波炉控制器分析解析_第1页
数字电路综合实验简易微波炉控制器分析解析_第2页
数字电路综合实验简易微波炉控制器分析解析_第3页
数字电路综合实验简易微波炉控制器分析解析_第4页
数字电路综合实验简易微波炉控制器分析解析_第5页
已阅读5页,还剩28页未读 继续免费阅读

下载本文档

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

文档简介

1、数 字 电 路 综 合 实 验姓名: XXX 班级: XXXX 学号: XXX 班内序号: XXX 1. 设计任务要求设计制作一个简易微波炉控制器。基本要求:1、 微波炉的火力有大、中、小三档可选。用一个按键实现火力的选择,用点阵显示火力档位,点阵的显示随着按键的按下次数而变化,没有选择时默认的火力为大。2、 微波加热时间在0-59分59秒之间可选。用4个按键分别设置加热时间各位的长度,用数码管显示加热时间。3、 设置一个开始键,按下此键后开始加热。加热过程中,用数码管倒计时显示剩余时间。4、 加热过程中,不能修改火力和加热时间。5、 加热完成后蜂鸣器至少鸣响两声以提醒使用者加热已结束,加热结

2、束后回到等待状态。6、 设置复位键,任何时候按下复位键可以取消加热,回到等待状态,只有在等待状态下才可以修改火力和加热时间。提高要求:1、 用8个LED灯作为加热进度显示条,随着加热时间的增加匀速增加点亮LED灯的个数,无论加热时间是多长,最后都必须将8个LED灯全部点亮。2、 增加烧烤功能,用一个键选择微波或烧烤功能,用一个数码管指示当前处于微波还是烧烤功能。3、 烧烤火力和加热时间要求与微波功能相同。4、 自拟其它功能。2系统设计2.1 设计思路看到实验设计要求后,首先确定了需要使用的硬件,如数码管、点阵、蜂鸣器、led灯和按键等。然后再分出模块来,一步一步将功能分解成小模块,更容易实现每

3、一步的功能,容易仿真,不容易出错,出错也好查。2.2 总体框图开始火力设置停止时间设置图1 硬件结构框图控制器分频模块进度条显示译码模块点阵火力显示时间显示火力设置时间设置初始化模块图2 模块划分控制器点阵火力显示扬声器进度条显示译码显示计时器分频器时钟开始复位设置图3 逻辑划分框图开始初始化设置加热时间,火力倒计时按下“开始”键?按下“复位”键?倒计时时间到?扬声器响两次是是是否否否图4 ASM图等待加热10010000图5 状态转移图2.3 分块设计这里只对其中几个模块进行说明,不说明的均是一些很简单的、显而易见的模块。2.3.1 初始化模块这是将整个电路的输入信号转化成适合程序处理和计算

4、的信号或变量,再输出到其他模块中进行计算。每当时钟检测到摸个信号变为高电平后,便对这个信号进行处理,比如输出信号自身加1,或置0。2.3.2 减计数计时模块由于在加热过程中,不允许设置时间和火力,所以对reset键进行了特别的设置。还有就是最核心的倒计时程序了。我分别检测秒、十秒、分、十分4位的剩余时间,进行减计数或借位等设置。当检测到4位的时间均为0时,倒计时结束。并输出一个结束信号,控制蜂鸣器报警(这部分在蜂鸣器模块详细说明)。2.3.3 点阵显示火力模块我用三色点阵显示火力,点阵左侧是火苗,火苗大小表示火力大小,右侧是一个火力条,火力条的高低表示火力大小。我设置里两个行向量分别控制红色和

5、绿色的led小灯亮暗,设置列向量进行列扫描,要亮起的一行置0,其余全部置1。效果很漂亮。2.3.4 数码管显示模块这模块主要是和数据选择模块一起用。根据书上数码管显示数字对应的高低电平设置好表格就好了,然后根据输入信号来选择需要显示的数字,根据已经写好的对应的高低电平,就可以正常显示了。2.3.5 蜂鸣器报警模块这个模块实现的功能虽然很简单,但是我却遇到了不少困难。首先遇到的困难是下载成功的同时蜂鸣器马上就报警,于是我在倒计时模块中加入了加热停止信号,在所有位都为0时,该信号置1。但是还不成功,蜂鸣器在我按下start键后就响起来了,并不是在计时结束才响,我就又加了一个输入信号,末位一定不总是

6、0才允许蜂鸣器报警。接下来又遇到了新的问题,就是蜂鸣器不是响3下就停止报警,而是一个周期一个周期重复这3下报警,我又加了报警检测信号,计算报警的6秒时间结束后,强制将蜂鸣器置0 。问题才解决。3. 仿真波形及波形分析3.1 初始化文件first图6 初始化文件仿真波形输入为时钟信号clk,时间设置信号s3s0,火力设置信号ffire。输出波形为时间计数信号o4o1和火力大小信号firest。3.2 减计数器倒计时模块 jianjishu图7 减计数器倒计时模块仿真波形输入为秒时钟信号clk,开始start,复位res,时间输入信号in4in1。输出信号为时间输出信号out4out1,蜂鸣器响起

7、信号light和两个倒计时结束信号c、d。3.3 点阵显示火力模块 fires图8 点阵显示火力模块仿真波形(三色小火)输入为时钟信号clk,复位res,火力大小信号firee。输出为行扫描信号r,红色灯列向量red,黄色led灯列向量yellow。如果将图顺时针旋转90°,则可以看出red和yellow信号成一个小火苗状,火苗左侧为矮的小火力显示条。图9 点阵显示火力模块仿真波形(三色中火)输入为时钟信号clk,复位res,火力大小信号firee。输出为行扫描信号r,红色灯列向量red,黄色led灯列向量yellow。如果将图顺时针旋转90°,则可以看出red和yello

8、w信号成一个小中苗状,火苗左侧为矮的中火力显示条。图10 点阵显示火力模块件仿真波形(三色大火)输入为时钟信号clk,复位res,火力大小信号firee。输出为行扫描信号r,红色灯列向量red,黄色led灯列向量yellow。如果将图顺时针旋转90°,则可以看出red和yellow信号成一个大火苗状,火苗左侧为矮的大力显示条。(注意红色red和黄色yellow重叠起来看!)3.4 进度条显示模块进度条图11 进度条显示模块件仿真波形输入为时钟信号clk,复位res,设置的加热时间i4i1,倒计时剩余时间c4c1。输出为8个led灯向量ledd。从图中可以看出,随着剩余时间的减少,8个

9、LED灯逐渐亮起。3.5 蜂鸣器报警模块 beep图12 蜂鸣器报警模块件仿真波形输入信号为clk时钟信号,十秒位归零但秒位不归零信号kzero,倒计时结束信号zero。当两个信号都被置1后,蜂鸣器报警3声,然后停止报警。4. 源程序4.1 顶层文件 toplibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity top isport(rest,clk1,miao0,miao1,fen0,fen1,startt,fire,st:in std_logic; lighto:out std_logi

10、c; row:out std_logic_vector(7 downto 0); sel:out std_logic_vector(5 downto 0); seg,redd,yel,led:out std_logic_vector(7 downto 0);end;architecture three of top iscomponent fenpin is port(clk:in std_logic; -分频 outclk,outclk2:out std_logic );end component;component first isport(clk,res,s0,s1,s2,s3,ffir

11、e:in std_logic; -初始化数据 o1,o2,o3,o4:out std_logic_vector(3 downto 0); firest:out std_logic_vector(1 downto 0);end component;component jianjishu isport(clks,start,res:in std_logic; in1,in2,in3,in4:in std_logic_vector(3 downto 0); -减计数 light,c,d:out std_logic; out1,out2,out3,out4:out std_logic_vector(3

12、 downto 0); end component;component choice isport(clk:std_logic; f1,f2,f3,f4,f5:in std_logic_vector(3 downto 0); o1:out std_logic_vector(2 downto 0); -位选 o2:out std_logic_vector(3 downto 0);end component;component view isport(-screen:in std_logic; f1:in std_logic_vector(2 downto 0); f2:in std_logic_

13、vector(3 downto 0); -显示输出 segout:out std_logic_vector(7 downto 0); selout:out std_logic_vector(5 downto 0);end component;component fires isport(res,clk:in std_logic; firee:in std_logic_vector(1 downto 0); red:out std_logic_vector(7 downto 0); yellow:out std_logic_vector(7 downto 0); r:out std_logic_

14、vector(7 downto 0);end component;component shaokao isport(clk,set:in std_logic;o2:out std_logic_vector(3 downto 0);end component;component beep isport(clks,zero,kzero:in std_logic; light:out std_logic);end component;component jindutiao isport(clk,res:in std_logic; i1,i2,i3,i4,c1,c2,c3,c4:in std_logi

15、c_vector(3 downto 0); ledd:out std_logic_vector(7 downto 0);end component;component doudong isport(clk,res,min10,min1,sec10,sec1,huo,moshi:in std_logic;resn,min10n,min1n,sec10n,sec1n,huon,moshin:out std_logic);end component;signal b,c,d,e,f,g,h,i,j,k:std_logic_vector(3 downto 0);signal a,pp,zc,rest1

16、1,min1011,min111,sec1011,sec111,huo11,moshi11,clk22:std_logic;signal q:std_logic_vector(2 downto 0);signal fir:std_logic_vector(1 downto 0);signal p:std_logic_vector(3 downto 0);beginu1: fenpin port map (clk=>clk1,outclk2=>clk22,outclk=>a);u2: first port map (clk=>clk1,res=>rest11,o1=

17、>b,o2=>c,o3=>d,o4=>e,s0=>sec111,s1=>sec1011,s2=>min111,s3=>min1011,ffire=>huo11,firest=>fir);u3:jianjishu port map (clks=>a,start=>startt,res=>rest,in1=>b,in2=>c,in3=>d,in4=>e,out1=>f,out2=>g,out3=>h,out4=>i,c=>zc,d=>pp);u4:choice

18、port map (clk=>clk22,f1=>f,f2=>g,f3=>h,f4=>i,f5=>k,o1=>q,o2=>p);u5:view port map (f1=>q,f2=>p,segout=>seg,selout=>sel);u6:fires port map (clk=>clk22,res=>rest11,firee=>fir,red=>redd,yellow=>yel,r=>row);u7:shaokao port map (clk=>clk1,set=>mo

19、shi11,o2=>k);u8:beep port map (clks=>a,zero=>zc,light=>lighto,kzero=>pp);u9:jindutiao port map(clk=>clk1,res=>rest,i1=>b,i2=>c,i3=>d,i4=>e,c1=>f,c2=>g,c3=>h,c4=>i,ledd=>led);u10:doudong port map(clk=>clk1,res=>rest,min10=>fen1,min1=>fen0,se

20、c10=>miao1,sec1=>miao0,huo=>fire,moshi=>st,resn=>rest11,min10n=>min1011,min1n=>min111,sec10n=>sec1011,sec1n=>sec111,huon=>huo11,moshin=>moshi11);end three;4.2 分频器 fenpinlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenpin is port(clk

21、:in std_logic; outclk,outclk2:out std_logic );end;architecture first of fenpin is signal Q1,Q2:std_logic; -signal Q2:std_logic; begin one:process(clk) variable count1:integer range 0 to 49999999; begin Q1<='0' if count1>49999999 then Q1<='1'count1:=0; elsif clk'event and

22、 clk='1' then count1:=count1+1; -分出1秒信号 end if; end process; two:process(clk) variable count2:integer range 0 to 2999; begin Q2<='0' if count2>2999 then Q2<='1'count2:=0; elsif clk'event and clk='1' then count2:=count2+1; -分出100Hz信号 end if; end process;ou

23、tclk<=Q1;outclk2<=Q2;end; 4.3 初始化模块 firstlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity first isport(clk,res,s0,s1,s2,s3,ffire:in std_logic; o1,o2,o3,o4:out std_logic_vector(3 downto 0); firest:out std_logic_vector(1 downto 0);end;architecture two of first issi

24、gnal q1,q2,q3,q4:std_logic_vector(3 downto 0);beginprocess(clk,res,q4)variable ss:std_logic_vector(3 downto 0);variable f:std_logic_vector(1 downto 0);beginif (clk'event and clk='1')then ss(0):=s0;ss(1):=s1;ss(2):=s2;ss(3):=s3;if res='1' then q1<="0000"q2<="0

25、000"q3<="0000"q4<="0000"firest<="10" -复位键elseif(ffire='1')thenif(f="10")then f:="00"else f:=f+'1'end if;end if;case ss iswhen "0001"=> if q1<9 then q1<=q1+1;else q1<="0000" -秒位加数end if;whe

26、n "0010"=> if q2<5 then q2<=q2+1;else q2<="0000" -十秒位加数 end if;when "0100"=> if q3<9 then q3<=q3+1;else q3<="0000" -分位加数end if;when "1000"=> if q4<5 then q4<=q4+1;else q4<="0000" -十分位加数end if;when others=

27、>null;end case;end if;end if;firest<=f;end process;o1<=q1;o2<=q2;o3<=q3;o4<=q4;end;4.4 减计数器计时模块 jianjishulibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jianjishu isport(clks,start,res:in std_logic; in1,in2,in3,in4:in std_logic_vector(3 downto 0); li

28、ght,c,d:out std_logic; out1,out2,out3,out4:out std_logic_vector(3 downto 0);end;architecture one of jianjishu issignal q1,q2,q3,q4:std_logic_vector(3 downto 0);beginprocess(start,clks,res,q4)variable a:std_logic_vector(1 downto 0);begin if res='1' then q1<=in1;q2<=in2;q3<=in3;q4<

29、=in4; -对信号都清零设置 elsif q4=(in4-15) or start='0' then light<='0' -当q4=15或start=0时不进行减计数,同时LED不亮 elsif start='1' then -当start=1时LED点亮同时开始倒计时if (clks'event and clks='1' )then if (in1-q1)=0 then q1<=(in1-9);q2<=q2+1;else q1<=q1+1;end if; -q1开始为0,当q1=in1时,对q

30、1赋值为(in1-9),为负数,-同时对q2进行加1,那么(in2-q2)就可以视线减1,若不是那么q1<=q1+1,可以实现-(in1-q1)从9开始的倒计数if (in2-q2)=0 and (in1-q1)=0 then q3<=q3+1;q2<=(in2-5);q1<=(in1-9);end if; -当输出out1=0和out2=0时进位减1,同时out1=9,out2=5;if (in3-q3)=0 and (in2-q2)=0 and (in1-q1)=0 then q4<=q4+1;q3<=(in3-9);q2<=(in2-5);q1&

31、lt;=(in1-9);d<='1'end if;if (in4-q4)=0 and (in3-q3)=0 and (in2-q2)=0 and (in1-q1)=0 thenq4<=in4;q3<=in3;q2<=in2;q1<=in1;c<='1' end if; -当所有计数完毕end if;end if;end process;out1<=(in1-q1);out2<=(in2-q2);out3<=(in3-q3);out4<=(in4-q4);end;4.5 数据选择器 choicelibra

32、ry ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity choice isport(clk:in std_logic; f1,f2,f3,f4,f5:in std_logic_vector(3 downto 0); o1:out std_logic_vector(2 downto 0); o2:out std_logic_vector(3 downto 0);end;architecture one of choice issignal q:std_logic_vector(2 downto 0);b

33、eginprocess(clk,q)beginif clk'event and clk='1' then q<=q+1;end if;case q iswhen "000" => o2<=f1; when "001" => o2<=f2;when "010" => o2<=f3; -选择输出数据when "011" => o2<=f4;when "100" => o2<=f5; when others=&g

34、t; null;end case;end process;o1<=q; -位选信号end;4.6 数码管显示模块 viewlibrary ieee;use ieee.std_logic_unsigned.all;entity view isport(-screen:in std_logic; f1:in std_logic_vector(2 downto 0); f2:in std_logic_vector(3 downto 0); segout:out std_logic_vector(7 downto 0); selout:out std_logic_vector(5 downto

35、0);end;architecture one of view issignal seg:std_logic_vector(6 downto 0);signal sel:std_logic_vector(5 downto 0);beginselout<=sel;segout(6 downto 0)<=seg;sel<="111110" when f1=0 else "111101" when f1=1 else "111011" when f1=2 else -相应的数据选择对应的位进行输出 "110111

36、" when f1=3 else "101111" when f1=4 else "111111"segout(7)<='1' when f1=2 else '0' -在第三个数码管输出小数点process(f2,sel)begincase f2 iswhen "0000" => seg<="0111111"when "0001" => seg<="0000110"when "0010"

37、; => seg<="1011011"when "0011" => seg<="1001111"when "0100" => seg<="1100110"when "0101" => seg<="1101101"when "0110" => seg<="1111101"when "0111" => seg<="000

38、0111"when "1000" => seg<="1111111"when "1001" => seg<="1101111"when "1010" => seg<="1011000"when "1011" => seg<="1001100"when others=>null;end case;end process;end;4.7 点阵显示火力library ieee;u

39、se ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fires isport(res,clk:in std_logic; firee:in std_logic_vector(1 downto 0); red:out std_logic_vector(7 downto 0); yellow:out std_logic_vector(7 downto 0); r:out std_logic_vector(7 downto 0);end fires;architecture a of fires issignal d0,

40、d1,d2,d3,d4,d5,d6,d7:std_logic_vector(7 downto 0);signal c0,c1,c2,c3,c4,c5,c6,c7:std_logic_vector(7 downto 0);signal rv:std_logic_vector(3 downto 0);begin-red-d0<=X"00"when firee="10"else -hig power -1X"00"when firee="01"else -mid power -1X"00"whe

41、n firee="00"else -low power -1X"00"d1<=X"00"when firee="10"else -hig power -2X"00"when firee="01"else -mid power -2X"00"when firee="00"else -low power -2X"00" d2<=X"20"when firee="10"e

42、lse -hig power -3X"00"when firee="01"else -mid power -3X"00"when firee="00"else -low power -3X"00" d3<=X"77"when firee="10"else -hig power -4X"07"when firee="01"else -mid power -4X"00"when firee=&q

43、uot;00"else -low power -4X"00" d4<=X"77"when firee="10"else -hig power -5X"27"when firee="01"else -mid power -5X"00"when firee="00"else -low power -5X"00" d5<=X"fb"when firee="10"else -hig

44、power -6X"73"when firee="01"else -mid power -6X"20"when firee="00"else -low power -6X"00" d6<=X"db"when firee="10"else -hig power -7X"fb"when firee="01"else -mid power -7X"73"when firee="00&qu

45、ot;else -low power -7X"00" d7<=X"51"when firee="10"else -hig power -8X"71"when firee="01"else -mid power -8X"71"when firee="00"else -low power -8X"00" -yellow-c0<=X"0f"when firee="10"else -hig p

46、ower -1X"00"when firee="01"else -mid power -1X"00"when firee="00"else -low power -1X"00" c1<=X"0f"when firee="10"else -hig power -2X"00"when firee="01"else -mid power -2X"00"when firee="00&quo

47、t;else -low power -2X"00" c2<=X"07"when firee="10"else -hig power -3X"00"when firee="01"else -mid power -3X"00"when firee="00"else -low power -3X"00" c3<=X"07"when firee="10"else -hig power -4X&

48、quot;07"when firee="01"else -mid power -4X"00"when firee="00"else -low power -4X"00" c4<=X"27"when firee="10"else -hig power -5X"07"when firee="01"else -mid power -5X"00"when firee="00"else -l

49、ow power -5X"00" c5<=X"73"when firee="10"else -hig power -6X"03"when firee="01"else -mid power -6X"00"when firee="00"else -low power -6X"00" c6<=X"70"when firee="10"else -hig power -7X"20&q

50、uot;when firee="01"else -mid power -7X"00"when firee="00"else -low power -7X"00" c7<=X"20"when firee="10"else -hig power -8X"20"when firee="01"else -mid power -8X"20"when firee="00"else -low power

51、-8X"00" process (clk,res)beginif(res='1') thenred<=X"00"yellow<=X"00"rv<="1000"elsif(clk'event and clk='1')thenif(rv="0111")thenrv<="0000"elserv<=rv+'1'end if; case rv is when "0000"=>

52、red<=d0;yellow<=c0; r<="11111110" -当扫描第1列时,送第1行像素信息 when "0001"=>red<=d1;yellow<=c1; r<="11111101" -当扫描第2列时,送第2行像素信息 when "0010"=>red<=d2;yellow<=c2; r<="11111011" -当扫描第3列时,送第3行像素信息 when "0011"=>red<=d

53、3;yellow<=c3; r<="11110111" -当扫描第4列时,送第4行像素信息 when "0100"=>red<=d4;yellow<=c4; r<="11101111" -当扫描第5列时,送第5行像素信息 when "0101"=>red<=d5;yellow<=c5; r<="11011111" -当扫描第6列时,送第6行像素信息 when "0110"=>red<=d6;yellow&

54、lt;=c6; r<="10111111" -当扫描第7列时,送第7行像素信息 when "0111"=>red<=d7;yellow<=c7; r<="01111111" -当扫描第8列时,送第8行像素信息 when "1000"=>red<=X"ff"yellow<=X"ff" r<="11111111" -当扫描第8列时,送第8行像素信息 when others=>null; end cas

55、e;end if;end process;end a; 4.8 切换微波/烧烤模式模块 shaokaolibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity shaokao isport(clk,set:in std_logic; o2:out std_logic_vector(3 downto 0);end;architecture a of shaokao issignal q:integer range 0 to 1;beginprocess(clk,set)beginif clk&#

56、39;event and clk='1' thenif set='0' then q<=0;else q<=q+1;case q iswhen 0 =>o2<="1010"when 1 =>o2<="1011"when others =>null;end case;end if;end if;end process;end a;4.9 蜂鸣器报警模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigne

57、d.all;entity beep isport(clks,zero,kzero:in std_logic; light:out std_logic);end;architecture one of beep issignal p :std_logic_vector(5 downto 0);signal b,c:integer:=5;beginp<="101011"process(clks,zero,kzero)zsbeginif clks' event and clks='1' thenif zero='1' then if

58、kzero='1' thenif c>0 and b>0 then light<=p(b);b<=b-1;c<=c-1;elsif c=0 then light<='0'else b<=5;light<='0'end if;else light<='0'end if;else light<='0'c<=5;end if;end if;end process;end one ;4.10 进度条模块 jindutiaolibrary ieee;use ieee.std_logic_1

温馨提示

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

评论

0/150

提交评论