【正文】
機(jī)編程產(chǎn)生超聲波,在系統(tǒng)發(fā)射超聲波的同時(shí)利用定時(shí)器的計(jì)數(shù)功能開始計(jì)時(shí),接收到回波后,接收電路輸出端產(chǎn)生的負(fù)跳變?cè)趩纹瑱C(jī)的外部中斷源輸入口產(chǎn)生一個(gè)中斷請(qǐng)求信號(hào) ,響應(yīng)外部中斷請(qǐng)求,執(zhí)行外部中斷服務(wù)子程序,停止計(jì)時(shí),讀取時(shí)間差,計(jì)算距離,然后通過軟件譯碼,將數(shù)據(jù)輸出 P0、 P1和 P2口顯示。 程序流程圖如圖 16所示 。經(jīng)過擬合 , 我們得到下面的方程 : y= ( 其中 : y 為實(shí)際值 , x 為測量值 )修正后本超聲波測距系統(tǒng)測量值與實(shí)際值的對(duì)應(yīng)關(guān)系如表 3 所示 : 障礙物 實(shí)際距離 ( cm) 測量 距離( cm) 45 60 75 100 125 150 175 200 表 3 修正后超聲測距系統(tǒng)測量值與實(shí)際值 ( 單位 : cm) 從修正后的數(shù)據(jù)我們可以看出 , 系統(tǒng)的 測量誤差在177。 超聲波傳感器是本系統(tǒng)的核心器件,本論文詳細(xì)地介紹了超聲波傳感器的原理、結(jié)構(gòu)、檢測方式以及它的一些特性。通過對(duì)單片機(jī)產(chǎn)生的方波信號(hào)進(jìn)行放大,以驅(qū)動(dòng)傳感器工作。 本課題所設(shè)計(jì)的超聲波測距系統(tǒng)具有測量精度較高、速度快、控制簡單方便等優(yōu)點(diǎn)。但由于經(jīng)驗(yàn)不足,電路硬件、軟件部分都有不夠完善的地方,在今后的學(xué)習(xí)中會(huì)進(jìn)一步改進(jìn)。這些對(duì)我今后的學(xué)習(xí)和工作都會(huì)有很大幫助的。 通過這次畢業(yè)設(shè)計(jì),使我深刻地認(rèn)識(shí)到學(xué)好專業(yè)知識(shí)的重要性,也理解了理論聯(lián)系實(shí)際的含義,并且檢驗(yàn)了大學(xué)四年的學(xué)習(xí)成果。 也 感謝在畢 業(yè) 設(shè) 計(jì) 中幫助過我的所有同學(xué)和師兄師姐們 ,感謝你們 對(duì)我的支持 。_nop_() define uchar unsigned char define uint unsigned int define ulong unsigned long /*************************************** 位定義 ****************************************/ sbit csb=P3^6。 bit flag_1=0。 uint count=0。 ulong dis,dis_4[3]。 temp*=speed。(dis_1100)) { n=dis_1/10。break。 } else { n=dis_1/100。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。 TL0=0。i) { csb=!csb。 nop。 nop。 EX1=1。 flag=0。 TL0=0。i) { csb=!csb。 nop。 nop。 EX1=1。 flag=0。 TL0=0。i) { csb=!csb。 nop。 nop。 EX1=1。 flag=0。 green=0。//send_(16)。 } else { if((dis_s500)amp。yellow=0。 } flag_2=2。red=0。 while(!busy)。 29 } flag_2=3。green=1。 if(dis_4[0]dis) dis=dis_4[0]。 P0 = 0xff。 TH0=0。 displayall()。 if(dis==0) { tran1()。 } fit_1()。 } } else time=dis。 temp_all()。j4。j4。 TR0=0。 if((temp0)amp。 } else { high_time=0。 ultrasonic sensors。 } } 32 The Research about Fuzzy Collision Avoidance in Ultrasonic Ranging Robots Electronic and Information Engineering ******* Tutor ***** Abstract: When mobile robots working, it interfere inevitably by obstructions, obstacles will affect seriously in the efficiency of the robot, serious collide may make the robots breakage, so it is very important to achieve the robot avoided obstacle automatic. This paper based on the mon use of sensors , analyzes the intelligent mobile robot how to obstacle avoidance, based on ultrasonic sensor, proposed a system about the fuzzy distance of the mobile robot obstacle avoidance, and write up in details about the principles and characteristics of ultrasonic sensors, the core used is AT89C52 MCU and let ultrasonic range finder to detect obstacles, through the signal processing on MCU, motordriven steering the azimuth, make it turn left ,right ,go and back, so as to achieve the function about the automatic obstacle avoidance . Study through the practice is easy to accept and understand of fuzzy control mechanism and strategy for obstacle avoidance, it will more convenient for application and development, fuzzy obstacle avoidance algorithm has great adaptability to the environment, the robot can be achieved the obstacle avoidance under different environmental conditions. Key words: AT89C52 microcontroller。(temp30000)) { high_time=TH0。 flag=1。 delay(100)。 lcd_pos(1,6)。 lcd_pos(1,6)。 if(tc_say==4) { soundplay(time)。 else { if((timedis)2500) time=dis。} } dis=do_s(dis)。i3。 EA=1。 P2 = 0xff。 } /*************************************** 函數(shù)名: void main(void) 功能:主函數(shù) ****************************************/ void main(void) { data ulong time。red=1。 yellow=1。 delay_nms(50)。 if(flag_2!=3) { send_(19)。(dis_s500)) { show_one(DIS6,2)。 delay_nms(50)。 green=1。 while(!busy)。yellow=1。 } /*************************************** 函數(shù)名: void dis_all(ulong dis_s) 28 功能:控制 LED 指示燈 ****************************************/ void dis_all(ulong dis_s) { show(dis_s)。 if(flag==1) { distance=Distance_count()。 } csb=1。 nop。 nop。 for(i=16。 } void tran2() { uchar i。 if(flag==1) { distance=Distance_count()。 } 27 csb=1。 nop。 nop。 for(i=8。 } void tran1() { uchar i。 if(flag==1) { distance=Distance_count()。 } csb=1。 nop。 nop。 for(i=4。 } } /*************************************** 函數(shù)名: void tran(), void tran1(), void tran2() 功能:超聲波的發(fā)射 ****************************************/ void tran() { uchar i。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。break。 } /*************************************** 函數(shù)名: ulong do_s(ulong dis_1) 功能:距離補(bǔ)償 ****************************************/ ulong do_s(ulong dis_1) { uchar n。 temp=high_time*256+low_time。 uchar flag_2=0。 uint speed=340。 sbit yellow=P2^4。 參考文獻(xiàn) [1] 沙愛軍 . 基于單片機(jī)的超聲波測距系統(tǒng)的研究與設(shè)計(jì) [J].北京 :電子科技 ,2021(11). [2] 宋長套 ,趙國象 ,任領(lǐng) . 移動(dòng)機(jī)器人超聲波避碰傳感器系統(tǒng)設(shè)計(jì) [J ].計(jì)算機(jī)測量與控制 ,2021,(12) . [3] 李淑萍 . 基于單片機(jī) AT89S52的超聲波測距系統(tǒng)的設(shè)計(jì) [J].北京 :自動(dòng)化與儀器儀表 ,2021(3). [4] 王維斌 . 超聲波測距系統(tǒng)的設(shè)計(jì) [J].北京 :電子技術(shù) ,2021(6) . [5] 陳春林 ,陳宗海 ,卓奮基于多超聲波傳感器的自主移動(dòng)機(jī)器人探測系統(tǒng) [J].測控技術(shù) ,2021,23(6). [6] 栗桂鳳 ,周東輝 ,王光聽 .