在啟動發(fā)射電路的同時啟動單片機內部的定時器T0,利用定時器的計數(shù)功能記錄超聲波發(fā)射的時間和收到反射波的時間。當收到超聲波反射波時,接收電路輸出端產生一個負跳變,在INT0或INT1端產生一個中斷請求信號,單片機響應外部中斷請求,執(zhí)行外部中斷服務子程序,讀取時間差,計算距離。其部分源程序如下:
RECEIVE0: PUSH PSWThis invention relates to apparatus for themeasurement of distance and, more particularly, to such apparatus whichtransmits ultrasonic waves between two points. Precision machine tools must becalibrated. In the past, this has been accomplished utilizing mechanicaldevices such as calipers, micrometers, and the like. However, the use of suchdevices does not readily lend itself to automation techniques. It is known thatthe distance between two points can be determined by measuring the propagationtime of a wave travelling between those two points. One such type of wave is anultrasonic, or acoustic, wave. When an ultrasonic wave travels between two points,the distance between the two points can be measured by multiplying the transittime of the wave by the wave velocity in the medium separating the two points.It is therefore an object of the present invention to provide apparatusutilizing ultrasonic waves to accurately measure the distance between twopoints.
When the medium between the two points whose spacingis being measured is air, the sound velocity is dependent upon the temperatureand humidity of the air. It is therefore a further object of the,presentinvention to provide apparatus of the type described which is independent oftemperature and humidity variations.
B.SUMMARY OF THE INVENTIONThe foregoing and additional objects are attained inaccordance with the principles of this invention by providing distancemeasuring apparatus which includes a reference unit and a measuring unit. Thereference and measuring units are the same and each includes an electroacoustictransmitter and an electroacoustic receiver. The spacing between the transmitterand the receiver of the reference unit is a fixed reference distance, whereasthe spacing between the transmitter and receiver of the measuring unit is thedistance to be measured. In each of the units, the transmitter and receiver arecoupled by a feedback loop which causes the transmitter to generate an acousticpulse which is received by the receiver and converted into an electrical pulsewhich is then fed back to the transmitter, so that a repetitive series ofpulses results. The repetition rate of the pulses is inversely related to thedistance between the transmitter and the receiver. In each of the units, thepulses are provided to a counter. Since the reference distance is known, theratio of the counter outputs is utilized to determine the desired distance tobe measured. Since both counts are identically influenced by temperature andhumidity variations, by taking the ratio of the counts, the resultantmeasurement becomes insensitive to such variations.
C.DETAILED DESCRIPTIONPiezoelectric ultrasonic generator is the use ofpiezoelectric crystal resonators to work. Ultrasonic generator, the internalstructure as shown in Figure 1, it has two piezoelectric chip and a resonanceplate. When it's two plus pulse signal, the frequency equal to the intrinsicpiezoelectric oscillation frequency chip, the chip will happen piezoelectricresonance, and promote the development of plate vibration resonance, ultrasoundis generated. Conversely, if the two are not inter-electrode voltage, when theboard received ultrasonic resonance, it will be for vibration suppression ofpiezoelectric chip, the mechanical energy is converted to electrical signals,then it becomes the ultrasonic receiver.
The traditional way to determine the moment of the echo'sarrival is based on thresholding the received signal with a fixed reference.The threshold is chosen well above the noise level, whereas the moment ofarrival of an echo is defined as the first moment the echo signal surpassesthat threshold. The intensity of an echo reflecting from an object stronglydepends on the object's nature, size and distance from the sensor. Further, thetime interval from the echo's starting point to the moment when it surpassesthe threshold changes with the intensity of the echo. As a consequence, aconsiderable error may occur Even two echoes with different intensitiesarriving exactly at the same time will surpass the threshold at differentmoments. The stronger one will surpass the threshold earlier than the weaker,so it will be considered as belonging to a nearer object.
2.the principle of ultrasonic distance measurementUltrasonic transmitter in a direction to launchultrasound, in the moment to launch the beginning of time at the same time, thespread of ultrasound in the air, obstacles on his way to return immediately,the ultrasonic reflected wave received by the receiver immediately stop theclock. Ultrasound in the air as the propagation velocity of 340m / s, accordingto the timer records the time t, we can calculate the distance between thelaunch distance barrier (s), that is: s = 340t / 2
B. Ultrasonic Ranging System for the Second CircuitDesign
System is characterized by single-chip microcomputerto control the use of ultrasonic transmitter and ultrasonic receiver since thelaunch from time to time, single-chip selection of 8751, economic-to-use, andthe chip has 4K of ROM, to facilitate programming. Circuit schematic diagramshown in Figure 2. Draw only the front range of the circuit wiring diagram,left and right in front of Ranging Ranging circuits and the same circuit, it isomitted.
1.40 kHz ultrasonic pulse generated with the launchRanging system using the ultrasonic sensor ofpiezoelectric ceramic sensors UCM40, its operating voltage of the pulse signalis 40kHz, which by the single-chip implementation of the following proceduresto generate.
puzel: mov 14h, # 12h; ultrasonic firingcontinued 200msRanging in front of single-chip termination circuitP1.0 input port, single chip implementation of the above procedure, the P1.0port in a 40kHz pulse output signal, after amplification transistor T, thedrive to launch the first ultrasonic UCM40T, issued 40kHz ultrasonic pulse, andthe continued launch of 200ms. Ranging the right and the left side of thecircuit, respectively, then input port P1.1 and P1.2, the working principle andcircuit in front of the same location.
2.reception and processing of ultrasonicUsed to receive the first launch of the first pairUCM40R, the ultrasonic pulse modulation signal into an alternating voltage, theop-amp amplification IC1A and after polarization IC1B to IC2. IC2 is lockedloop with audio decoder chip LM567, internal voltage-controlled oscillatorcenter frequency of f0 = 1/1.1R8C3, capacitor C4 determine their targetbandwidth. R8-conditioning in the launch of the carrier frequency on the LM567input signal is greater than 25mV, the output from the high jump 8 feet into alow-level, as interrupt request signals to the single-chip processing.
Ranging in front of single-chip termination circuitoutput port INT0 interrupt the highest priority, right or left location of theoutput circuit with output gate IC3A access INT1 port single-chip, whilesingle-chip P1.3 and P1. 4 received input IC3A, interrupted by the process toidentify the source of inquiry to deal with, interrupt priority level for thefirst left right after. Part of the source code is as follows:
receive1: push pswWhen you start firing at the same time start thesingle-chip circuitry within the timer T0, the use of timer counting functionrecords the time and the launch of ultrasonic reflected wave received time.When you receive the ultrasonic reflected wave, the receiver circuit outputs anegative jump in the end of INT0 or INT1 interrupt request generates a signal,single-chip microcomputer in response to external interrupt request, theimplementation of the external interrupt service subroutine, read the timedifference, calculating the distance . Some of its source code is as follows:
RECEIVE0: PUSH PSWFor a flattarget, a distance measurement consists of two phases: a coarse measurementand. 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 theecho is detected.
Step 3:Detection of the amplitudes and zero-crossing times of both echoes.
Step 4:Setting the gains of both echo amplifiers to normalize the output at, say 3volts. Setting the period of the next pulses according to the : period ofechoes. Setting the time window according to the data of step 2.
Step 5:Sending two pulse trains to produce an interfered wave. Testing thezero-crossing times and amplitudes of the echoes. If phase inversion occurs inthe echo, determine to otherwise calculate to by interpolation using theamplitudes near the trough. Derive t sub m1 and t sub m2 .
Step 6:Calculation of the distance y using equation .
D. Fourth, the ultrasonicranging system software design
Software is divided into two parts, the main programand interrupt service routine, shown in Figure 3 (a) (b) (c) below. Completionof the work of the main program is initialized, each sequence of ultrasonictransmitting and receiving control.
Interrupt service routines from time to time tocomplete three of the rotation direction of ultrasonic launch, the mainexternal interrupt service subroutine to read the value of completion time,distance calculation, the results of the output and so on..
System initialization after the start timer T1 startscounting from 0 to enter the main program to wait for the T1 overflow into theT1 interrupt service routine when the time is reached; T1 interrupt serviceroutine will start a new ultrasonic transmitting, the square wave will begenerated in the P1.0 pin at the same time open the timer T0 timing, in orderto avoid the diffraction of the direct wave, the delay 1ms and then, after theINT0 interrupt Enable; the INT0 interrupt to allow open, if thisoccurs when thelow is representative of the received echo signal, the interrupt request toINT0 interrupt service routine, the INT0 interrupt service routine will stopthe timer T0 timing, read the time value of T0 timer to the appropriate storagearea.set to receive a sign of success; main program detects reception hallmarksof success, the temperature subroutine is called, collecting the ambienttemperature when the ultrasonic ranging, and converted the accurate speed ofsound stored in RAM storage unit; SCM calls the distance calculationsubroutineto calculate, calculate the distance between the sensor to the target object;since the main program calls the display subroutine to display; aftercompletion of the first launch, receive, display, the system will delay 100msre-T1 set initial value againstart T1 to overflow into the next ranging. If theobstacle is too far beyond the range that T0 overflow has not yet received echo"ERROR" is displayed back to the main flow into a new round of tests.
E. CONCLUSIONSRequired measuring range of 30cm ~ 200cm objectsinside the plane to do a number of measurements found that the maximum error is0.5cm, and good reproducibility. Single-chip design can be seen on theultrasonic ranging system has a hardware structure is simple, reliable, smallfeatures such as measurement error. Therefore, it can be used not only formobile robot can be used in other detection systems.
Thoughts: As for why the receiver do not have thetransistor amplifier circuit, because the magnification well, CX20106integrated amplifier, but also with automatic gain control level, magnificationto 76dB, the center frequency is 38k to 40k, is exactly resonant ultrasonicsensors frequency.
歡迎光臨 (http://www.zg4o1577.cn/bbs/) | Powered by Discuz! X3.1 |