Single chip ultrasonic rangefinder

Publisher:古通闲人Latest update time:2015-08-25 Source: eechina Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The 51 series single-chip microcomputer provides a highly flexible and low-cost solution 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.

1 Principle of distance measurement by single-chip microcomputer

The single-chip microcomputer emits ultrasonic ranging by continuously detecting the echo reflected by obstacles after the ultrasonic emission, 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 speed.

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, multiple ultrasonic transducers can be used as a design method for multi-channel ultrasonic emission/reception. Since ultrasonic waves belong to the sound wave range, their wave speed C is related to temperature. Table 1. Lists the wave speeds 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, as long as the round-trip time r of the ultrasonic wave is measured, the distance 5 can be obtained. The system principle block diagram is shown in Figure 2.



The single-chip microcomputer (AT89C51) sends 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 emitter follower and driven by the power amplifier to be emitted by the ultrasonic transmitter. 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, the output is low level and sent to the pin of AT89C51.

Example of design using this principle: Car anti-collision radar

2 System hardware design

Car anti-collision radar can help drivers understand the obstacles around the car in time and prevent the car from being hit or scratched when turning, reversing, etc. The hardware circuit of the receiving part is shown in Figure 3, and the hardware circuit of the transmitting, preset, control, and display part is shown in Figure 4.



sP3.2, provided 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 74LSl64 by the serial port line RXD and TXD, and converted into parallel data to control the display of the LED, using dynamic display. The two LEDs 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 n) or 0.5m), the alarm circuit will issue an appropriate warning tone, and the output of P2.1 will control the operation of the alarm circuit.

3 System software design

The automobile anti-collision radar is developed and designed with AT89C51 microcontroller based on the ultrasonic ranging principle. The entire software adopts modular design and consists of modules such as 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, and sound alarm functions into independent modules. In the main program, a key-controlled loop is used. When the control key is pressed, each module is executed in sequence within a certain period, calling the preset subprogram, transmission subprogram, query reception subprogram, and timing subprogram, and the measurement results are analyzed and processed. 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. Figure 5 shows the flow chart of the program.



4 Conclusion

The rangefinder designed with 51 series microcontrollers is easy to operate and the reading is intuitive. Actual tests have proved that this type of rangefinder works stably, can meet the requirements of general short-range ranging, and has low cost and good cost performance. Since it takes a certain amount of time for the phase-locked loop in this system to lock, there is an error in the measured distance. In automotive radar applications, this error is 3C111 and can be ignored; but in industrial fields with higher precision requirements, such as automatic ranging of robots, this error cannot be ignored. Only by changing the application of some hardware to achieve rapid locking of the ultrasonic wave can the error be further reduced to 0.31llnl to meet higher requirements.
Reference address:Single chip ultrasonic rangefinder

Previous article:Design and implementation of CAN bus interface circuit based on SJA1000
Next article:How to make Keil MDK compatible with Keil C51?

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号