【正文】
ervice subroutine, read the time difference, calculating the distance . Some of its source code is as follows: RECEIVE0: PUSH PSW PUSH ACC CLR EX0。 storage results MOV A, R7 SUBB A, 3CH MOV 30H, A? SETB EX0。 read the time value MOV R6, TL0? CLR C MOV A, R6 SUBB A, 0BBH。 open external interrupt 1 pop? acc pop? psw reti right: ...?。 ret Ranging in front of singlechip termination circuit input port, single chip implementation of the above procedure, the port in a 40kHz pulse output signal, after amplification transistor T, the drive to launch the first ultrasonic UCM40T, issued 40kHz ultrasonic pulse, and the continued launch of 200ms. Ranging the right and the left side of the circuit, respectively, then input port and , the working principle and circuit in front of the same location. 2, reception and processing of ultrasonic Used to receive the first launch of the first pair UCM40R, the ultrasonic pulse modulation signal into an alternating voltage, the opamp amplification IC1A and after polarization IC1B to IC2. IC2 is locked loop with audio decoder chip LM567, internal voltagecontrolled oscillator center frequency of f0 = 1/, capacitor C4 determine their target bandwidth. R8conditioning in the launch of the carrier frequency on the LM567 input signal is greater than 25mV, the output from the high jump 8 feet into a lowlevel, as interrupt request signals to the singlechip processing. Ranging in front of singlechip termination circuit output port INT0 interrupt the highest priority, right or left location of the output circuit with output gate IC3A access INT1 port singlechip, while singlechip and P1. 4 received input IC3A, interrupted by the process to identify the source of inquiry to deal with, interrupt priority level for the first left right after. Part of the source code is as follows: receive1: push psw push acc clr ex1。 output 40kHz square wave nop。 思考:至于為什么接收不用晶體管做放大電路呢,因為放大倍數(shù)搞不好, CX20216集成放大電路,還帶自動電平增益控制,放大倍數(shù)為 76dB,中心頻率是 38k到 40k,剛好是超聲波傳感器的諧振頻率 。 定時中斷服務(wù)子程序完成三方向超聲波的輪流發(fā)射,外部中斷服務(wù)子程序主要完成時間值的讀取、距離計算、結(jié)果的輸出等工作。部分源程序如下: receive1: push psw push acc clr ex1 ; 關(guān)外部中斷 1 jnb , right ; 引腳為 0,轉(zhuǎn)至右測距電路中斷服務(wù)程序 jnb , left ; 引腳為 0,轉(zhuǎn)至左測距電路中斷服務(wù)程序 return: SETB EX1; 開外部中斷 1 pop? acc pop? psw reti right: ...? ; 右測距電路中斷服務(wù)程序入口 ? ajmp? return left: ... ; 左