




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、簡易數(shù)字頻率計設(shè)計一、設(shè)計任務(wù)與要求: 設(shè)計一個具有如下功能的簡易頻率計。(1)基本要求: a被測信號的頻率范圍為120kHz,用4位數(shù)碼管顯示數(shù)據(jù)。b測量結(jié)果直接用十進制數(shù)值顯示。c被測信號可以是正弦波、三角波、方波,幅值13V不等。d具有超量程警告(可以用LED燈顯示,也可以用蜂鳴器報警)。e當(dāng)測量脈沖信號時,能顯示其占空比(精度誤差不大于1%)。(2)發(fā)揮部分:a修改設(shè)計,實現(xiàn)自動切換量程。b構(gòu)思方案,使整形時,跳變閾值自動進行調(diào)節(jié),以實現(xiàn)擴寬被測信號的幅值范圍。二、方案設(shè)計與論證:(1)數(shù)字頻率計概述:數(shù)字頻率計是直接用十進制數(shù)字來顯示被測信號頻率的一種測量裝置。它不僅可以測量正弦波、
2、方波、三角波、尖脈沖信號和其他具有周期特性的信號的頻率,而且還可以測量它們的周期。經(jīng)過改裝,可以測量脈沖寬度,做成數(shù)字式脈寬測量儀;可以測量電容做成數(shù)字式電容測量儀;在電路中增加傳感器,還可以做成數(shù)字脈搏儀、計價器等。因此數(shù)字頻率計在測量物理量方面應(yīng)用廣泛。(2) 數(shù)字頻率計方案選擇:本設(shè)計要求的測頻范圍是120KHZ,可分19999HZ和10.0020.00KHZ兩個量程,有兩種不同的方案實現(xiàn)量程的劃分:方案1:將1HZ CLK信號二分頻,取分頻后信號的高電平作為測頻的1S閘門信號,測量結(jié)果有5位,當(dāng)結(jié)果小于9999HZ時選擇低四位由數(shù)碼管顯示輸出,大于9999HZ且小于20KHZ時,選擇高
3、四位輸出,大于20KHZ時,超量程指示燈亮。通過選擇高四位或低四位來實現(xiàn)量程的自動轉(zhuǎn)換。此方案的特點是實現(xiàn)方法簡單,適合小范圍的頻率測量,但測頻范圍較大時,實現(xiàn)起來,測量速度較慢,還會造成所用元器件的浪費。方案2:由分頻來實現(xiàn)量程的劃分,將基準(zhǔn)信號經(jīng)分頻得1HZ和10HZ的分頻信號,設(shè)置一信號量SEL,初值為1HZ,將SEL信號二分頻取分頻后信號的高電平作為測頻的閘門信號。測頻的量程為19999HZ時, SEL為1HZ,測頻的閘門信號為1S;量程為10.0020.00KHZ時,將SEL為10HZ,同時表示小數(shù)點的指示燈亮,測頻的閘門信號為0.1S;當(dāng)測量結(jié)果小于9999HZ時,SEL賦值為10
4、HZ,測量結(jié)果大于9999HZ且小于20KHZ時,SEL賦值為10HZ,測量結(jié)果大于20KHZ時,超量程指示燈亮從而實現(xiàn)量程的自動轉(zhuǎn)換。此方案的特點是測頻范圍較小時,分頻略顯麻煩。但總體實現(xiàn)起來較為可行。比較兩方案可知:對于本設(shè)計,方案1較方案2簡單,方案1結(jié)果有5位,按情況選擇4位輸出顯示即可實現(xiàn)頻率的測量和量程的自動轉(zhuǎn)換;而方案2要經(jīng)過分頻略顯麻煩。但是,在本設(shè)計中,頻率測量范圍較小,量程劃分也簡單, 所以,我選方案1進行設(shè)計。 方案一原理圖: 方案二原理圖:(3)實驗相關(guān)電路原理:(1)設(shè)計原理: a 測頻率: 數(shù)字頻率計的核心是電子計數(shù)器。電子計數(shù)器可以對脈沖數(shù)目進行累加運算,能把任意
5、一段時間內(nèi)的脈沖總數(shù)計算出并由數(shù)碼管顯示出來。如某個時間間隔t內(nèi)對周期性信號的累加計數(shù)值為N,則信號頻率f為fN/t 。 因此,首先應(yīng)將被測信號變成周期性的脈沖,脈沖形成電路就是起這個作用,其脈沖的重復(fù)頻率等于被測信號頻率。脈沖形成后將它加到閘門電路的一個輸入端A,閘門電路就是用來控制開和關(guān)的一種電路,當(dāng)具有標(biāo)準(zhǔn)時間的閘門脈沖到達時,閘門便開啟,允許由A進入的脈沖通過;閘門脈沖結(jié)束后,閘門便關(guān)閉,信號就不能通過。閘門開啟時通過的脈沖送到電子計數(shù)器進行計數(shù),由裝在面板上的數(shù)碼管顯示出來。例如,時基信號的作用時間為1秒,閘門電路將打開1秒,若在這段時間內(nèi)通過閘門電路的脈沖數(shù)目
6、為1000個,則被測信號的頻率就是1000Hz。 b 測占空比: 測占空比有很多種方法,本設(shè)計采用多周期測量法其測量原理是:預(yù)置的時間和被測信號同時輸入到同步電路,在同步電路輸出端得到一個與被測信號同步的閘門信號。基準(zhǔn)信號同時控制兩個閘門的開啟和關(guān)閉。在相同的閘門開啟時間內(nèi),兩個計數(shù)器分別對被測信號的通過的高電平和低電平個數(shù)進行計數(shù),對得出的結(jié)果做運算,得到的結(jié)果即為被測信號的占空比。(2)超高速A/D、D/A板GW_ADDA說明:GW_ADDA板含兩片10位超高速DAC(轉(zhuǎn)換速率最高150MHz)和一片8位ADC(轉(zhuǎn)換速率最高50MHz),另2片3dB帶寬大于260MHz的高速運放組成變換電
7、路。GW_ADDA板上所有的A/D和D/A全部處于使能狀態(tài),除了數(shù)據(jù)線外,任一器件的控制信號線只有時鐘線,這有利于高速控制和直接利用MATLAB/DSP Builder工具的設(shè)計。GW_ADDA板上工作時鐘必須由FPGA的I/O口提供,且DAC和ADC的工作時鐘是分開的。無法直接利用MATLAB和DSP Builder進行自動流程的設(shè)計,優(yōu)點是時鐘頻率容易變化,且可通過Cyclone中的PLL的到幾乎任何時鐘頻率。由此即可測試ADC和DAC的最高轉(zhuǎn)換頻率。兩個電位器可分別調(diào)協(xié)兩個D/A輸出的幅度(輸出幅度峰峰值不可大于5V,否則波形失真);模擬信號從接插口的2針“AIN”輸入,J1和J2分別是
8、模擬信號輸出的PA、PB口,也可在兩掛鉤處輸出,分別是兩個10位DA5651輸出口。注意,使用A/D,D/A板必須打開GW48-PK2主系統(tǒng)板上的+/-12V電源,用后關(guān)閉!三、電路圖及設(shè)計文件:(1)系統(tǒng)電路圖:(2)系統(tǒng)的RTL級描述: (3)系統(tǒng)的引腳鎖定圖 (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為信號發(fā)生器產(chǎn)生的信號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' -且數(shù)碼管顯示為”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;-記低電平個數(shù)木塊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 -當(dāng)輸入信號有效時,在clk0loout<=loout+1; -上升沿來臨時,記下低電end if; -平個數(shù)end if;end process;end one;library ieee;-記高電平個數(shù)模塊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 -當(dāng)輸入信號有效時,在clk0hiout<=hiout+1;-上升沿時記下高電平的個end if; -數(shù)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二分頻產(chǎn)生相反的en,rst end if; -信號,用來作為自動切換量程模塊 if clk2='0' and en='0' then rst<='1' -的使能信號和復(fù)位信號 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為記低電平模塊的復(fù)位信號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為記高電平模塊的復(fù)位信號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 -把計算出來的占空比轉(zhuǎn)換輸出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時序仿真結(jié)果: (1)輸入信號模塊 仿真波形: 結(jié)果分析: 輸入信號signl為高頻脈沖,當(dāng)signl>"00000000"時,輸出fout為1,否則為0。 RTL Viewer:(2)低電平計數(shù)模塊: 仿真波形:結(jié)果分析:本模塊是記在閘門打開時通過低電平的個數(shù),clk0是試驗箱自帶的12MHZ的脈沖信號,enl喝clr是由經(jīng)過整形的fin分頻得來的,它們的電位時時相反,lout為閘門打開時記的低電平通過的個數(shù)。 RTL Vewer:(3)計算展空比模塊: 仿真波形: 結(jié)果分析: 本模塊實現(xiàn)計算占空比的功能,仿真波形中,設(shè)記得的高電平個數(shù)為5000,低電平的個數(shù)為5009,當(dāng)能信號load為1時,計算占空比,并把計算的占空比轉(zhuǎn)
溫馨提示
- 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)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【德陽】2025年四川德陽市中江縣醫(yī)療衛(wèi)生單位公開考核招聘工作人員115人筆試歷年典型考題及考點剖析附帶答案詳解
- 動畫書法教學(xué)課件
- 學(xué)前拼音教學(xué)課件下冊
- 小學(xué)教學(xué)課件
- 觀察物體 二 教學(xué)課件
- 陶藝課件教學(xué)設(shè)計
- 英文繪本課件教學(xué)
- 中風(fēng)教學(xué)課件
- 節(jié)日作文教學(xué)課件
- 國畫竹 教學(xué)課件
- 公安出入境培訓(xùn)課件
- 中登協(xié)初級戶外指導(dǎo)員培訓(xùn)
- 2023科研機構(gòu)招聘面試題庫100題
- 小學(xué)學(xué)業(yè)生涯規(guī)劃與目標(biāo)
- 老舊小區(qū)物業(yè)投標(biāo)方案(技術(shù)標(biāo))
- 辦公耗材采購 投標(biāo)方案(技術(shù)方案)
- 欽州市第二人民醫(yī)院白石湖院區(qū)項目環(huán)境影響報告書
- 城市水工程概論
- 撤銷冒名登記(備案)申請表
- 減肥總結(jié):如何制定有效的減肥計劃PPT
- 眼視光醫(yī)學(xué)專業(yè)綜合概述
評論
0/150
提交評論