【正文】
因此,它不僅可用于移動(dòng)機(jī)器人,還可用在其它檢測(cè)系統(tǒng)中。系統(tǒng)初始化后就啟動(dòng)定時(shí)器T1從0開(kāi)始計(jì)數(shù),此時(shí)主程序進(jìn)入等待,當(dāng)?shù)竭_(dá)定時(shí)時(shí)間時(shí)T1溢出進(jìn)入T1中斷服務(wù)子程序;在T1中斷服務(wù)子程序中將啟動(dòng)一次新的超聲波發(fā)射,同時(shí)開(kāi)啟定時(shí)器T0計(jì)時(shí),為了避免直射波的繞射,需要延遲1ms后再開(kāi)INT0中斷允許;INT0中斷允許打開(kāi)后,若此時(shí)出現(xiàn)低電平則代表收到回波信號(hào),將提出中斷請(qǐng)求進(jìn)入INT0中斷服務(wù)子程序,在INT0中斷服務(wù)子程序中將停止定時(shí)器T0計(jì)時(shí),讀取定時(shí)器T0時(shí)間值到相應(yīng)的存儲(chǔ)區(qū),同時(shí)設(shè)置接收成功標(biāo)志;主程序一旦檢測(cè)到接收成功標(biāo)志,將調(diào)用測(cè)溫子程序,采集超聲波測(cè)距時(shí)的環(huán)境溫度,并換算出準(zhǔn)確的聲速,存儲(chǔ)到RAM存儲(chǔ)單元中;單片機(jī)再調(diào)用距離計(jì)算子程序進(jìn)行計(jì)算,計(jì)算出傳感器到目標(biāo)物體之間的距離;此后主程序調(diào)用顯示子程序進(jìn)行顯示;當(dāng)一次發(fā)射、接收、顯示的過(guò)程完成后,系統(tǒng)將延遲100ms重新讓T1置初值,再次啟動(dòng)T1以溢出,進(jìn)入下一次測(cè)距。第六步:通過(guò)公式計(jì)算距離y。根據(jù)第二部的數(shù)據(jù)設(shè)定時(shí)間窗。第二步:根據(jù)公式改變回波放大器的獲得量直到回?fù)鼙粰z測(cè)到。部分源程序如下:receive1:push psw push acc clr ex1 ; 關(guān)外部中斷1 jnb , right ; ,轉(zhuǎn)至右測(cè)距電路中斷服務(wù)程序 jnb , left ; ,轉(zhuǎn)至左測(cè)距電路中斷服務(wù)程序return: SETB EX1; 開(kāi)外部中斷1 pop acc pop psw retiright: ... ; 右測(cè)距電路中斷服務(wù)程序入口 ajmp returnleft: ... ; 左測(cè)距電路中斷服務(wù)程序入口 ajmp return計(jì)算超聲波傳播時(shí)間在啟動(dòng)發(fā)射電路的同時(shí)啟動(dòng)單片機(jī)內(nèi)部的定時(shí)器T0,利用定時(shí)器的計(jì)數(shù)功能記錄超聲波發(fā)射的時(shí)間和收到反射波的時(shí)間。超聲波的接收與處理接收頭采用與發(fā)射頭配對(duì)的UCM40R,將超聲波調(diào)制脈沖變?yōu)榻蛔冸妷盒盘?hào),經(jīng)運(yùn)算放大器IC1A和IC1B兩極放大后加至IC2。其中只畫(huà)出前方測(cè)距電路的接線圖,左側(cè)和右側(cè)測(cè)距電路與前方測(cè)距電路相同,故省略之。強(qiáng)度較強(qiáng)的脈沖會(huì)比強(qiáng)度較弱的脈沖超過(guò)界限的時(shí)間早點(diǎn),因此我們會(huì)認(rèn)為強(qiáng)度較強(qiáng)的脈沖屬于較近的物體。這個(gè)界限恰恰選于噪音水平之上,然而脈沖到達(dá)時(shí)間被定義為脈沖信號(hào)剛好超過(guò)界限的第一時(shí)刻。超聲波發(fā)生器內(nèi)部結(jié)構(gòu)如下所示,它有兩個(gè)壓電晶片和一個(gè)共振板。在每一個(gè)單位,脈沖提供一個(gè)反饋。參考和測(cè)量單位是相同的,每個(gè)包括一個(gè)超聲波發(fā)射機(jī)和一個(gè)接收機(jī)。因此,本發(fā)明提供儀器利用超聲波來(lái)精確測(cè)量?jī)牲c(diǎn)之間的距離對(duì)象。不過(guò),使用這種裝置并不利于本身的自動(dòng)化技術(shù)發(fā)展。該脈沖序列提供給各自的計(jì)數(shù)器,計(jì)數(shù)器的產(chǎn)出的比率,是用來(lái)確定被測(cè)量的距離。 SCM calls the distance calculationsubroutine to calculate, calculate the distance between the sensor to the target object。 open external interrupt 0 POP ACC POP PSW RETI For a flat target, a distance measurement consists of two phases: a coarse measurement and. a fine measurement:Step 1: Transmission of one pulse train to produce a simple ultrasonic wave.Step 2: Changing the gain of both echo amplifiers according to equation , until the echo is detected.Step 3: Detection of the amplitudes and zerocrossing times of both echoes.Step 4: Setting the gains of both echo amplifiers to normalize the output at, say 3 volts. Setting the period of the next pulses according to the : period of echoes. Setting the time window according to the data of step 2.Step 5: Sending two pulse trains to produce an interfered wave. Testing the zerocrossing times and amplitudes of the echoes. If phase inversion occurs in the echo, determine to otherwise calculate to by interpolation using the amplitudes near the trough. Derive t sub m1 and t sub m2 .Step 6: Calculation of the distance y using equation ., the ultrasonic ranging system software design Software is divided into two parts, the main program and interrupt service routine, shown in Figure 3 (a) (b) (c) below. Completion of the work of the main program is initialized, each sequence of ultrasonic transmitting and receiving control. Interrupt service routines from time to time to plete three of the rotation direction of ultrasonic launch, the main external interrupt service subroutine to read the value of pletion time, distance calculation, the results of the output and so on..System initialization after the start timer T1 starts counting from 0 to enter the main program to wait for the T1 overflow into the T1 interrupt service routine when the time is reached。 related external interrupt 0 MOV R7, TH0。 pin to 0, to the left ranging circuit interrupt service routine return: SETB EX1。 djnz 14h, here。 ultrasonic firing continued 200ms here: cpl 。s two plus pulse signal, the frequency equal to the intrinsic piezoelectric oscillation frequency chip, the chip will happe