The principle of distance meter designed by single chip microcomputer and its simple application

Publisher:MysticalEssenceLatest update time:2013-11-09 Source: dzscKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:MCU Reference address:The principle of distance meter designed by single chip microcomputer and its simple application

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号