Ultrasonic waves have the advantages of good directionality, concentrated energy, low attenuation during transmission, and strong reflection ability. Ultrasonic sensors can be widely used in non-contact detection methods, so simulation technology is used for ultrasonic ranging.
At present, the ultrasonic distance measurement ASICs in China have a measurement accuracy of only centimeters. By analyzing the causes of ultrasonic distance measurement errors, improving the measurement time difference to microseconds, and using the LM92 temperature sensor to compensate for the sound wave propagation speed, the designed high-accuracy ultrasonic distance meter can achieve millimeter-level measurement accuracy.
1 Basic Principle of Ultrasonic Distance Measurement Alarm System
As shown in FIG. 1 , the single chip microcomputer can receive the distance signal output by the ultrasonic module, and after reasonable processing, display the distance between the ultrasonic module and the obstacle in real time on the display module.
Figure 1 System connection diagram
The single-chip microcomputer sends out a 40 kHz square wave signal, which is amplified and output through the ultrasonic transmitter; the ultrasonic receiver amplifies the received ultrasonic signal through the amplifier, performs detection processing with the phase-locked loop circuit, and starts the single-chip microcomputer interrupt program. The measured time is t.
Then the software is programmed to distinguish and calculate, and the measured distance value is obtained and displayed by the LED digital tube. The principle block diagram is shown in Figure 2.
Figure 2 Principle block diagram of ultrasonic rangefinder
The ultrasonic wave emitted by the transmitter propagates in the air at a speed of v. When it reaches the object to be measured, it is reflected back and received by the receiver. The round trip time is t. The distance of the object to be measured is calculated by the formula: measured distance L (m) = sound speed 340 (m/s) at normal temperature × induction time t (s) / 2. Since ultrasonic wave is also a sound wave, its sound speed v is related to temperature. If the temperature does not change much, the sound speed can be considered to be basically unchanged. If the distance measurement accuracy is very high, it should be corrected by temperature compensation.
2 System Hardware Design
2.1 Principle of Ultrasonic Distance Measurement
The MCU transmits a square wave at time T0 and starts the timer to count. When the echo is received, a negative jump is generated to the port of the MCU. The MCU responds to the interrupt program and the timer stops counting. By calculating the time difference, the time t of the ultrasonic wave propagating in the medium can be obtained, and the distance can be calculated from it. The timing diagram is shown in Figure 3.
Figure 3 Ultrasonic timing diagram
2.2 Hardware Circuit
The design of the hardware circuit mainly includes three parts: the single-chip microcomputer system and display circuit, the ultrasonic transmitting circuit and the ultrasonic detection receiving circuit. The single-chip microcomputer adopts STC89C51 or its compatible series. A 12 MHz high-precision crystal oscillator is used to obtain a more stable clock frequency and reduce measurement errors. The single-chip microcomputer uses the P2.4 port to output the 40 kHz square wave signal required by the ultrasonic transducer, and uses the external interrupt 0 port to monitor the return signal output by the ultrasonic receiving circuit. The display circuit uses a simple and practical 4-bit common anode LED digital tube, the segment code is driven by the program, and the bit code is driven by the PNP transistor. [page]
2.3 Hardware of each main module
The STC89C51 chip pins and package are shown in Figure 4.
Figure 4 STC89C51 pinout
Pin function description:
(1) VCC: power supply voltage.
(2) GND: Ground.
(3) RST: Reset input. When the oscillator resets the device, the RST pin must be kept high for two machine cycles.
(4) /EA/VPP: When /EA is kept at a low level, the external program memory (0000H-FFFFH) is used during this period, regardless of whether there is an internal program memory.
(5) XTAL1: Input of the reverse oscillation amplifier and the input of the internal clock working circuit.
(6) XTAL2: Output from the reverse oscillator.
(7) Port 0: Port 0 is an 8-bit open-drain bidirectional I/O port, also known as an address/data bus multiplexing port. When used as an output port, each pin can absorb 8TTL gate current.
(8) P1 port: P1 port is an 8-bit bidirectional I/O port with an internal pull-up resistor. The P1 port buffer can absorb or output 4TTL gate current.
(9) P2 port: P2 port is an 8-bit bidirectional I/O port with an internal pull-up resistor. The P2 port buffer can absorb or output 4 TTL gate currents. When "1" is written to the P2 port, its pin is pulled high by the internal pull-up resistor and acts as an input.
(10) P3 port: P3 port pins are 8 bidirectional I/O ports with internal pull-up resistors, which can absorb or output 4 TTL gate currents.
Port P3 can also be used as some special function ports of AT89C52, as shown in Table 1.
Table 1 P3 special function port
Port P3 receives some control signals for both flash programming and programming verification.
(11) ALE//PROG: The address latch enable output level is used to latch the status byte of the address when accessing external memory.
(12) /PSEN: Selection signal of external program memory.
During instruction fetch from external program memory, /PSEN is valid twice in each machine cycle. However, when accessing external data memory, these two valid /PSEN signals will not appear. [page]
2.4 Ultrasonic Transmitter Circuit
The principle of the ultrasonic transmitter circuit is shown in Figure 5. Two inverters are connected in parallel at the output end to improve the driving ability. The upper resistors R10 and R11 can improve the driving ability of the inverter 74LS04 to output a high level, and on the other hand, they can increase the damping effect of the ultrasonic transducer and shorten its free oscillation time.
Figure 5 Schematic diagram of ultrasonic transmitting circuit
2.5 Ultrasonic detection receiving circuit
The integrated circuit CX20106A is a special chip for infrared detection and reception. Considering that the carrier frequency 38 kHz commonly used in infrared remote control is close to the ultrasonic frequency 40 kHz for ranging, it can be used to make an ultrasonic detection and receiving circuit (as shown in Figure 6). Experiments have shown that using CX20106A to receive ultrasonic waves (output high level when there is no signal) has good sensitivity and strong anti-interference ability.
Figure 6 Ultrasonic detection receiving circuit
2.6 Display Circuit
The display circuit uses a simple and practical 4-digit common anode LED digital tube, the segment code is driven by 74LS244, and the bit code is driven by PNP three-stage tube. The digital tube connected to the P2.1 pin is the ones-digit display digital tube, and its decimal point is displayed when P2.1 is valid. This function is completed by software.
2.7 Reset Function
The system should have a ranging start function that can reset the system to start ranging again.
In summary, the characteristics of this system are to use a single-chip microcomputer to control the emission of ultrasound and the timing of the round-trip time from the emission to the reception of ultrasound. The single-chip microcomputer uses STC89C52, which is economical and easy to use, and has an 8K ROM on the chip for easy programming. The circuit principle is shown in Figure 7.
3 Software Solution
The system software design adopts modular design, which mainly includes main program design, T0 interrupt service subroutine, external interrupt service subroutine, distance calculation subroutine, LED display subroutine design, etc.
The main program first initializes the system environment, sets the working mode of timer T0 to 16-bit timer counter mode, sets the general interrupt enable bit EA and clears the display ports P0 and P2 to 0.
Baidu Button BEGIN
Previous article:Design of single chip microcomputer in LED aquarium light source
Next article:Design of single chip microcomputer in wireless ward pager
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- Mobile 5G device antenna tuning revealed
- What is switching AC-DC conversion?
- About PIN-to-PIN compatibility between SI24R1 and NRF24L01P
- Huawei_Large-Scale Logic Design Guide.rar
- Announcement: Participants in the last round of the lottery will be given 11.11 yuan to purchase a multimeter, soldering station, and development board
- MSP430 clock frequency configuration process
- [Mill Edge AI Computing Box FZ5 Review] Pynq Framework - Helloworld!
- pybNano development board added to uf2-stm32f
- Compound tube and complementary push-pull circuit
- [RTT & Renesas high performance CPK-RA6M4 development board review] - Serial and USB communication