Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer

Publisher:沈阳阿荣Latest update time:2016-11-07 Source: elecfansKeywords:AT89S52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  Ultrasonic waves are mechanical waves with a frequency of more than 20KHz, and their propagation speed in the air is about 340 m/s (at 20°C). Ultrasonic waves can be generated by ultrasonic sensors. There are two common types of ultrasonic sensors: one is to generate ultrasonic waves electrically, and the other is to generate ultrasonic waves mechanically. Currently, piezoelectric ultrasonic sensors are more commonly used. Ultrasonic waves are widely used in non-destructive testing, distance measurement, distance switches, car reversing collision avoidance, intelligent robots and other fields because they are easy to transmit in a directional manner, have good directionality, are easy to control intensity, are insensitive to color and light intensity, and have high reflectivity.

  The overall block diagram of this design is shown in the figure. It is mainly composed of ultrasonic emission, ultrasonic reception and signal conversion, button display circuit and temperature sensor circuit. Ultrasonic ranging is to measure the time difference T between the emission and reception of echoes by continuously detecting the echo reflected by obstacles after the ultrasonic emission, and then calculate the distance S=CT/2, where C is the ultrasonic wave speed. At room temperature, the speed of sound in air is about 340m/s. Since ultrasonic waves are also a kind of sound waves, their propagation speed C is related to temperature. When used, if the temperature does not change much, the sound speed can be considered to be basically unchanged. Because the ranging accuracy of this system is very high, the propagation speed of ultrasonic waves is corrected by detecting the temperature. After the ultrasonic propagation speed is determined, the distance can be calculated by measuring the round-trip time of the ultrasonic wave. This is the basic principle of the ultrasonic ranging system.

  Ultrasonic signal transmitting and receiving circuit

Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer

  The transmitting circuit is shown in Figure 3, which is mainly composed of a pulse modulation signal generating circuit, an isolation circuit and a driving circuit, and is used to provide a transmitting signal for the ultrasonic sensor. In the pulse modulation signal generating circuit, the 555 timer works in time-sharing mode by controlling the reset (RESET) terminal of the 555 through the single-chip microcomputer, thereby generating a pulse modulation signal with a pulse frequency of 40KHz and a period of 30ms. The signal waveform is shown in Figure 2. In this design, 10 pulse signals are sent in one cycle. The isolation circuit is mainly composed of two NAND gates to isolate the output stage from the pulse generating circuit. The output stage is composed of two general-purpose integrated operational amplifiers TL084CN. Since the transmission distance of the ultrasonic sensor is proportional to the voltage applied at its two ends, the circuit is required to generate a sufficiently large driving voltage. Its basic principle is a comparison circuit. When the input signal is greater than 2.5V, the output voltage of operational amplifier A VA=+12V, and the output voltage of operational amplifier B VB=-12V. When the input signal is 2.5V, the output voltage of operational amplifier A VA="-12V", and the output voltage of operational amplifier B VB=+12V. Therefore, two symmetrical waveforms with completely opposite polarities are obtained at both ends of the ultrasonic sensor, that is, VB=-VA. Therefore, the voltage applied to both ends of the ultrasonic sensor is V=VA-VB=2VA, and the voltage at both ends can reach 24V, thereby ensuring that the ultrasonic wave can be transmitted over a longer distance and improving the measurement range.

  The receiving circuit consists of an amplifier circuit, a bandpass filter circuit and a signal conversion circuit. The amplifier circuit and the bandpass filter circuit are shown in Figure 4. Since the ultrasonic signal is greatly attenuated when propagating in the air, the reflected ultrasonic signal is very weak and cannot be directly sent to the subsequent circuit for processing. The signal must be amplified to a sufficient amplitude so that the subsequent circuit can process it correctly. The preamplifier circuit is a bootstrap in-phase AC amplifier circuit composed of an integrated operational amplifier with a very high input impedance. C5, C6, and C7 are DC blocking capacitors, and R5, R6, and R7 are bias resistors used to set the static operating point of the amplifier. The bandpass filter uses a second-order RC active filter to eliminate the influence of interference signals during ultrasonic propagation.
 

  Amplifier circuit and bandpass filter circuit

  As shown in Figure 4 below, this circuit is a second-order voltage-controlled voltage source bandpass filter circuit. In the figure, RW and C10 form a low-pass filter network, and C9 and R12 form a high-pass filter network. The two are connected in series to form a bandpass filter circuit. The integrated operational amplifier and resistors R9 and R10 together form a common-phase proportional amplifier. In order to make the circuit work stably, the gain of the common-phase proportional amplifier must be guaranteed. The center frequency of the bandpass filter ω0=40kHz, and the circuit parameters can be determined by AV=1+R9/R10 and ω0=1/R12C2 (1/RW+1/R13). The signal after bandpass filtering is amplified by a dedicated instrument amplifier AD620 and then sent to the signal conversion circuit. The signal conversion circuit mainly converts the received envelope signal into an interrupt trigger signal of the single-chip microcomputer. It consists of an envelope detection circuit, a voltage comparator and an RS trigger. The envelope detection circuit consists of a diode D3, a resistor R19, and a capacitor C13. The signal obtained after envelope detection is shown as V2 in Figure 6. The voltage comparator is composed of an integrated operational amplifier and a capacitor and resistor. In order to eliminate the interference signal of the transmitting probe, we add the signal output by the single chip P1.2 to the in-phase end of the voltage comparator. Its waveform is a high level of 250μs and a low level square wave of 29750μs. P1.2 and the positive end of the comparator are isolated by diode D3. When P1.2 outputs a high level, the capacitor C14 is charged through the diode. Since the diode is forward-conducting, the charging is very fast. When P1.2 outputs a low level, the diode is reversely cut off, and the capacitor is discharged through resistors RW and R21. Since the total resistance is relatively large, the discharge is very slow. The waveform is shown as V3 in Figure 6. It can be seen from the figure that when no return signal is received, the comparator outputs a high level. If a return signal is received, the comparator outputs a low level. The output waveform is shown as Vo in Figure 6. This method can eliminate the interference of the transmitting probe on the reflected signal.

Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer

  When the ultrasonic signal is sent from the transmitter, P1.2 outputs a high level, and after passing through the inverter, it becomes a low level and is added to the R end of the trigger. Because the voltage comparator outputs a high level before receiving the reflected signal, the input of the basic RS trigger is R=O, S=1, which is 0 state, that is, Q=0, Q=1, and Q signal is added to the interrupt input of the microcontroller. Because the interrupt of the microcontroller is triggered by the falling edge, the input is high level and no interrupt is generated. When the transmission is completed, P1.2 outputs a low level, and after passing through the inverter, it becomes a high level and is sent to the R end of the trigger. When the reflected signal is not received, the voltage comparator output is still high level, so the basic RS trigger R=“1”, S=1, is in the hold state, that is, Q=1, Q=0, and no interrupt is generated. When the reflected signal is received, the voltage comparator outputs a low level, so the input of the basic RS trigger R=“1”, S=0, the trigger works in 0 state, that is, Q=O, Q=1. The level of the interrupt input terminal of the microcontroller changes from high level to low level, causing the microcontroller to generate an interrupt.

Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer

Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer

  The peripheral circuit diagram of the single-chip microcomputer is shown in Figure 7. The display circuit is controlled by the single-chip microcomputer to display the seven-segment digital tube. The digital temperature sensor DS18820 is used to detect the ambient temperature, so as to perform temperature compensation on the propagation speed of the ultrasonic wave and improve the measurement accuracy. Two buttons are used to control the start and stop of the measurement and the switching of the distance and temperature display.

  Due to the transmission power and ultrasonic transmitter probe, the measurement distance of this system is between 10cm and 500cm. There are large errors in close-range and long-range measurements. The accuracy is best when measuring between 50cm and 200cm, and the error is no more than 1cm. In this design, since the ultrasonic transmission cycle is 10 square waves of 25μs, the transmission time is T=250μs. It is known that the sound speed C at room temperature is 340m/s, so S=CT/2=250μs/2=8.5cm, so the ranging blind area is confirmed to be 9cm. That is, when the measurement distance is less than 9cm, it cannot be measured correctly.

Keywords:AT89S52 Reference address:Circuit Design of Ultrasonic Distance Measurement System Based on AT89S52 Single Chip Microcomputer

Previous article:Flow monitoring system signal measurement electronic circuit
Next article:Application of Single Chip Microcomputer in Inverted Pendulum Control System

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号