




已閱讀5頁,還剩31頁未讀, 繼續免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
數字電路綜合實驗簡易微波爐控制器數 字 電 路 綜 合 實 驗姓名: XXX 班級: XXXX 學號: XXX 班內序號: XXX 1. 設計任務要求設計制作一個簡易微波爐控制器。基本要求:1、 微波爐的火力有大、中、小三檔可選。用一個按鍵實現火力的選擇,用點陣顯示火力檔位,點陣的顯示隨著按鍵的按下次數而變化,沒有選擇時默認的火力為大。2、 微波加熱時間在0-59分59秒之間可選。用4個按鍵分別設置加熱時間各位的長度,用數碼管顯示加熱時間。3、 設置一個開始鍵,按下此鍵后開始加熱。加熱過程中,用數碼管倒計時顯示剩余時間。4、 加熱過程中,不能修改火力和加熱時間。5、 加熱完成后蜂鳴器至少鳴響兩聲以提醒使用者加熱已結束,加熱結束后回到等待狀態。6、 設置復位鍵,任何時候按下復位鍵可以取消加熱,回到等待狀態,只有在等待狀態下才可以修改火力和加熱時間。提高要求:1、 用8個LED燈作為加熱進度顯示條,隨著加熱時間的增加勻速增加點亮LED燈的個數,無論加熱時間是多長,最后都必須將8個LED燈全部點亮。2、 增加燒烤功能,用一個鍵選擇微波或燒烤功能,用一個數碼管指示當前處于微波還是燒烤功能。3、 燒烤火力和加熱時間要求與微波功能相同。4、 自擬其它功能。2系統設計2.1 設計思路看到實驗設計要求后,首先確定了需要使用的硬件,如數碼管、點陣、蜂鳴器、led燈和按鍵等。然后再分出模塊來,一步一步將功能分解成小模塊,更容易實現每一步的功能,容易仿真,不容易出錯,出錯也好查。2.2 總體框圖開始火力設置停止時間設置圖1 硬件結構框圖控制器分頻模塊進度條顯示譯碼模塊點陣火力顯示時間顯示火力設置時間設置初始化模塊圖2 模塊劃分控制器點陣火力顯示揚聲器進度條顯示譯碼顯示計時器分頻器時鐘開始復位設置圖3 邏輯劃分框圖開始初始化設置加熱時間,火力倒計時按下“開始”鍵?按下“復位”鍵?倒計時時間到?揚聲器響兩次是是是否否否圖4 ASM圖等待加熱10010000圖5 狀態轉移圖2.3 分塊設計這里只對其中幾個模塊進行說明,不說明的均是一些很簡單的、顯而易見的模塊。2.3.1 初始化模塊這是將整個電路的輸入信號轉化成適合程序處理和計算的信號或變量,再輸出到其他模塊中進行計算。每當時鐘檢測到摸個信號變為高電平后,便對這個信號進行處理,比如輸出信號自身加1,或置0。2.3.2 減計數計時模塊由于在加熱過程中,不允許設置時間和火力,所以對reset鍵進行了特別的設置。還有就是最核心的倒計時程序了。我分別檢測秒、十秒、分、十分4位的剩余時間,進行減計數或借位等設置。當檢測到4位的時間均為0時,倒計時結束。并輸出一個結束信號,控制蜂鳴器報警(這部分在蜂鳴器模塊詳細說明)。2.3.3 點陣顯示火力模塊我用三色點陣顯示火力,點陣左側是火苗,火苗大小表示火力大小,右側是一個火力條,火力條的高低表示火力大小。我設置里兩個行向量分別控制紅色和綠色的led小燈亮暗,設置列向量進行列掃描,要亮起的一行置0,其余全部置1。效果很漂亮。2.3.4 數碼管顯示模塊這模塊主要是和數據選擇模塊一起用。根據書上數碼管顯示數字對應的高低電平設置好表格就好了,然后根據輸入信號來選擇需要顯示的數字,根據已經寫好的對應的高低電平,就可以正常顯示了。2.3.5 蜂鳴器報警模塊這個模塊實現的功能雖然很簡單,但是我卻遇到了不少困難。首先遇到的困難是下載成功的同時蜂鳴器馬上就報警,于是我在倒計時模塊中加入了加熱停止信號,在所有位都為0時,該信號置1。但是還不成功,蜂鳴器在我按下start鍵后就響起來了,并不是在計時結束才響,我就又加了一個輸入信號,末位一定不總是0才允許蜂鳴器報警。接下來又遇到了新的問題,就是蜂鳴器不是響3下就停止報警,而是一個周期一個周期重復這3下報警,我又加了報警檢測信號,計算報警的6秒時間結束后,強制將蜂鳴器置0 。問題才解決。3. 仿真波形及波形分析3.1 初始化文件first圖6 初始化文件仿真波形輸入為時鐘信號clk,時間設置信號s3s0,火力設置信號ffire。輸出波形為時間計數信號o4o1和火力大小信號firest。3.2 減計數器倒計時模塊 jianjishu圖7 減計數器倒計時模塊仿真波形輸入為秒時鐘信號clk,開始start,復位res,時間輸入信號in4in1。輸出信號為時間輸出信號out4out1,蜂鳴器響起信號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和yellow信號成一個小中苗狀,火苗左側為矮的中火力顯示條。圖10 點陣顯示火力模塊件仿真波形(三色大火)輸入為時鐘信號clk,復位res,火力大小信號firee。輸出為行掃描信號r,紅色燈列向量red,黃色led燈列向量yellow。如果將圖順時針旋轉90,則可以看出red和yellow信號成一個大火苗狀,火苗左側為矮的大力顯示條。(注意紅色red和黃色yellow重疊起來看!)3.4 進度條顯示模塊進度條圖11 進度條顯示模塊件仿真波形輸入為時鐘信號clk,復位res,設置的加熱時間i4i1,倒計時剩余時間c4c1。輸出為8個led燈向量ledd。從圖中可以看出,隨著剩余時間的減少,8個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_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; -初始化數據 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 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 減計數器計時模塊 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; -對信號都清零設置 elsif q4=(in4-15) or start=0 then light=0; -當q4=15或start=0時不進行減計數,同時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),為負數,-同時對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=(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 數據選擇器 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 數碼管顯示模塊 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 -相應的數據選擇對應的位進行輸出 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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 遼寧省大連市新民間聯盟2024-2025學年初三第六次摸底考試數學試題含解析
- 遼寧省大石橋市重點名校2025年初三聯考考試數學試題含解析
- 色達縣2025年三下數學期末考試模擬試題含解析
- 江蘇宿遷市2024-2025學年下學期高三生物試題(文史類)一模考試試卷含解析
- 浙江水利水電學院《分子與細胞生物學檢測技術》2023-2024學年第二學期期末試卷
- 伊春市嘉蔭縣2025屆三下數學期末質量檢測試題含解析
- 室內裝飾材料員培訓
- 如何打造高端大氣活動
- 2025購車合同簡版格式
- 2025華帝租賃合同
- DB36 1993-2024 水產養殖尾水排放標準
- 基于改進YOLOv8的電梯內電動車檢測算法研究
- 2025年全球及中國玻璃通孔(TGV)工藝的激光設備行業頭部企業市場占有率及排名調研報告
- 高校課堂教學創新大賽一等獎課件:混合教學模式創新實踐
- 人教版(2024)七年級下冊英語期中復習:Unit1~4+期中共5套學情調研檢測試卷(含答案)
- 提升供應商質量管理的方案
- 《房顫診治指南解讀》課件
- 中考化學主題復習(重慶)專題4綜合實驗的探究
- 2008年高考數學試卷(文)(全國卷Ⅱ)(解析卷)
- 專題01 富強與創新【考情透視+框架梳理+考點突破+題型歸納】道德與法治上學期期末高效復習資料
- 人力資源管理軟件采購協議
評論
0/150
提交評論