At present, ultrasonic distance measurement has been widely used. In China, various distance measurement instruments are generally designed based on the principle of ultrasonic distance measurement using dedicated integrated circuits. However, the cost of dedicated integrated circuits is high and the function is single. The distance measurement instrument with single-chip microcomputer as the core can realize multiple functions such as preset, multi-port detection, display, alarm, etc., and it has low cost, high precision, simple operation, stable and reliable operation. This paper briefly introduces the principle and implementation method of ultrasonic distance measurement using 51 series single-chip microcomputer.
1 Functional characteristics of 51 series single-chip microcomputer
The typical chip in the 51 series single-chip microcomputer (female [1AT89C51) adopts the form of 40-pin dual in-line package (DIP), and is composed of CPU, 4kB ROM, 256B RAM, 2 16b timer/counters T0 and T1, 4 8b I/O terminals I: IP0, P1, P2, P3, a full-duplex serial communication port, etc. In particular, the Flash programmable and erasable read-only memory (E~PROM) inside the chip of this series of microcontrollers makes it have a very wide range of uses in practice, and is more useful in portable, power-saving and special information storage instruments and systems.
The 5l series microcontrollers provide the following functions: 4 kB memory; 256 B RAM; 32 I/O lines; 2 16b timer/counters; 5 2-level interrupt sources; 1 full-bidirectional serial port and clock circuit.
Idle mode: The CPU stops working, while the RAM, timer/counter, serial port and interrupt system continue to work.
Power-down mode: The contents of the RAM are saved, the oscillator stops, and all other functions of the chip are disabled until the next hardware reset.
The 5l series microcontrollers provide highly flexible and low-cost solutions for many controls. By making full use of its on-chip resources, a fully functional ultrasonic ranging system can be constructed with fewer peripheral circuits.
2 Principle of distance measurement by single chip microcomputer
The single chip microcomputer emits ultrasonic distance measurement by continuously detecting the echo reflected by obstacles after the ultrasonic wave is emitted, thereby measuring the time difference tr between the emission and reception of the echo, and then calculating the distance S = Ct/2, where C is the ultrasonic wave velocity.
There are four factors that limit the maximum measurable distance of the system: the amplitude of the ultrasonic wave, the texture of the reflection, the angle between the reflected and incident sound waves, and the sensitivity of the receiving transducer. The direct receiving ability of the receiving transducer to the sound wave pulse will determine the minimum measurable distance. In order to increase the measured coverage and reduce the measurement error, a design method of using multiple ultrasonic transducers as multi-channel ultrasonic transmitters/receivers can be used. Since ultrasonic waves belong to the sound wave range, their wave velocity C is related to temperature. Table 1 lists the wave velocities at several different temperatures.
Due to temperature changes during distance measurement, the temperature sensor can automatically detect the ambient temperature and determine the wave speed C when calculating the distance, so as to more accurately obtain the distance traveled by the ultrasonic wave in this environment, thereby improving the measurement accuracy. After the wave speed is determined, the distance 5 can be obtained by measuring the round-trip time r of the ultrasonic wave.
The single-chip microcomputer (AT89C51) sends out a short 40kHz signal, which is amplified and output through the ultrasonic transducer; the reflected ultrasonic wave is used as the input of the system through the ultrasonic transducer, and the phase-locked loop locks this signal, generates a locking signal to start the single-chip microcomputer interrupt program, and obtains the time t. After the system software calculates and judges it, the corresponding calculation result is sent to the LED display circuit for display. If the measured distance exceeds the set range, the system will prompt the sound alarm circuit to alarm.
AT89C51 outputs an ultrasonic pulse train with a pulse width of 25/us and a carrier of 40kHz through the external pin P2.0, which is added to the base stage of the transmitter follower and driven by the power amplifier to be emitted. The ultrasonic receiver sends the received reflected ultrasonic wave to the amplifier for amplification, and then uses the phase-locked loop circuit for detection. After processing, it outputs a low level and sends it to the pin of AT89C51. An example of design using this principle: car anti-collision radar
3.1 System hardware design
Car anti-collision radar can help drivers understand the obstacles around the car in time to prevent the car from being hit or scratched when turning or reversing.
sP3.2, and provide it to the software for processing. After AT89C51 processes the received information, the measured distance is displayed on the LED. The displayed data is output to 74LS164 through the serial port lines RXD and TXD, and converted into parallel data to control the display of the LED, using dynamic display. The two-digit LED can represent a distance of 4.9 to 0.1 m, which meets the display accuracy; if the distance is less than the preset low-speed safety braking range of the car (such as: 1 m) or 0.5 m), the alarm circuit will issue an appropriate warning tone, and the output of P2.1 will control the operation of the alarm circuit.
3.2 System software design
The automobile anti-collision radar is developed and designed using the AT89C51 microcontroller based on the principle of ultrasonic ranging. The entire software adopts a modular design, consisting of modules such as the main program, preset subprogram, transmission subprogram, receiving subprogram, and display subprogram.
The main idea of software design is to compile the preset, transmission, reception, display, sound alarm and other functions into independent modules, and adopt the key control loop method in the main program. When the control key is pressed, each module is executed in sequence within a certain period, calling the preset subroutine, transmission subroutine, query reception subroutine, timing subroutine, and analyzing and processing the measurement results. According to the processing results, the content of the display program and whether to call the sound alarm program are determined. When the measured distance is less than the preset distance, the sound alarm program is called.
4 Conclusion
The rangefinder designed with 51 series single chip microcomputer is easy to operate and has intuitive readings. Practical tests have proved that this type of rangefinder works stably, can meet the requirements of general short-range distance measurement, and has low cost and good cost performance. Since the phase-locked loop in this system needs a certain time to lock, the measured distance has an error. In the application of automotive radar, this error is 3C111 and can be ignored; but in industrial fields with high precision requirements such as robot automatic distance measurement, this error cannot be ignored. Only by changing the application of some hardware to achieve rapid locking of ultrasonic waves, the error can be further reduced to 0.31llnl, which can meet higher requirements.
Previous article:Design of C8051 single chip microcomputer in variable air volume air conditioning control system
Next article:Design of IC Card Automatic Fueling Machine
- 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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Analysis of the composition and working principle of the radio frequency identification system
- Add RTT log output to common projects. Simple configuration. It is very easy to use.
- AC Current Sensor = AC Current Transducer = AC Current Transducer
- The control motor is found to have insufficient stroke. Please provide a solution.
- [Flower carving DIY] Interesting and fun music visualization series project (27) - Magnetic stirring LED water rotating lamp
- Failed to import brd file into AD
- Confirm that your personal information is correct
- The battery management chip used is Zhongying's SH39F004! Why is the filtering starting from the sixth battery not filtering the GND?...
- KiCad to other EDA conversion
- 【Silicon Labs Development Kit Review】– Joy & Unboxing