




已閱讀5頁,還剩31頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
數(shù)字電路綜合實驗簡易微波爐控制器數(shù) 字 電 路 綜 合 實 驗姓名: XXX 班級: XXXX 學(xué)號: XXX 班內(nèi)序號: XXX 1. 設(shè)計任務(wù)要求設(shè)計制作一個簡易微波爐控制器?;疽螅?、 微波爐的火力有大、中、小三檔可選。用一個按鍵實現(xiàn)火力的選擇,用點陣顯示火力檔位,點陣的顯示隨著按鍵的按下次數(shù)而變化,沒有選擇時默認的火力為大。2、 微波加熱時間在0-59分59秒之間可選。用4個按鍵分別設(shè)置加熱時間各位的長度,用數(shù)碼管顯示加熱時間。3、 設(shè)置一個開始鍵,按下此鍵后開始加熱。加熱過程中,用數(shù)碼管倒計時顯示剩余時間。4、 加熱過程中,不能修改火力和加熱時間。5、 加熱完成后蜂鳴器至少鳴響兩聲以提醒使用者加熱已結(jié)束,加熱結(jié)束后回到等待狀態(tài)。6、 設(shè)置復(fù)位鍵,任何時候按下復(fù)位鍵可以取消加熱,回到等待狀態(tài),只有在等待狀態(tài)下才可以修改火力和加熱時間。提高要求:1、 用8個LED燈作為加熱進度顯示條,隨著加熱時間的增加勻速增加點亮LED燈的個數(shù),無論加熱時間是多長,最后都必須將8個LED燈全部點亮。2、 增加燒烤功能,用一個鍵選擇微波或燒烤功能,用一個數(shù)碼管指示當前處于微波還是燒烤功能。3、 燒烤火力和加熱時間要求與微波功能相同。4、 自擬其它功能。2系統(tǒng)設(shè)計2.1 設(shè)計思路看到實驗設(shè)計要求后,首先確定了需要使用的硬件,如數(shù)碼管、點陣、蜂鳴器、led燈和按鍵等。然后再分出模塊來,一步一步將功能分解成小模塊,更容易實現(xiàn)每一步的功能,容易仿真,不容易出錯,出錯也好查。2.2 總體框圖開始火力設(shè)置停止時間設(shè)置圖1 硬件結(jié)構(gòu)框圖控制器分頻模塊進度條顯示譯碼模塊點陣火力顯示時間顯示火力設(shè)置時間設(shè)置初始化模塊圖2 模塊劃分控制器點陣火力顯示揚聲器進度條顯示譯碼顯示計時器分頻器時鐘開始復(fù)位設(shè)置圖3 邏輯劃分框圖開始初始化設(shè)置加熱時間,火力倒計時按下“開始”鍵?按下“復(fù)位”鍵?倒計時時間到?揚聲器響兩次是是是否否否圖4 ASM圖等待加熱10010000圖5 狀態(tài)轉(zhuǎn)移圖2.3 分塊設(shè)計這里只對其中幾個模塊進行說明,不說明的均是一些很簡單的、顯而易見的模塊。2.3.1 初始化模塊這是將整個電路的輸入信號轉(zhuǎn)化成適合程序處理和計算的信號或變量,再輸出到其他模塊中進行計算。每當時鐘檢測到摸個信號變?yōu)楦唠娖胶?,便對這個信號進行處理,比如輸出信號自身加1,或置0。2.3.2 減計數(shù)計時模塊由于在加熱過程中,不允許設(shè)置時間和火力,所以對reset鍵進行了特別的設(shè)置。還有就是最核心的倒計時程序了。我分別檢測秒、十秒、分、十分4位的剩余時間,進行減計數(shù)或借位等設(shè)置。當檢測到4位的時間均為0時,倒計時結(jié)束。并輸出一個結(jié)束信號,控制蜂鳴器報警(這部分在蜂鳴器模塊詳細說明)。2.3.3 點陣顯示火力模塊我用三色點陣顯示火力,點陣左側(cè)是火苗,火苗大小表示火力大小,右側(cè)是一個火力條,火力條的高低表示火力大小。我設(shè)置里兩個行向量分別控制紅色和綠色的led小燈亮暗,設(shè)置列向量進行列掃描,要亮起的一行置0,其余全部置1。效果很漂亮。2.3.4 數(shù)碼管顯示模塊這模塊主要是和數(shù)據(jù)選擇模塊一起用。根據(jù)書上數(shù)碼管顯示數(shù)字對應(yīng)的高低電平設(shè)置好表格就好了,然后根據(jù)輸入信號來選擇需要顯示的數(shù)字,根據(jù)已經(jīng)寫好的對應(yīng)的高低電平,就可以正常顯示了。2.3.5 蜂鳴器報警模塊這個模塊實現(xiàn)的功能雖然很簡單,但是我卻遇到了不少困難。首先遇到的困難是下載成功的同時蜂鳴器馬上就報警,于是我在倒計時模塊中加入了加熱停止信號,在所有位都為0時,該信號置1。但是還不成功,蜂鳴器在我按下start鍵后就響起來了,并不是在計時結(jié)束才響,我就又加了一個輸入信號,末位一定不總是0才允許蜂鳴器報警。接下來又遇到了新的問題,就是蜂鳴器不是響3下就停止報警,而是一個周期一個周期重復(fù)這3下報警,我又加了報警檢測信號,計算報警的6秒時間結(jié)束后,強制將蜂鳴器置0 。問題才解決。3. 仿真波形及波形分析3.1 初始化文件first圖6 初始化文件仿真波形輸入為時鐘信號clk,時間設(shè)置信號s3s0,火力設(shè)置信號ffire。輸出波形為時間計數(shù)信號o4o1和火力大小信號firest。3.2 減計數(shù)器倒計時模塊 jianjishu圖7 減計數(shù)器倒計時模塊仿真波形輸入為秒時鐘信號clk,開始start,復(fù)位res,時間輸入信號in4in1。輸出信號為時間輸出信號out4out1,蜂鳴器響起信號light和兩個倒計時結(jié)束信號c、d。3.3 點陣顯示火力模塊 fires圖8 點陣顯示火力模塊仿真波形(三色小火)輸入為時鐘信號clk,復(fù)位res,火力大小信號firee。輸出為行掃描信號r,紅色燈列向量red,黃色led燈列向量yellow。如果將圖順時針旋轉(zhuǎn)90,則可以看出red和yellow信號成一個小火苗狀,火苗左側(cè)為矮的小火力顯示條。圖9 點陣顯示火力模塊仿真波形(三色中火)輸入為時鐘信號clk,復(fù)位res,火力大小信號firee。輸出為行掃描信號r,紅色燈列向量red,黃色led燈列向量yellow。如果將圖順時針旋轉(zhuǎn)90,則可以看出red和yellow信號成一個小中苗狀,火苗左側(cè)為矮的中火力顯示條。圖10 點陣顯示火力模塊件仿真波形(三色大火)輸入為時鐘信號clk,復(fù)位res,火力大小信號firee。輸出為行掃描信號r,紅色燈列向量red,黃色led燈列向量yellow。如果將圖順時針旋轉(zhuǎn)90,則可以看出red和yellow信號成一個大火苗狀,火苗左側(cè)為矮的大力顯示條。(注意紅色red和黃色yellow重疊起來看?。?.4 進度條顯示模塊進度條圖11 進度條顯示模塊件仿真波形輸入為時鐘信號clk,復(fù)位res,設(shè)置的加熱時間i4i1,倒計時剩余時間c4c1。輸出為8個led燈向量ledd。從圖中可以看出,隨著剩余時間的減少,8個LED燈逐漸亮起。3.5 蜂鳴器報警模塊 beep圖12 蜂鳴器報警模塊件仿真波形輸入信號為clk時鐘信號,十秒位歸零但秒位不歸零信號kzero,倒計時結(jié)束信號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_logic; 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,ffire:in std_logic; -初始化數(shù)據(jù) 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); -減計數(shù) light,c,d:out std_logic; out1,out2,out3,out4:out std_logic_vector(3 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_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_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_logic_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,rest11,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=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 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=moshi11,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,sec10=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: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 Q149999999 then Q1=1;count1:=0; elsif clkevent and clk=1 then count1:=count1+1; -分出1秒信號 end if; end process; two:process(clk) variable count2:integer range 0 to 2999; begin Q22999 then Q2=1;count2:=0; elsif clkevent and clk=1 then count2:=count2+1; -分出100Hz信號 end if; end process;outclk=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 issignal 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 (clkevent and clk=1)then ss(0):=s0;ss(1):=s1;ss(2):=s2;ss(3):=s3;if res=1 then q1=0000;q2=0000;q3=0000;q4=0000;firest if q19 then q1=q1+1;else q1 if q25 then q2=q2+1;else q2 if q39 then q3=q3+1;else q3 if q45 then q4=q4+1;else q4null;end case;end if;end if;firest=f;end process;o1=q1;o2=q2;o3=q3;o4=q4;end;4.4 減計數(shù)器計時模塊 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); light,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=in4; -對信號都清零設(shè)置 elsif q4=(in4-15) or start=0 then light=0; -當q4=15或start=0時不進行減計數(shù),同時LED不亮 elsif start=1 then -當start=1時LED點亮同時開始倒計時if (clksevent 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時,對q1賦值為(in1-9),為負數(shù),-同時對q2進行加1,那么(in2-q2)就可以視線減1,若不是那么q1=q1+1,可以實現(xiàn)-(in1-q1)從9開始的倒計數(shù)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=(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; -當所有計數(shù)完畢end if;end if;end process;out1=(in1-q1);out2=(in2-q2);out3=(in3-q3);out4=(in4-q4);end;4.5 數(shù)據(jù)選擇器 choicelibrary 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);beginprocess(clk,q)beginif clkevent and clk=1 then q o2 o2 o2 o2 o2 null;end case;end process;o1=q; -位選信號end;4.6 數(shù)碼管顯示模塊 viewlibrary ieee;use ieee.std_logic_1164.all;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 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 -相應(yīng)的數(shù)據(jù)選擇對應(yīng)的位進行輸出 110111 when f1=3 else 101111 when f1=4 else 111111;segout(7) seg seg seg seg seg seg seg seg seg seg seg segnull;end case;end process;end;4.7 點陣顯示火力library ieee;use 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,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=X00when firee=10else -hig power -1X00when firee=01else -mid power -1X00when firee=00else -low power -1X00;d1=X00when firee=10else -hig power -2X00when firee=01else -mid power -2X00when firee=00else -low power -2X00; d2=X20when firee=10else -hig power -3X00when firee=01else -mid power -3X00when firee=00else -low power -3X00; d3=X77when firee=10else -hig power -4X07when firee=01else -mid power -4X00when firee=00else -low power -4X00; d4=X77when firee=10else -hig power -5X27when firee=01else -mid power -5X00when firee=00else -low power -5X00; d5=Xfbwhen firee=10else -hig power -6X73when firee=01else -mid power -6X20when firee=00else -low power -6X00; d6=Xdbwhen firee=10else -hig power -7Xfbwhen firee=01else -mid power -7X73when firee=00else -low power -7X00; d7=X51when firee=10else -hig power -8X71when firee=01else -mid power -8X71when firee=00else -low power -8X00; -yellow-c0=X0fwhen firee=10else -hig power -1X00when firee=01else -mid power -1X00when firee=00else -low power -1X00; c1=X0fwhen firee=10else -hig power -2X00when firee=01else -mid power -2X00when firee=00else -low power -2X00; c2=X07when firee=10else -hig power -3X00when firee=01else -mid power -3X00when firee=00else -low power -3X00; c3=X07when firee=10else -hig power -4X07when firee=01else -mid power -4X00when firee=00else -low power -4X00; c4=X27when firee=10else -hig power -5X07when firee=01else -mid power -5X00when firee=00else -low power -5X00; c5=X73when firee=10else -hig power -6X03when firee=01else -mid power -6X00when firee=00else -low power -6X00; c6=X70when firee=10else -hig power -7X20when firee=01else -mid power -7X00when firee=00else -low power -7X00; c7=X20when firee=10else -hig power -8X20when firee=01else -mid power -8X20when firee=00else -low power -8X00; process (clk,res)beginif(res=1) thenred=X00;yellow=X00;rv=1000;elsif(clkevent and clk=1)thenif(rv=0111)thenrv=0000;elservred=d0;yellow=c0; rred=d1;yellow=c1; rred=d2;yellow=c2; rred=d3;yellow=c3; rred=d4;yellow=c4; rred=d5;yellow=c5; rred=d6;yellow=c6; rred=d7;yellow=c7; rred=Xff;yellow=Xff; rnull; end case;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 clkevent and clk=1 thenif set=0 then q=0;else qo2o2null;end case;end if;end if;end process;end a;4.9 蜂鳴器報警模塊library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity beep isport(clks,zero,kzero:in std_logic; light:out std_logic);end;architecture one of beep issignal p :std_
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 再生橡膠在電線電纜中的耐腐蝕性研究考核試卷
- 農(nóng)業(yè)科學(xué)中的水產(chǎn)養(yǎng)殖品種改良考核試卷
- 原電池新型電源(講)-2023年高考化學(xué)一輪復(fù)習
- 1項目一 認識城市軌道交通票務(wù)管理系統(tǒng)
- 河南省駐馬店市上蔡縣2024-2025學(xué)年七年級下學(xué)期期末考試英語試卷(含答案無聽力原文及音頻)
- 合同履行監(jiān)控系統(tǒng)操作手冊
- 中高層管理團隊激勵實施細節(jié)
- 2024-2025學(xué)年吉林省長春市慧澤高中高一(下)期中數(shù)學(xué)試卷(含答案)
- 2025秋初中數(shù)學(xué)九年級上冊人教版教案設(shè)計 21.3實際問題與一元二次方程(2)-教案
- 科技活動AI+數(shù)智應(yīng)用化如何提升資源匹配精準度
- 2025年幼兒教育專業(yè)職業(yè)綜合素質(zhì)測評考試試題及答案
- 循環(huán)系統(tǒng)管理課件
- 餐廳服務(wù)流程與接待標準
- 高一秋季開學(xué)第一課班會課件:金秋逐夢啟新程青春執(zhí)筆繪華章
- 多主體創(chuàng)新博弈-洞察及研究
- 礦山工程機械租賃服務(wù)方案措施
- 嬰幼兒發(fā)育商測評師培訓(xùn)大綱
- 2025年佛山危險品資格證模擬考試題
- 2025-2030中國氨基胍碳酸鹽行業(yè)產(chǎn)銷狀況及應(yīng)用前景預(yù)測報告
- 影刀RPA(競品)分析報告
- 威視數(shù)字化轉(zhuǎn)型的軌跡與成效研究
評論
0/150
提交評論