Non-contact air distance measurement method based on P89LPC932

Publisher:AmpouleLatest update time:2012-11-17 Source: 21IC Keywords:P89LPC932 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

Some traditional distance measurement methods have insurmountable defects in certain special occasions. For example, liquid level measurement is a kind of distance measurement. The traditional electrode method uses differential distribution electrodes to detect the liquid level by applying electricity or pulses. The electrodes are easily corroded and electrolyzed when immersed in water or other liquids for a long time, and lose sensitivity. Using ultrasonic distance measurement can solve these problems.

The ultrasonic rangefinder designed in this paper uses three range-measuring modes to select jumper J1 (short distance, medium distance, and adjustable distance). The overall solution is that when the measurement key is pressed, the probe sends ultrasonic waves, and when the ultrasonic waves encounter obstacles, an echo signal will be generated; the system amplifies the echo signal received by the probe and sends it to the controller; the temperature measurement circuit measures the temperature, calculates the measured distance, and displays it on the digital display, with the last 4 digits showing the distance and the first 2 digits showing the temperature.

1 Basic Principle of Ultrasonic Rangefinder

Basic Principle of Ultrasonic Rangefinder

The principle of using ultrasound to measure distance is shown in Figure 1. It can be simply described as follows: the regularly transmitted ultrasound waves are reflected when encountering obstacles. The reflected waves are received by the receiver and converted into electrical signals. In this way, the distance can be calculated by measuring the time difference △t between transmission and reception, and then according to formula (1):

Where: C is the propagation speed of ultrasound in air, C is 331 m/s at 0℃, C is 347 m/s at 25℃, and its relationship with ambient temperature T (unit: ℃) is as shown in formula (2):

It can be seen that the speed of sound is closely related to temperature. In applications, if the temperature does not change much and there is no special accuracy requirement, the speed of sound can be considered to be basically unchanged. Otherwise, temperature compensation must be performed. The temperature compensation method is to first calculate the speed of sound C at that time according to formula (2) and then calculate the distance according to formula (1).

In addition, it can be seen from Figure 1 that since ultrasound uses the received reflected waves to calculate the distance, there is inevitably an angle between the emission and the reflection, and its size is 2a. When a is very small, the distance can be directly calculated according to formula (1); when a is large, the distance must be corrected, and the correction formula is as shown in formula (3):

2 System Hardware

The ultrasonic rangefinder mainly includes: temperature detection circuit, ultrasonic emission and control circuit, ultrasonic reception and signal processing circuit, display circuit, microprocessor and its auxiliary circuit and RS 232 communication interface circuit. Its structural block diagram is shown in Figure 2.

Ultrasonic rangefinder structure

2.1 Ultrasonic emission and control circuit

Ultrasonic emission and control circuit

The ultrasonic probe model is CSB40T. The software generates a 40 kHz ultrasonic signal, which is input to the driver through the output pin. After being driven by the driver, the probe is driven to generate ultrasonic waves, as shown in Figure 3. It can be seen from the figure that the 40 kHz ultrasonic signal is generated by oscillating the 555 time base circuit. The oscillation frequency calculation formula is as follows:

The purpose of designing R10 as an adjustable resistor is to adjust the signal frequency to make it consistent with the 40 kHz natural frequency of the transducer. In order to ensure that the 555 time base has sufficient driving ability, it is advisable to use a +12 V power supply. CNT is the ultrasonic emission control signal, which is controlled by a microprocessor. [page]

2.2 Design of Ultrasonic Receiver

Echo Receive Processor Circuit

Select Jumper Circuit

The ultrasonic receiver consists of three parts: ultrasonic receiving probe, signal amplification circuit and waveform conversion circuit. The ultrasonic probe must be of the same model as the transmitting probe, and CSB 40R is used here. Since the sine wave electrical signal after the probe conversion is very weak, it must be amplified by the amplifier circuit. The sine wave signal cannot be directly received by the microprocessor, so the waveform must be changed. As shown in Figure 4, the front stage uses NE5532 to form a 10,000-fold amplifier to amplify the received signal; the back stage uses LM311 comparator to adjust the received signal. The input of LM311's 3-pin is the comparison voltage. Different comparison voltages can be selected by the J1 jumper to select different ranging modes, as shown in Figure 5.

The module provides a distance measurement mode selection jumper J1, which can select short-distance measurement mode, medium-distance measurement mode or adjustable distance mode. When the jumper is selected LOW, it is the short-distance measurement mode, when it is selected HIGH, it is the medium-distance measurement mode; when it is selected SET, it is the adjustable distance mode.

2.3 Temperature Measurement Circuit

When the ambient temperature changes, the ultrasonic wave velocity will change accordingly, so it needs to be corrected. Therefore, a temperature detection circuit is set up in the system to collect temperature in real time and correct the wave velocity. The sensor used in the temperature measurement circuit is DS1820, as shown in Figure 6. It has 9, 10, 11, and 12-bit conversion accuracy. The default accuracy is 12 bits when not programmed. The measurement error is generally 0.5°C, which can reach 0.1°C after software processing.

3 System Software

The system flow chart is shown in Figure 7.

The microprocessor P89LPC932 first sets P1.6 to 0, starts the ultrasonic probe to emit ultrasonic waves, and starts the internal timer T0 to start timing. Then the temperature is detected and temperature compensation is performed. When the ultrasonic signal encounters an obstacle, the signal returns immediately. The microprocessor keeps scanning the P2.7 pin. If the signal received by P2.7 changes from a high level to a low level, it indicates that the signal has returned, and the microprocessor enters an interrupt to turn off the timer. The data in the timer is then converted to obtain the measured distance.

4 Conclusion

This system has three mode jumper selections, so it has the characteristics of high measurement accuracy, strong anti-interference ability, fast response speed, etc. Experiments show that the actual measurement accuracy of this rangefinder is the best 1%, and the farthest distance is about 700 cm.

Keywords:P89LPC932 Reference address:Non-contact air distance measurement method based on P89LPC932

Previous article:Design of ultrasonic guided wave excitation signal source based on DS89C430
Next article:Design of Power Factor Measuring Instrument Based on P89V51RD2

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号