




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、簡易數字頻率計設計一、設計任務與要求: 設計一個具有如下功能的簡易頻率計。(1)基本要求: a被測信號的頻率范圍為120kHz,用4位數碼管顯示數據。b測量結果直接用十進制數值顯示。c被測信號可以是正弦波、三角波、方波,幅值13V不等。d具有超量程警告(可以用LED燈顯示,也可以用蜂鳴器報警)。e當測量脈沖信號時,能顯示其占空比(精度誤差不大于1%)。(2)發揮部分:a修改設計,實現自動切換量程。b構思方案,使整形時,跳變閾值自動進行調節,以實現擴寬被測信號的幅值范圍。二、方案設計與論證:(1)數字頻率計概述:數字頻率計是直接用十進制數字來顯示被測信號頻率的一種測量裝置。它不僅可以測量正弦波、
2、方波、三角波、尖脈沖信號和其他具有周期特性的信號的頻率,而且還可以測量它們的周期。經過改裝,可以測量脈沖寬度,做成數字式脈寬測量儀;可以測量電容做成數字式電容測量儀;在電路中增加傳感器,還可以做成數字脈搏儀、計價器等。因此數字頻率計在測量物理量方面應用廣泛。(2) 數字頻率計方案選擇:本設計要求的測頻范圍是120KHZ,可分19999HZ和10.0020.00KHZ兩個量程,有兩種不同的方案實現量程的劃分:方案1:將1HZ CLK信號二分頻,取分頻后信號的高電平作為測頻的1S閘門信號,測量結果有5位,當結果小于9999HZ時選擇低四位由數碼管顯示輸出,大于9999HZ且小于20KHZ時,選擇高
3、四位輸出,大于20KHZ時,超量程指示燈亮。通過選擇高四位或低四位來實現量程的自動轉換。此方案的特點是實現方法簡單,適合小范圍的頻率測量,但測頻范圍較大時,實現起來,測量速度較慢,還會造成所用元器件的浪費。方案2:由分頻來實現量程的劃分,將基準信號經分頻得1HZ和10HZ的分頻信號,設置一信號量SEL,初值為1HZ,將SEL信號二分頻取分頻后信號的高電平作為測頻的閘門信號。測頻的量程為19999HZ時, SEL為1HZ,測頻的閘門信號為1S;量程為10.0020.00KHZ時,將SEL為10HZ,同時表示小數點的指示燈亮,測頻的閘門信號為0.1S;當測量結果小于9999HZ時,SEL賦值為10
4、HZ,測量結果大于9999HZ且小于20KHZ時,SEL賦值為10HZ,測量結果大于20KHZ時,超量程指示燈亮從而實現量程的自動轉換。此方案的特點是測頻范圍較小時,分頻略顯麻煩。但總體實現起來較為可行。比較兩方案可知:對于本設計,方案1較方案2簡單,方案1結果有5位,按情況選擇4位輸出顯示即可實現頻率的測量和量程的自動轉換;而方案2要經過分頻略顯麻煩。但是,在本設計中,頻率測量范圍較小,量程劃分也簡單, 所以,我選方案1進行設計。 方案一原理圖: 方案二原理圖:(3)實驗相關電路原理:(1)設計原理: a 測頻率: 數字頻率計的核心是電子計數器。電子計數器可以對脈沖數目進行累加運算,能把任意
5、一段時間內的脈沖總數計算出并由數碼管顯示出來。如某個時間間隔t內對周期性信號的累加計數值為N,則信號頻率f為fN/t 。 因此,首先應將被測信號變成周期性的脈沖,脈沖形成電路就是起這個作用,其脈沖的重復頻率等于被測信號頻率。脈沖形成后將它加到閘門電路的一個輸入端A,閘門電路就是用來控制開和關的一種電路,當具有標準時間的閘門脈沖到達時,閘門便開啟,允許由A進入的脈沖通過;閘門脈沖結束后,閘門便關閉,信號就不能通過。閘門開啟時通過的脈沖送到電子計數器進行計數,由裝在面板上的數碼管顯示出來。例如,時基信號的作用時間為1秒,閘門電路將打開1秒,若在這段時間內通過閘門電路的脈沖數目
6、為1000個,則被測信號的頻率就是1000Hz。 b 測占空比: 測占空比有很多種方法,本設計采用多周期測量法其測量原理是:預置的時間和被測信號同時輸入到同步電路,在同步電路輸出端得到一個與被測信號同步的閘門信號。基準信號同時控制兩個閘門的開啟和關閉。在相同的閘門開啟時間內,兩個計數器分別對被測信號的通過的高電平和低電平個數進行計數,對得出的結果做運算,得到的結果即為被測信號的占空比。(2)超高速A/D、D/A板GW_ADDA說明:GW_ADDA板含兩片10位超高速DAC(轉換速率最高150MHz)和一片8位ADC(轉換速率最高50MHz),另2片3dB帶寬大于260MHz的高速運放組成變換電
7、路。GW_ADDA板上所有的A/D和D/A全部處于使能狀態,除了數據線外,任一器件的控制信號線只有時鐘線,這有利于高速控制和直接利用MATLAB/DSP Builder工具的設計。GW_ADDA板上工作時鐘必須由FPGA的I/O口提供,且DAC和ADC的工作時鐘是分開的。無法直接利用MATLAB和DSP Builder進行自動流程的設計,優點是時鐘頻率容易變化,且可通過Cyclone中的PLL的到幾乎任何時鐘頻率。由此即可測試ADC和DAC的最高轉換頻率。兩個電位器可分別調協兩個D/A輸出的幅度(輸出幅度峰峰值不可大于5V,否則波形失真);模擬信號從接插口的2針“AIN”輸入,J1和J2分別是
8、模擬信號輸出的PA、PB口,也可在兩掛鉤處輸出,分別是兩個10位DA5651輸出口。注意,使用A/D,D/A板必須打開GW48-PK2主系統板上的+/-12V電源,用后關閉!三、電路圖及設計文件:(1)系統電路圖:(2)系統的RTL級描述: (3)系統的引腳鎖定圖 (4)程序源代碼:library ieee;-輸入信號模塊use ieee.std_logic_1164.all;entity comp isport(signl:in std_logic_vector(7 downto 0);fout:out std_logic);end comp;-signl為信號發生器產生的信號archite
9、cture one of comp isbeginprocess(signl)beginif (signl>"00000000") then -判斷輸入信號不為0fout<='1' -fout為以后電路的門else -信號fout<='0'end if;end process;end one;library ieee;-自動切換量程模塊use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity
10、corna is port(clr,fin,en,key2,rst:in std_logic; ranin:in std_logic_vector(15 downto 0); alm:out std_logic; dis_out:buffer std_logic_vector(15 downto 0);end corna;architecture one of corna issignal c0,c1,c2,c3,c4:std_logic_vector(3 downto 0); beginp1:process(en,fin) begin if rst='1' then alm&
11、lt;='0' elsif clr='1' then c0<="0000"c1<="0000"c2<="0000"c3<="0000"c4<="0000" elsif fin'event and fin='1' then if en='1' then if c0<"1001" then c0<=c0+1; else c0<="0000"
12、if c1<"1001" then c1<=c1+1; else c1<="0000" if c2<"1001" then c2<=c2+1; else c2<="0000"if c3<"1001" then c3<=c3+1;else c3<="0000" if c4<"0001" then c4<=c4+1; else c4<="1111" c3<=&qu
13、ot;1111" c2<="1111" c1<="1111" -超過量程2KHZ時會報警,并alm<='1' -且數碼管顯示為”FFFF” end if;end if; end if; end if ; end if; elsec4<="0000"c3<="0000"c2<="0000"c1<="0000"c0<="0000"alm<='0' end if;en
14、d if;end process p1;p2:process(key2,ranin,c4) begin if key2='1' then dis_out<=ranin; -若key2有效,則輸出為占空比,否 elsif c4/="0000"then -則為顯示頻率 dis_out<=c4&c3&c2&c1; -c4不為“0000”時,量程最低位為 else -10HZ,記頻率范圍為0-2KHZ,c4為 dis_out<=c3&c2&c1&c0; -“0000”時,量程最低位為1HZ,記 end
15、 if; -頻率范圍為0-9999HZend process p2; end one;library ieee;-記低電平個數木塊use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count1 isport(enl,clr,clk0:in std_logic;loout:buffer integer range 1 to 600000);end count1;architecture one of count1 isbeginprocess(enl,clr,clk0)beginif clr='1'
16、; thenloout<=1;elsif (clk0'event and clk0='1') thenif enl='1' then -當輸入信號有效時,在clk0loout<=loout+1; -上升沿來臨時,記下低電end if; -平個數end if;end process;end one;library ieee;-記高電平個數模塊use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count2 isport(enh,clr,clk0:in std_lo
17、gic;hiout:buffer integer range 1 to 600000);end count2;architecture one of count2 isbeginprocess(enh,clr,clk0)beginif clr='1' then -clk0為實驗板自帶的12MHZhiout<=1; -信號elsif (clk0'event and clk0='1') thenif enh='1' then -當輸入信號有效時,在clk0hiout<=hiout+1;-上升沿時記下高電平的個end if; -數e
18、nd if;end process;end one;library ieee;-控制模塊一use ieee.std_logic_1164.all;entity ctrl is port(clk2:in std_logic; rst,load:out std_logic; en:buffer std_logic);end ctrl;architecture one of ctrl isbegin process(clk2,en) begin -clk2為試驗箱自帶的1HZ信號 if clk2'event and clk2='1' then en<=not en; -
19、以clk2二分頻產生相反的en,rst end if; -信號,用來作為自動切換量程模塊 if clk2='0' and en='0' then rst<='1' -的使能信號和復位信號 else rst<='0' end if; end process; load<=not en; -對en取反得到load,作為鎖存器模塊end one; -的允許鎖存信號library ieee;-控制模塊二use ieee.std_logic_1164.all;entity ctrl1 isport(fin:in std_l
20、ogic;enl:buffer std_logic;clr,load:out std_logic);end ctrl1;architecture one of ctrl1 issignal ct:std_logic;beginprocess(fin,enl,ct)beginif fin'event and fin='1' thenct<=(not ct);end if;if fin='1' and ct='0' thenclr<='1' -clr為記低電平模塊的復位信號elseclr<='0
21、9;end if;if ct='1' and fin='0' thenenl<='1' -enl為記高電平模塊的使能信號elseenl<='0'end if;end process;load<=(not ct); -load為計算占空比模塊的門控信號end one;library ieee;-控制模塊三use ieee.std_logic_1164.all;entity ctrl2 isport(fin:in std_logic;enh:buffer std_logic;clr:out std_logic);en
22、d ctrl2;architecture one of ctrl2 issignal ct: std_logic;beginprocess(fin,enh,ct)beginif fin'event and fin='1' thenct<=(not ct);end if;if fin='0' and ct='0' thenclr<='1' -clr為記高電平模塊的復位信號elseclr<='0'end if;if ct='1' and fin='1' then
23、enh<='1' -enh為記高電平模塊的使能信號elseenh<='0'end if;end process;end one;library ieee;-譯碼顯示模塊use ieee.std_logic_1164.all;entity disp isport(key2,clk0:in std_logic; ran:in std_logic_vector(7 downto 0);dataout:out std_logic_vector(15 downto 0);end disp;architecture one of disp isbeginproc
24、ess(key2,clk0)begin if clk0'event and clk0='1' thenif(key2='1') then -key2有效時,把計算的占空比dataout<=ran&"00000000" -輸出顯示end if; end if;end process;end one; library ieee;-鎖存器模塊use ieee.std_logic_1164.all;entity reg16 is port(load:in std_logic; datain:in std_logic_vector
25、(15 downto 0); dataout:out std_logic_vector(15 downto 0);end reg16;architecture one of reg16 isbegin process(load) begin if load'event and load='1' then dataout<=datain; -鎖存要輸出的信息 end if; end process; end one;library ieee;-計算占空比模塊use ieee.std_logic_1164.all;use ieee.std_logic_arith.al
26、l;entity slov isport(load:in std_logic;high,low:in integer range 1 to 600000;ran:out std_logic_vector(7 downto 0);end slov;architecture one of slov issignal a,b:integer range 0 to 9;signal ranh,ranl:std_logic_vector(3 downto 0); beginprocess(high,low)begin -計算占空比a<=(high*10)/(high+low);b<=(hig
27、h*10) rem (high+low)*10/(high+low);end process;process(a,b)begin -把計算出來的占空比轉換輸出if load'event and load='1' thenranh<=conv_std_logic_vector(a,4);ranl<=conv_std_logic_vector(b,4);end if;ran<=ranh&ranl;end process;end one;library ieee;-整形模塊use ieee.std_logic_1164.all;entity zhen
28、gxing isport(clk0,a:in std_logic;q:out std_logic);end zhengxing;architecture one of zhengxing isbeginprocess(clk0)beginif clk0'event and clk0='1' thenq<=a; -對輸入信號進行整形end if;end process;end one;library ieee;-頂層文件use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_l
29、ogic_arith.all;entity div is port(clk0,clk2,key2,rst:in std_logic; signl:in std_logic_vector(7 downto 0); alm:out std_logic; data:out std_logic_vector(15 downto 0);end div;-各個模塊的元件例化聲明architecture one of div iscomponent comp isport(signl:in std_logic_vector(7 downto 0);fout:out std_logic);end compon
30、ent;component zhengxing isport(clk0,a:in std_logic;q:out std_logic);end component;component ctrl is port(clk2:in std_logic; rst,load:out std_logic; en:buffer std_logic);end component ctrl;component reg16 is port(load:in std_logic; datain:in std_logic_vector(15 downto 0); dataout:out std_logic_vector
31、(15 downto 0);end component;component ctrl1 isport(fin:in std_logic;enl:buffer std_logic;clr,load:out std_logic);end component;component ctrl2 isport(fin:in std_logic;enh:buffer std_logic;clr:out std_logic);end component;component count1 isport(enl,clr,clk0:in std_logic;loout:out integer range 1 to
32、600000);end component;component count2 isport(enh,clr,clk0:in std_logic;hiout:out integer range 1 to 600000);end component;component slov isport(load:in std_logic;high,low:in integer range 1 to 600000;ran:out std_logic_vector(7 downto 0);end component;component disp isport(key2,clk0:in std_logic;ran
33、:in std_logic_vector(7 downto 0);dataout:out std_logic_vector(15 downto 0);end component;component corna is port(clr,fin,en,key2,rst:in std_logic; ranin:in std_logic_vector(15 downto 0); alm:out std_logic; dis_out:buffer std_logic_vector(15 downto 0);end component corna;signal countclr,regload,count
34、en,count1en,count2en,count1clr,count2clr,slovload,finf,finedf:std_logic;signal datall,fran:std_logic_vector(15 downto 0);signal hinum,lownum:integer range 1 to 600000;signal hpl:std_logic_vector(7 downto 0);-電路的具體連接beginu0:zhengxing port map(clk0,finf,finedf);u1:ctrl port map(clk2,countclr,regload,c
35、ounten);u2:corna port map(countclr,finedf,counten,key2,rst,fran,alm,datall);u3:reg16 port map(regload,datall,data);u4:ctrl1 port map(finedf,count1en,count1clr,slovload);u5:ctrl2 port map(finedf,count2en,count2clr);u6:count1 port map(count1en,count1clr,clk0,lownum);u7:count2 port map(count2en,count2c
36、lr,clk0,hinum);u8:slov port map(slovload,hinum,lownum,hpl);u9:disp port map(key2,clk0,hpl,fran);ul0:comp port map(signl,finf);end one;四、FPGA時序仿真結果: (1)輸入信號模塊 仿真波形: 結果分析: 輸入信號signl為高頻脈沖,當signl>"00000000"時,輸出fout為1,否則為0。 RTL Viewer:(2)低電平計數模塊: 仿真波形:結果分析:本模塊是記在閘門打開時通過低電平的個數,clk0是試驗箱自帶的12MHZ的脈沖信號,enl喝clr是由經過整形的fin分頻得來的,它們的電位時時相反,lout為閘門打開時記的低電平通過的個數。 RTL Vewer:(3)計算展空比模塊: 仿真波形: 結果分析: 本模塊實現計算占空比的功能,仿真波形中,設記得的高電平個數為5000,低電平的個數為5009,當能信號load為1時,計算占空比,并把計算的占空比轉
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司游戲線上活動方案
- 公司美甲活動策劃方案
- 公司文化曬單活動方案
- 公司組織員工清雪活動方案
- 公司每周團體活動方案
- 公司百日會戰活動方案
- 公司搬遷慶祝活動方案
- 公司日常野餐活動方案
- 公司活動全案策劃方案
- 公司百年慶典策劃方案
- 水利工程閥門安裝及調試方案
- 旅游住宿安排協議
- CT設備故障處理及應急方案
- 代持股協議書
- 【網易云聽音樂的品牌營銷問題及優化建議探析(論文)11000字】
- 歷屆“挑戰杯”全國大學生課外科技學術作品競賽獲獎作品
- 遼寧省錦州市2023-2024學年高二下學期期末考試+政治試卷(含答案)
- 貴州省2024年小升初語文模擬考試試卷(含答案)
- 會員體系構建與個性化服務提升策略
- 遼寧省營口市2024年中考物理真題試卷含解析
- 創業大賽承辦服務投標方案(技術方案)
評論
0/150
提交評論