1. Ultrasonic sensor and its ranging principle
Ultrasonic waves refer to mechanical waves with a frequency higher than 20 kHz [1]. In order to use ultrasonic waves as a detection method, it is necessary to generate and receive ultrasonic waves. The device that performs this function is an ultrasonic sensor, usually called an ultrasonic transducer or ultrasonic probe. An ultrasonic sensor has a transmitter and a receiver, but an ultrasonic sensor can also have the dual function of sending and receiving sound waves. Ultrasonic sensors use the principle of piezoelectric effect [1] to convert electrical energy and ultrasonic waves into each other. That is, when emitting ultrasonic waves, electrical energy is converted to emit ultrasonic waves; and when receiving echoes, ultrasonic vibrations are converted into electrical signals.
The principle of ultrasonic ranging generally uses the time of flight method TOF (time of flight) [2]. First, the time it takes for the ultrasonic wave to be emitted and return after encountering an obstacle is measured, and then multiplied by the speed of the ultrasonic wave to obtain twice the distance between the sound source and the obstacle, that is,
2. Hardware circuit design
The ultrasonic distance measurement system we designed is composed of Polaroid 600 series sensor, Polaroid 6500 series ultrasonic distance module and AT89C51 single chip.
2.1 Polaroid 600 Series Sensors
This ultrasonic sensor is a sensor that integrates transmission and reception. There is a circular sheet inside the sensor. The sheet is made of plastic, with a metal film coated on the front and an aluminum back plate on the back. The sheet and the back plate form a capacitor. When a square wave voltage of 49.4kHz and 300VAC pk-pk is applied to the sheet, the sheet vibrates at the same frequency, thereby generating ultrasonic waves with a frequency of 49.4kHz. When receiving echoes, there is a tuning circuit in the Polaroid 6500 so that only signals with frequencies close to 49.4kHz can be received, while signals of other frequencies are filtered out.
The ultrasonic wave sent by the Polaroid 600 ultrasonic sensor has a beam angle of 30 degrees [3], as shown in Figure 1:
Ultrasonic sensors can be used as both transmitters and receivers. The sensor transmits a series of ultrasonic beams over a period of time. The reception can only be started after the transmission is completed. If the time for transmitting the beam is D, the signal reflected from the object within D time cannot be captured. In addition, the ultrasonic sensor has a certain inertia, and there is still a certain amount of residual vibration after the transmission is completed. This residual vibration also generates a voltage signal through the transducer, disrupting the system's work of capturing the return signal. Therefore, before the residual vibration disappears, the system cannot be started for echo reception. The above two reasons cause the ultrasonic sensor to have a certain measurement range. This ultrasonic wave can measure 37cm at the closest.
2.2 Polaroid 6500 Series Ultrasonic Distance Module
The hardware circuit of the Polaroid 6500 series ultrasonic distance module is shown in Figure 2:
Figure 2 Hardware circuit of Polaroid 6500 series ultrasonic distance module [page]
TL851 is an economical digital 12-step distance control integrated circuit. There is a 420KHz ceramic crystal inside. When the 6500 series ultrasonic distance module starts working, in the first 16 cycles of transmission, the ceramic crystal is divided by 8.5 to form a 49.4KHz ultrasonic signal, which is then transmitted to the ultrasonic sensor through transistor Q1 and transformer T1. After transmission, the ceramic crystal is divided by 4.5 for timing of the microcontroller. TL852 is a chip specially designed for receiving ultrasonic waves. Because the returned ultrasonic signal is relatively weak, it needs to be amplified before it can be received by the microcontroller. TL852 mainly provides an amplification circuit. When TL852 receives 4 pulse signals, it sends a high level to TL851 through REC to indicate that the ultrasonic wave has been received.
2.3 AT89C51 Microcontroller
This system uses AT89C51 to control the Polaroid 600 series sensors and Polaroid 6500 series ultrasonic distance modules. The single-chip microcomputer controls the transmission of ultrasonic waves through the P1.0 pin via an inverter, and then the single-chip microcomputer continuously detects the INT0 pin. When the level of the INT0 pin changes from a high level to a low level, it is considered that the ultrasonic wave has returned. The data counted by the counter is the time experienced by the ultrasonic wave, and the distance between the sensor and the obstacle can be obtained by conversion. The hardware schematic diagram of ultrasonic ranging is shown in Figure 3:
Figure 3 Hardware diagram of ultrasonic ranging
3. System software design
The system program flow chart is shown in Figure 4:
Figure 4 Ultrasonic ranging program flow chart
When working, the microprocessor AT89C51 first sets P1.0 to 0, starts the ultrasonic sensor to transmit ultrasonic waves, and starts the internal timer T0 to start timing. Since the ultrasonic sensor we use is a transceiver, the ultrasonic sensor still has aftershocks after sending 16 pulses. In order to eliminate the transmission signal of the ultrasonic sensor from the return signal, the return signal must be detected 2.38ms after the start of the transmission signal, so that the output interference can be suppressed. When the ultrasonic signal hits an obstacle, the signal returns immediately, and the microprocessor keeps scanning the INT0 pin. If the signal received by INT0 changes from a high level to a low level, it means that the signal has returned, and the microprocessor enters the interrupt shutdown timer. The data in the timer is converted to get the distance between the ultrasonic sensor and the obstacle.
4. Experimental data processing
Due to the influence of ambient temperature and humidity, there is always some deviation between the measured value of the ultrasonic sensor and the actual value. Table 1 lists the measured value of this ultrasonic ranging system and the corresponding actual value:
Table 1 Measured values and actual values of ultrasonic ranging system Unit: cm
From the data in the table, we can see that the measured value is always about 7cm larger than the actual value. After analysis, there are three main reasons: first, the data measured by the ultrasonic sensor is affected by the ambient temperature; second, the command execution takes a certain amount of time, which makes the measured data larger; third, in order to prevent interference from other signals, the drive circuit sends 16 pulse trains when the microcontroller starts counting. For the single echo method, when the drive circuit receives the fourth pulse returned by the obstacle, it stops counting, so the final measured time is four pulses longer than the time corresponding to the actual distance. In order to reduce the deviation between the measured value and the actual value, we use the least squares method [4~5] to correct the data in Table 1. After fitting, we get the following equation:
y=1.0145x-9.3354? (where y is the actual value and x is the measured value)
The corresponding relationship between the measured value and the actual value of the ultrasonic ranging system after correction is shown in Table 2:
Table 2 Corrected ultrasonic ranging system measured values and actual values Unit: cm
From the corrected data we can see that the measurement error of the system is within ±2%, which meets our measurement requirements.
5. Conclusion
When using ultrasonic sensors to measure distance, the main thing is to ensure that the circuit design meets the reliability and stability of the circuit. After experiments and analysis, we believe that using the 6500 series distance module and 600 series ultrasonic sensor to measure distance is simple, economical, and reliable, and the error of the measured data is relatively small.
Previous article:Simulation design of liquid crystal temperature display based on Proteus
Next article:A constant current source design based on power amplifier
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Open Source] GPIO Experiment Tutorial - Crazy Shell ARM Dual Processor Development Board Series
- Does the embedded industry strictly restrict college education?
- BAW filters help 5G achieve high-quality communications and higher efficiency
- [RISC-V MCU CH32V103 Review] Hardware IIC drive OLED (finally)
- 2 mistakes in the RSL10 official getting started guide
- ADC10 multi-channel input of msp430g2553
- 【TI Recommended Course】#Texas Instruments Field Transmitter Output Interface/Fieldbus Solution#
- 【CH579M-R1】+Love for CH579M
- MSP430 MCU Example 10-8-bit Digital Tube Display Clock
- Getting Started with the ST SensorTile.box Sensor Kit (4) Programming Mode Experience