当前位置:文档之家› 超声波测身高

超声波测身高

超声波测身高超声波身高测量仪,该测量仪是由单片机组成的单片机中央控制系统,超声波发射电路由发射驱动电路和设于该驱动电路输出端的超声波换能器构成,超声波接收电路由超声波接收换能器、限位电路和超声波接收集成块电路构成。

1.传感器超声波传感器是利用超声波的特性研制而成的传感器。

以超声波作为检测手段,必须产生和接收超声波,完成这种功能的装置就是超声波传感器。

超声波传感器主要由压电晶片组成,既可以发射超声波,也可以接收超声波。

超声波传感器的核心是其塑料外套或者金属外套中的一块压电晶片。

超声波传感器的主要性能指标是工作频率、工作温度、灵敏度。

2. 超声波发生器为了研究和利用超声波,人们已经设计和制成了许多超声波发生器。

超声波发生器可以分为两类:一类是用电气方式产生超声波,一类是用机械方式产生超声波。

电气方式包括压电型、磁致伸缩型和电动型等;机械方式有加尔统笛、液哨和气流旋笛等。

目前较为常用的是压电式超声波发生器。

压电式超声波发生器的原理:利用压电晶体的谐振来工作的。

超声波发生器内部结构由两个压电晶片和一个共振板构成。

当它的两极外加脉冲信号,其频率等于压电晶片的固有振荡频率时,压电晶片将会发生共振,并带动共振板振动,便产生超声波。

反之,如果两电极间未外加电压,当共振板接收到超声波时,讲压迫压电晶片做振动,讲机械能转换为电信号,这时它就成为超声波接收器了。

3.超声波测量仪原理本设计是以超声波作为检测手段,必须产生超声波和接收超声波。

传感器通过声波的波长和发射声波以及接收到返回声波的时间差就能确定人体的身高,在发送脉冲的同时,接收器的计时器启动并计数,直至接收传感器接收反射回波后,计数停止,该时间差相当于测量的距离,从而可测算出测量仪与头顶之间的距离,即人体的身高。

4.EDA设计思路该超声波测量仪有2个子模块:测距、显示数据。

其中显示数据模块有3部分构成:计数、显示、信号处理。

测量主要由超声波传感器完成。

将发射和接收的时间差转换为电信号,再有A/D转换器得到数字信号,然后将数字信号送入到计数部分,再到显示。

5.EDA设计(1).VHDL顶层设计顶层文件就是用原件例化格式将显示模式、计时模块、分频模块组合在一起。

其源代码如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clock isport(clk:in std_logic;enable:in std_logic;sel:out std_logic_vector(2 downto 0);choose:out std_logic_vector(7 downto 0);segment:out std_logic_vector(6 downto 0);end clock;architecture rt1 of clock iscomponent clk_div100 --分频器port(clk:in std_logic;clk_div:out std_logic);end component;component time_counter --计数器(产生各分秒显示位)port(enable:in std_logic;clk0:in std_logic;sec10:out std_logic_vector(2 downto 0);sec:out std_logic_vector(3 downto 0);seec10:out std_logic_vector(3 downto 0);seec:out std_logic_vector(3 downto 0););end component;component display --与数码管连接,显示分秒位在其上port(clk:in std_logic;sec10:in std_logic_vector(2 downto 0);sec:in std_logic_vector(3 downto 0);seec10:in std_logic_vector(3 downto 0);seec:in std_logic_vector(3 downto 0);sel:out std_logic_vector(2 downto 0);choose:out std_logic_vector(7 downto 0);segment:out std_logic_vector(6 downto 0));end component;signal sec10:std_logic_vector(2 downto 0);signal sec:std_logic_vector(3 downto 0);signal seec10:std_logic_vector(3 downto 0);signal seec:std_logic_vector(3 downto 0);signal clk0:std_logic;beginu0:clk_div100 port map(clk,clk0);u1:time counter port map(enable,clk0,sec10,sec,seec10,seec); u2:display port map(clk,sec10,sec,seec,seec10,choose,segment); u2:display port map(clk,sec10,sec,seec10,seec,sel,segment); end rt1;(2).传感器产生信号clk源代码如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clk_div10 isport(clk:in std_logic;clk_div:out std_logic);end clk_div10;architecture rt1 of clk_div10 issignal q_tmp :integer range 0 to 9;beginprocess(clk)beginif(clk’event and clk=’1’)thenif(q_tmp=9)thenq_tmp<=0;elseq_tmp<=q_tmp+1;end if;end if;end process;process(clk)beginif(clk’event and clk=’1’)thenif(q_tmp=9)thenclk_div<=’1’;elseclk_div<=’0’;end if;end if;end process;end rt1;(3).计时模块源代码如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count10 isport(enable :in std_logic;clk: in std_logic;cout: out std_logic;q:out std_logic_vector(3 downto 0));end count10;architecture rt1 of count10 issignal q_tmp:std_logic_vector(3 downto 0);beginprocess(clk)beginif(clk’event and clk=’1’)thenif(enable=’1’)thenif(q_tmp=”1001”)thenq_tmp<=(others=>’0’);elseq_tmp<=q_tmp+1;end if;end if;end if;q<=q_tmp;end process;cout<=’1’when q_tmp=”1001”and enable=’1’ else’0’; cout<=’1’when q_tmp=”1001” else’0’;end rt1;library ieee;use ieee.std_logic_1164.all;entity time_counter isport(enable:in std_logic;clk0:in std_logic;sec10:out std_logic_vector(2 downto 0);sec:out std_logic_vector(3 downto 0);seec10:out std_logic_vector(3 downto 0);seec:out std_logic_vector(3 downto 0););end time_counter;architecture rt1 of time_counter iscomponent count10port(enable:in std_logic;clk: in std_logic;cout: out std_logic;q: out std_logic_vector(3 downto 0));end component;signal co1,co2,co3,co4,co5,co6,co7:std_logic;beginu0:count10 port map(enable,clk0,co1,seec);u1:count10 port map(co1,clk0,co2,seec10);u2:count10 port map(co2,clk0,co3,sec);u3:count10 port map(co3,clk0,co4,sec10);(4).显示模块其模块框图如下:从图3-1中可以看出,显示模块有四个部分构成:八进制计数器、计时位选择电路、七段显示译码电路、显示位选择译码电路。

在外部时钟信号clk的作用下,8进制计数器的输出从000到111按顺序循环变化,输出信号为sel。

信号sel经过位选择电路译码后产生用来选通一个LED 七段显示数码管的choose信号,同时它还作为计时位选择电路的选择信号,用来选择对应位的数据并将其转换为四位位矢量。

,将其转换成用来点燃LED七段显示数码管的segment信号。

library ieee; --三八译码器use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count8 isport(clk:in std_logic;sel:out std_logic_vector(2 downto 0);end count8;architecture rt1 of count8 issignal sel_tmp:std_logic_vector(2 downto 0);beginprocess(clk)beginif (clk’event and clk=’1’)thenif(sel_tmp=”111”)thensel_tmp<=(others=>’0’);elsesel_tmp<=sel_tmp+1;end if;sel<=sel_tmp;end process;end rt1;计时位选择电路的功能是根据8进制计数器的计数输出的选择信号来选择对应计时显示位的计时数据,作为送至七段显示译码电路的输入数据。

相关主题