首页 简易数字频率计

简易数字频率计

举报
开通vip

简易数字频率计简易数字频率计 摘 要 简易数字频率计利用复杂可编程逻辑器件FPGA,VHDL编程将所有功能模块集成在一块 芯片上。功能模块包括时基脉冲发生器、计数器、数据锁存器和显示电路4部分。设计时先 分别设计各功能模块,并调试得到正确仿真结果,然后将各个功能模块组合起来。最后作整 体仿真、下载,得到实物。由于采用纯数字硬件设计制作,稳定性、可靠性远远高于使用单 片机或模拟方式实现的系统,外围电路简单。该数字频率计达到预期要求,实现了可变量程 测量,测量范围0.1Hz—9999MHz,精度可达0.1Hz。 关键字:数字频...

简易数字频率计
简易数字频率计 摘 要 简易数字频率计利用复杂可编程逻辑器件FPGA,VHDL编程将所有功能模块集成在一块 芯片上。功能模块包括时基脉冲发生器、计数器、数据锁存器和显示电路4部分。设计时先 分别设计各功能模块,并调试得到正确仿真结果,然后将各个功能模块组合起来。最后作整 体仿真、下载,得到实物。由于采用纯数字硬件设计制作,稳定性、可靠性远远高于使用单 片机或模拟方式实现的系统,外围电路简单。该数字频率计达到预期要求,实现了可变量程 测量,测量范围0.1Hz—9999MHz,精度可达0.1Hz。 关键字:数字频率计 FPGA VHDL Abstract The digital cymometer utilize CPLD (complex programmable logic device) integrate several functional modules onto one single chip by programming with VHDL. The five functional modules are timebase generator , counter, data flip-latch and display circuit. First design the functional module and get the expected simulation results, then ensemble them into one. After that the final simulation and download was done and the product can be made. Due to the use of digital hardware designing,the stability and reliability are far more higher compared to those singlechip or anolog implemented system. The digital cymometer could achieve the expected requirement. The measurement range from 0.1Hz to 9999MHz , with the accuracy up to 0.1Hz. Keywords: Digital symometer FPGA VHDL 最后修改:September 23, 2007 1 目 录 第一章 总体设计 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 ---------------------------------------------------3 第二章 功能模块设计---------------------------------------------------3 3 2.1时基脉冲发生器的设计与制作 ----------------------------- 2.2计数器设计与制作 --------------------------------------6 2.3数据锁存器设计与制作 -----------------------------------7 2.4显示译码器设计与制作 ----------------------------------8 第三章 软件设计--------------------------------------------------------9 第四章 系统测试--------------------------------------------------------9 第五章 总结-------------------------------------------------------------10 第六章 参考文献-------------------------------------------------------10 第七章 附录-------------------------------------------------------------11 一、 总体设计方案: 将系统分解为时基脉冲发生器,计数器,数据锁存器,显示译码器功能模块。时基脉冲 2 发生器产生的脉冲送到计数器的使能端CLKK,高电平时有效,计数器在使能后开始计时,直到脉冲变为低电平,停止计数,所计到的数值送入数据锁存器,再送显示译码器去驱动LED显示器。总体结构框图如图1.1所示。 方案一:采用数字逻辑电路制作,用IC拼凑焊接实现。其特点是直接用现成的IC组合而成,简单方便,但由于使用的器件较多,连线复杂,体积大,功耗大,焊点和线路较多将使成品稳定度与精确度大打折扣。 方案二:采用可编程逻辑器件(CPLD)制作,利用EDA软件编程,下载烧制实现。将所有器件集成在一块芯片上,体积大大减小的同时还提高了稳定性,并且可应用EDA软件仿真,调试,每个设计人员可以充分利用软件代码,提高开发效率,缩短研发周期,降低研发成本。易于进行功能扩展,可以利用频率计的核心技术,改造成其它产品。实现方法灵活,调试方便,修改容易。 比较以上两种方案,易见采用后者更优。 图1.1 总体设计结构框图 二、功能模块设计 2.1时基脉冲发生器的设计: 2.1.1设计原理: 时基脉冲发生器由分频器组成,即对32Mhz晶体振荡器的输出频率进行分频,得到周期可调的脉冲作为时基闸门的控制信号,采用一级固定分频器(M,64)和一级可变编程n分频器级连组成,固定分频器(M,64)的作用是将32MHz的晶体振荡频率降低,可变编程n分频器则用于根据需要得到不同的频率输出。 3 图 2.1.1 分频器原理图 2.1.2程序设计: 对于一个稳定但频率固定的石英晶体振荡器,要得到多个具有相同稳定度的频率就必须采用分频技术。由于使用的是频率为32MHz的晶体,先进行固定64分频,然后通过判断aa的值选择档位,即可变分频的次数。 如 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 2.1.1所示,有八个档位可选择。最后通过共同的输出口将频率输出。可控分频器的外围接口电路如图2.1.2所示,程序 流程 快递问题件怎么处理流程河南自建厂房流程下载关于规范招聘需求审批流程制作流程表下载邮件下载流程设计 图如图2.1.2所示。程序代码见附录11页。 由频率测量定义: 所测频率 fx=N/T ( T:分频器输出一周期内高电平持续时间) fx=N/(0.5×Tr) ( N:波形个数,即计数器记录方波个数) =N×2×fr ( fr:闸门信号频率 fr=晶振频率/分频次数) 6 =N×2×32×10/(64*N0) (N0:可变分频次数) 6 =N×10 /N0 (NO:大小由aa2 aa1 aa0 控制) aa N0 fx 7 000 10N×0.1 6 001 10N×1 5 010 10N×10 24011 10N×10 3 3100 10N×10 2 4101 10N×10 5110 10 N×10 6111 1 N×10 表2.1.1 由表2.1.1可知:不同的aa编码对应不同的分频次数N0和测量档位,如: aa=001时, 6 分频次数为10,档位为X1。相应的读数为数码显示数字乘以档位。 图2.1.2可控分频器的外围接口电路 4 图 2.1.2分频器程序流程图 2.1.3 仿真 仿真结果如图2.1.3. 图 2.1.3 分频器仿真结果 5 2.2.计数器设计与制作 2.2.1 设计原理: 系统要求计数范围为0—9999,需要14位的二进制编码,故将计数器做成十六位带使能端的十进制加法计数器。时基信号的高电平作为使能控制信号,待测频率作为时钟触发信号,时基为低电平时停止计数,计数结果将被数据锁存器锁存,然后计数器利用低电平自动清零。若将时基高电平脉冲宽度设定为一秒,则计数器的计数既是被测信号的频率值,如果待测频率较低,可将时基脉冲宽度增加到n秒,最后将计数结果除以n即得被测频率值。 2.2.2程序设计: 程序流程是(如图2.2.2所示):首先判断时基信号clkk,当clkk=‘1’时计数,clkk=‘0’,计数器清零然后判断被测信号clk,当clk为上升沿时,计数器加1,在计数器累加过程中满十进一,一共四位,个、十、百、千分别由one,ten,hu,th表示,每位用4位二进制表示,这样四位十进制数用16位二进制表示 ,当满9999后产生进位信号co,并将16位二进制输出。程序代码见附录12页。 图 2.2.2 计数器程序流程图 6 2.2.3 程序仿真 仿真结果如图2.2.3 图 2.2.3 计数器仿真结果 2.3、数据锁存器设计与制作 2.3.1工作原理: 数据锁存器数由十六位D触发器构成,在时基闸门信号clkk下降沿触发锁存器,将16位二进制数保存在触发器中,其它时间保持触发器中数据不变,锁存器数据与数码显示管直接相连,显示数据即锁存器数据。程序流程图如图3.1所示。程序代码见附录12页。 图 2.3.1 锁存显示流程图 7 2.3.2仿真: 图 2.3.2 锁存器仿真结果 2.4.显示译码器设计与制作 2.4.1工作原理: 显示器采用8段LED显示器,除去“点”无需显示,需要7个输入信号,因此须将锁存器送来送来的4个4位数据都译成相应当7位。LED数码显示器为共阴极,故译码器真值表如表2.4.1所示。程序代码见附录13页。 输 入 输 出 显示数码 D3 D2 D1 D0 a b c d e f g 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 1 1 0 0 1 0 0 0 1 0 0 1 0 2 0 0 1 1 0 0 0 0 1 1 0 3 0 1 0 0 1 0 0 1 1 0 0 4 0 1 0 1 0 1 0 0 1 0 0 5 0 1 1 0 0 1 0 0 0 0 0 6 0 1 1 1 0 0 0 0 1 1 1 7 1 0 0 0 0 0 0 0 0 0 0 8 1 0 0 1 0 0 0 1 1 0 0 9 表2.4.1 译码器真值表 8 2.4.2 仿真波形 图 2.4.2 结果显示仿真结果 三、软件设计 使用MAX+plus II 编程实现系统的功能,并作仿真。程序清单请见附页。 四、系统测试 系统各模块的调试已再单元电路设计中完成,顶层电路程序代码见附录14页。下面对整机调试: 使用清华TPG-FPGA TPG/AC0015实验板下载程序,选用saprtan2系列的xc2s200-5pq208芯片烧制,并利用实验板上的晶振频率分频后作为调试用的被测信号。系统仿真结果如图4.1所示。 图4.1系统仿真图 9 五、总结 根据对系统进行测试的结果可见,满足设计要求。 频率计特性参数: 频率范围 :0.1—9999MHz 精度 :0.1Hz 档位 :X 0.1、X 1、X10 、X100、X1K、X10K、X100K、C1M、X10M -5频率稳定度 :10 六、参考文献 1. 黄正谨,徐坚,章小丽等.《CPLD系统设计技术入门与应用》[m]. 北京:电子工业出版 社.2002。 2. 潘松,黄计业.EDA 技术实用教程[m].北京:科学出版社.2002。 3. 王松武,蒋志坚.通用仪器[m].哈尔滨:哈尔滨工程大学出版社.2002。 4. 高吉祥.电子技术基础实验与课程设计[m].北京:电子工业出版社.2002。 5. 全国大学生电子设计竞赛组委会.第四界全国大学生电子设计竞赛获奖作品选编(1999) [m].北京:北京理工大学出版社.2001。 10 附 录 case aa is 分频器程序 ***pulse30m.vhd library ieee; when "000"=>aaa<="000000000000000000000001"; use ieee.std_logic_1164.all; when "001"=>aaa<="000000000000000000001001"; use ieee.std_logic_unsigned.all; when "010"=>aaa<="000000000000000001100100"; entity pulse30m is when "011"=>aaa<="000000000000001111101000"; port (clk: in std_logic; when "100"=>aaa<="000000000010011100010000"; aa:in std_logic_vector(2 downto 0); when "101"=>aaa<="000000011000011010100000"; fout:out std_logic when "110"=>aaa<="000011110100001001000000"; ); when "111"=>aaa<="100110001001011010000000"; end entity pulse30m; when others=>null; architecture one of pulse30m is end case; signal full,full1,full2,full3,full4: std_logic; If full2'event and full2='1' then signal aaa:std_logic_vector(23 downto 0); if cnt9 ="000000000000000000000001" then begin cnt9 := aaa; full3<='1'; p_reg: process(clk) else cnt9 :=cnt9-1; variable cnt8 : std_logic_vector(5 downto 0); full3<='0'; begin end if; If clk'event and clk='1' then end if; if cnt8 ="000001" then end process p_reg1; cnt8 :="100000"; p_div1: process(full3) full<='1'; variable cnt3 : std_logic; else cnt8 :=cnt8-1; begin full<='0'; if full3'event and full3 ='1' then end if; cnt3 :=not cnt3; end if; if cnt3='1' then fout <='1'; end process p_reg; else fout <='0'; p_div: process(full) end if; variable cnt2 : std_logic; end if; begin end process p_div1; if full'event and full ='1' then end one; cnt2 :=not cnt2; if cnt2='1' then full2 <='1'; else full2 <='0'; end if; end if; end process p_div; p_reg1: process(full2) variable cnt9 : std_logic_vector(23 downto 0); begin 11 begin 锁存器程序 if( clkk='0') then ***save.vhd library IEEE; th1<="0000"; use IEEE.STD_LOGIC_1164.ALL; hu1<="0000"; use IEEE.STD_LOGIC_ARITH.ALL; ten1<="0000"; use IEEE.STD_LOGIC_UNSIGNED.ALL; one1<="0000"; entity save is elsif(clk'event and clk='1') then port( clk :in std_logic; if clkk='1' then data :in std_logic_vector(15 downto 0); if(one1=9) then showone :out std_logic_vector(3 downto 0); one1<="0000"; showten :out std_logic_vector(3 downto 0); if (ten1=9) then showhu :out std_logic_vector(3 downto 0); ten1<="0000"; showth : out std_logic_vector(3 downto 0)); if (hu1=9) then end save; hu1<="0000"; architecture behave of save is if (th1=9) then begin th1<="0000"; process(clk) else begin th1<=th1+1; if(clk'event and clk ='0') then end if; showth<=data(15 downto 12); else showhu<=data(11 downto 8); hu1<=hu1+1; showten<=data(7 downto 4); end if; showone<=data(3 downto 0); else end if; ten1<=ten1+1; end process; end if; end behave else one1<=one1+1; 计数器程序 ***counter.vhd end if; library ieee; end if; use ieee.std_logic_1164.all; end if; use ieee.std_logic_unsigned.all; data<=th1&hu1&ten1&one1; entity counter is end process; port ( clkk:in std_logic; end behave; clk :in std_logic; th1 : buffer std_logic_vector(3 downto 0); hu1 : buffer std_logic_vector(3 downto 0); ten1 : buffer std_logic_vector(3 downto 0); one1 : buffer std_logic_vector(3 downto 0) ) ; end counter; architecture behave of counter is signal data : std_logic_vector(15 downto 0); begin counter9999:process(clk,clkk) 12 when "0110"=>show2<="1011111"; 显示译码程序 ***show.vhd when "0111"=>show2<="1110000"; library IEEE; when "1000"=>show2<="1111111"; use IEEE.STD_LOGIC_1164.ALL; when "1001"=>show2<="1111011"; use IEEE.STD_LOGIC_ARITH.ALL; when others=>null; use IEEE.STD_LOGIC_UNSIGNED.ALL; end case; case showhu is entity show is when "0000"=>show3<="1111110"; Port ( when "0001"=>show3<="0110000"; showone : in std_logic_vector(3 downto 0); when "0010"=>show3<="1101101"; showten : in std_logic_vector(3 downto 0); when "0011"=>show3<="1111001"; showhu : in std_logic_vector(3 downto 0); when "0100"=>show3<="0110011"; showth : in std_logic_vector(3 downto 0); when "0101"=>show3<="1011011"; show1 :out std_logic_vector(6 downto 0); when "0110"=>show3<="1011111"; show2 :out std_logic_vector(6 downto 0); when "0111"=>show3<="1110000"; show3 :out std_logic_vector(6 downto 0); when "1000"=>show3<="1111111"; show4 :out std_logic_vector(6 downto 0)); when "1001"=>show3<="1111011"; end show; when others=>null; architecture Behavioral of show is end case; case showth is begin when "0000"=>show4<="1111110"; show: process(showone,showth,showhu,showten) when "0001"=>show4<="0110000"; begin when "0010"=>show4<="1101101"; case showone is when "0011"=>show4<="1111001"; when "0000"=>show1<="1111110"; when "0100"=>show4<="0110011"; when "0001"=>show1<="0110000"; when "0101"=>show4<="1011011"; when "0010"=>show1<="1101101"; when "0110"=>show4<="1011111"; when "0011"=>show1<="1111001"; when "0111"=>show4<="1110000"; when "0100"=>show1<="0110011"; when "1000"=>show4<="1111111"; when "0101"=>show1<="1011011"; when "1001"=>show4<="1111011"; when "0110"=>show1<="1011111"; when others=>null; when "0111"=>show1<="1110000"; end case; when "1000"=>show1<="1111111"; end process; when "1001"=>show1<="1111011"; when others=>null; end Behavioral; end case; case showten is when "0000"=>show2<="1111110"; when "0001"=>show2<="0110000"; when "0010"=>show2<="1101101"; when "0011"=>show2<="1111001"; when "0100"=>show2<="0110011"; when "0101"=>show2<="1011011"; 13 signal fout1,fout2 :std_logic; 顶层电路程序 ****top.vhd 程序 begin library IEEE; use IEEE.STD_LOGIC_1164.ALL; u1:pulse30m port map(clk=>clk,aa=>a1,fout=>fout1); use IEEE.STD_LOGIC_ARITH.ALL; u2: pulse11 port use IEEE.STD_LOGIC_UNSIGNED.ALL entity top map(clk=>clk,aa=>a2,bb=>bb,fout=>fout2); is u3: counter port Port ( clk: in std_logic; map(clk=>fout2,clkk=>fout1,show1=>show1,show2= a1:in std_logic_vector(2 downto 0); >show2,show3=>show3,show4=>show4); a2:in std_logic_vector(2 downto 0); end Behavioral; bb:in std_logic_vector(3 downto 0); show1 :out std_logic_vector(6 downto 0); show2 :out std_logic_vector(6 downto 0); show3 :out std_logic_vector(6 downto 0); show4 :out std_logic_vector(6 downto 0)); end top; architecture Behavioral of top is component pulse11 port (clk: in std_logic; aa:in std_logic_vector(2 downto 0); bb:in std_logic_vector(3 downto 0); fout:out std_logic ); end component pulse11; component pulse30m port (clk: in std_logic; aa:in std_logic_vector(2 downto 0); fout:out std_logic ); end component pulse30m; component counter port ( clkk:in std_logic; clk :in std_logic; show1:out std_logic_vector(6 downto 0); show2:out std_logic_vector(6 downto 0); show3:out std_logic_vector(6 downto 0); show4 :out std_logic_vector(6 downto 0) ) ; end component counter; 14
本文档为【简易数字频率计】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_721103
暂无简介~
格式:doc
大小:221KB
软件:Word
页数:19
分类:互联网
上传时间:2017-10-15
浏览量:43