基于單片機控制的數字鐘課程設計_第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

提交評論