1、因此,设计好的超声波测距仪就显得非常重要了。2 波测距原理2.1 压电式超声波发生器原理压电式超声波发生器实际上是利用压电晶体的谐振来工作的。超声波发生器内部结构,它有两个压电晶片和一个共振板。当它的两极外加脉冲信号,其频率等于压电晶片的固有振荡频率时,压电晶片将会发生共振,并带动共振板振动,便产生超声波。反之,如果两电极间未外加电压,当共振板接收到超声波时,将压迫压电晶片作振动,将机械能转换为电信号,这时它就成为超声波接收器了。测量脉冲到达时间的传统方法是以拥有固定参数的接收信号开端为基础的。这个界限恰恰选于噪音水平之上,然而脉冲到达时间被定义为脉冲信号刚好超过界限的第一时刻。一个物体的脉冲
2、强度很大程度上取决于这个物体的自然属性尺寸还有它与传感器的距离。进一步说,从脉冲起始点到刚好超过界限之间的时间段随着脉冲的强度而改变。结果,一种错误便出现了两个拥有不同强度的脉冲在不同时间超过界限却在同一时间到达。强度较强的脉冲会比强度较弱的脉冲超过界限的时间早点,因此我们会认为强度较强的脉冲属于较近的物体。2 声波测距原理 超声波发射器向某一方向发射超声波,在发射时刻的同时开始计时,超声波在空气中传播,途中碰到障碍物就立即返回来,超声波接收器收到反射波就立即停止计时。超声波在空气中的传播速度为34m/,根据计时器记录的时间 t,就可以计算出发射点距障碍物的距离s,即:s340t23 波测距系
3、统的电路设计 系统的特点是利用单片机控制超声波的发射和对超声波自发射至接收往返时间的计时,单片机选用 C5,经济易用,且片内有 4K 的 ROM,便于编程。3.40 脉冲的产生与超声波发射测距系统中的超声波传感器采用UCM0 的压电陶瓷传感器,它的工作电压是40z 的脉冲信号,这由单片机执行下面程序来产生。puzel: mv4h 12;超声波发射持续 0shere: cpl p.0 ; 输出 40kH方波n ; o ; nop ;djnz 14h,he; ret 前方测距电路的输入端接单片机1 端口,单片机执行上面的程序后,在 1.0端口输出一个 40Hz 的脉冲信号,经过三极管T 放大,驱动
4、超声波发射头CM0T,发出 40kHz 的脉冲超声波,且持续发射 0m。右侧和左侧测 距电路的输入端分别接 P11和 P12端口,工作原理与前方测距电路相同。3.2 超声波的接收与处理接收头采用与发射头配对的UCM4R,将超声波调制脉冲变为交变电压信号,经IC2运算放大器 IA和 1B 两极放大后加至 I2。 是带有锁 定环的音频译码集成块LM7,内部的压控振荡器的中心频率 f1/1.18C3,电容 C4 决定其锁定带宽。调节8 在发射的载频上,则 L7 输入信号大于 25mV,输出端 8脚由高电平跃变为低电平,作为中断请求信号,送至单片机处理 前方测距电路的输出端接单片机NT0端口,中断优先
5、级最高,左、右测距电路的输出通过与门 C3A 的输出接单片机 N1 端口,同时单片机P1. 和 P1.4 接到 I的输入端,中断源的识别由程序查询来处理,中断优先级为先右后左。部分源程序如下:reie1:push pswpush acc ex1;关外部中断 1 jb 1.ight;P1 引脚为0转至右测距电路中断服务程序 jnb12lft;P12 引脚为 0转至左测距电路中断服务程序turn:SETBX1; 开外部中断 1 pop acc po psw rtiht: . ; 右测距电路中断服务程序入口 ajm returnlef: 左测距电路中断服务程序入口 ajmpretun3.3计算超声波
6、传播时间 在启动发射电路的同时启动单片机内部的定时器 ,利用定时器的计数功能记录超声波发射的时间和收到反射波的时间。当收到超声波反射波时,接收电路 输出端产生一个负跳变,在INT0或 INT1 端产生一个中断请求信号,单片机响应外部中断请求,执行外部中断服务子程序,读取时间差,计算距离。其部分源程序如下:RECEI: PUS SW PUSH C CLR 0 ; 关外部中断0 MOV R7 TH0 ; 读取时间值 MVR TL0 CLR C MO R6 SBB A0BB; 计算时间差 MV 31H A ; 存储结果MOV R SUBB C MOV 30H ASETB EX ;开外部中断0 POP
7、 APOP SW RETI对于一个平坦的目标,距离测量包括两个阶段:粗糙的测量和精细测量。第一步:脉冲的传送产生一种简单的超声波。第二步:根据公式改变回波放大器的获得量直到回拨被检测到。第三步:检测两种回波的振幅与过零时间。第四步:设置回波放大器的所得来规格输出,假定是 3 伏。通过脉冲的周期设置下一 个脉冲。根据第二部的数据设定时间窗。第五步:发射两串脉冲产生干扰波。测量过零时间与回波的振幅。如果逆向发生在回 波中,决定要不通过在低气压插入振幅。第六步:通过公式计算距离 y。4 波测距系统的软件设计 软件分为两部分,主程序和中断服务程序。主程序完成初始化工作、各路超声波发射和接收顺序的控制。
8、定时中断服务子程序完成三方向超声波的轮流发射,外部中断服务子程序主要完成时间值的读取、距离计算、结果的输出等工作。5 对所要求测量范围 cm200m 内的平面物体做了多次测量发现,其最大误差为.5cm,且重复性好。可见基于单片机设计的超声波测距系统具有硬件结构简单、工作可靠、测量误差小等特点。因此,它不仅可用于移动机器人,还可用在其它检测系统中。思考:至于为什么接收不用晶体管做放大电路呢,因为放大倍数搞不好,集成放大电路,还带自动电平增益控制,放大倍数为 76dB,中心频率是 3 到4k,刚好是超声波传感器的谐振频率 。原文出处:传感器文摘 布拉福德:1993年 第3页摘要Ultrasonic
9、 rangig echnol has wi using wort in man fields,sucas the indutrallocal,veicleavigtio and sona enginerinNow itas eenued in lel masren,selfguied utoomous ehicls fielwork robots autotenaviain,airnduderwtetargetdetcion,idniiaion,lation so oo there is an iort practcing meaning to larn terangingtheorynd s
10、eply. o improve the prisionof th ultrsi angingyte in hnd,satisfy the eues of the engineeringpsnel fr the ranging precison,thbund d tesae,portale ltrsonicrnging syste baed on he ingle h procesr as veope1.ih the devlopment ofsnce echnolog thmrovme fpopesstadard ofliing speedingup teeelopme an osrucin
11、of te ciy. urandraiagesysm he gretly deepd hir siuatio s constat mproving. Hovru to histoical reasonaynprdcale fctor nthe syntesi ofher tie the ciyraingsystem. I artclar dranage sstem often lags bhindrban constrtion.Therefore thee ar often ldnexcvatin hbeen buidingacilites t gadetdrinagesystem phnom
12、en.Itrut to thct sewge a it s clar toteciteae andnge uler in eseage treatmnt systm.cofrt isvery imporattele lves. Moie roots digd o car the ainage ulvert automaticotro sstem ree ewag clvt clar arne robote rois dsigned to lea theclet swae t the cor. Control Sysems the co componntofhdeeopmnt ofultason
13、c rane idr. ereore t i ve iortato dsignagod utrasi angefinder.2. A principle ofultrsonidste surement2. T piciple o pieleic trasonic generatorizoeltric ultasonic enertori the ue of piezoericytal rstos wok.Ultasonic generarh intraltrcre assonitast ezoelctri ci andresonance lat. Whenit twopus s sial th
14、 frquncy equato heitinsicpolectic osciatonrequencchip h chip wllappenpeoelricresnnce apromoe h velopmnt o plate vibration reoaeultraud s eeated.Cnerselyif th twoare not ter-elcrde ltage whth orreived utrasonicesoance twill be fr viraton upess f pieoelecric chite mechacl nergy i covertto elecicl sgna
15、ls th it becoe the ultraonic recever. The taditnalay to determinehemoto teeh rval is base tresolding he reeive sial with a e referec. hthrshld hosn wel ovee ois levewhees the momnt f arriva ofeh deined ashefirst oettheech sinal urpassstahld. Tetensity of an h refectin from an objestrnglydepenson he
16、bjcts natue iznd dstance from hesesor.Futher th timeintvl fro the ehos startigoint to heoentwenisurasss th theslcanes wih the ntenit o theecho. As a cosquce a cosdabe err my occrEvn to ehoe wih dierent intnsities riving eay t e me timewillsupss hethresod at different mons.e tronge one wll suasste th
17、rehdearier anhewear so i willbe osdeeas blnig to anearerobet.2.2Thprncipleofutrascdstaneeauremen ltrsonc trasmtte in a irecio tolaunculasoun in the et aunchhegnnig o ime a te ame timeh sprad of ulrsound the ar ostacson iswayteurn immedately the utrasonic refcte wavereive by the eceiver medialstop he
18、 ck.Ultrasound n the air a the propgton vlocty f 340m / s accoding ttheirrecrs the mt ca aute the dncebetenhe aunchdtncebriershat is: s 40/3.Ulsonic angng Stem f th Secd rc Desig Syem s chaactrd bsnl-hi icocomputert conrolhse fltrasonicranmitenduroc receversince he anc fotme otime singe-hi sletiono
19、8751 economic-use andthchip 4KofROM to failtateproamig. Ciruitschmatic dira shon i Fur. ure 1 circit principl diagram 34 kH ultraonicpuse geneae wi th lah Rangng ste usng the utasonisenor ofpiezoelecticerai sensors M0its rating vlteo theplesignli 4Hzwhich by he sle-hip implemettiono thfolowing proce
20、ures to genrate.puzel: o 4h 12hultranirng ntied 20mse: pl 0 outut 4kHzquare wavno nop o djnz14 hr etRanging frn fsnle-chp tenation iruit P1 nput potsingl cipiplentaton f te bov predre the P10portin a40kHz pulse otutsn ateramplificaton trasisorT the ive t launchthe fst ulraic M40ssue 40Hzltrasoic pul
21、and he contned lunch o 200m. angig t riad he efsie fte circui reecivel the input ot1.1 ad P2 teworkig prcipl and ciut nfront thesam loaton.2 Reception and proesig o utrasonic Usedto rcee the first lnch o th frstpair UCM40R th ulrasoni pusmoduati signalinto n alternating votge he -amp ampicatio1A ana
22、terpolarizaioC1 to C2. C islockd loop ih audo decodr chipLM67 nnlvoleconleoscilltcentr frequeny of f0/1.8C3ccior C4 drmineher target bdwidth. R-coditinigin thlaunch of thearier frencyon thM57 input siga sgretrn 2mVh outut frmt hih jump 8 ee intoalow-vel iterupt reust sgnals to h singe-chip pesig.Rgi
23、ng nfont f singlechitemitinciuitotpu ort INT0interrpt hehighestpioriy righ r eft lio ofh otput crcu withoutpu gae IA accesIN1 pr single-ch while single-hip P1. nd P1.4 ceived inp IC3 itrrupted byteroces idntif thesource oiquiryodea wth tptpiritylevlfor hfrteft rg e. Pt o the source code isas follws:
24、reeive1: us pw puscr ex1 reled etenalnup 1 jn p1.right P.1 pin t 0 rangng fo right interru servicerutne ciuit jb 1.2 lef P12pinto 0to te lf ranging ircuit nerrptservc outinerturn: SET E1 open extena interp 1op ac pop psw retirigt: . igocain ennce crcuititerutrviceroin Ajmp eurnlft: . eft Rangig etnccirut itrup rvie oti jmp Return. The calcutin of ltrsoc propagatin tme When yousart fringath ameimtart the sglechip circuiywthin etimerT0th e of im cting function recor the tim and the lac o ulranirele waereeived tme Whn yureceive the ultrasoic efleeve the eccuit utpus