Ultrasonic Rangefinder Using Time-of-Flight Detection

Ultrasonic Rangefinder Using Time-of-Flight Detection

Ranging technology is widely used in civil and industrial fields such as material level detection, medical flaw detection, and automobile anti-collision. Since the speed of ultrasonic waves is much smaller than the speed of light, its propagation time is relatively easy to detect, and it is easy to directional launch and has good directionality. , the emission intensity is well controlled, and is not affected by electromagnetic interference, so the use of ultrasonic ranging is an effective non-contact ranging method.

Ranging technology is widely used in civil and industrial fields such as material level detection, medical flaw detection, and automobile anti-collision. Since the speed of ultrasonic waves is much smaller than the speed of light, its propagation time is relatively easy to detect, and it is easy to directional launch and has good directionality. , the emission intensity is well controlled, and is not affected by electromagnetic interference, so the use of ultrasonic ranging is an effective non-contact ranging method. However, the propagation speed of ultrasonic waves is different at different ambient temperatures. If the influence of temperature is ignored, the final measurement accuracy will be affected. The ultrasonic range finder introduced in this paper adopts the transit time detection method, uses the DS1 8B20 temperature sensor to detect the field temperature, and realizes the temperature compensation of the wave speed through software calculation, which eliminates the influence of temperature on the measurement results and reduces the measurement error.

1 How the system works

The principle of ultrasonic ranging is shown in Figure 1.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 1 Principle of ultrasonic ranging

Ultrasonic Rangefinder Using Time-of-Flight Detection

In the formula, c – ultrasonic wave speed: t – the time taken from transmitting ultrasonic waves to receiving echoes.

There are four factors that limit the measurable distance of the system: the amplitude of the ultrasonic waves, the texture of the reflection, the angle between the reflected and incident sound waves, and the sensitivity of the receiving transducer. The measurable distance that will be determined by the ability of the receiving transducer to directly receive the acoustic pulse. 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 transmission/reception respectively.

Since the ultrasonic wave belongs to the range of sound waves, its wave speed c is related to the temperature.

Table 1 Relationship between sound speed and temperature
Ultrasonic Rangefinder Using Time-of-Flight Detection

A first-order fit of the measured velocity data to the temperature data yields:

c=331.6+0.6107xT (2)

where T is the local temperature.

During distance measurement, the temperature sensor can be used to automatically detect the ambient temperature and determine the wave speed c. After the wave speed is determined, as long as the time t of the ultrasonic round trip is measured, the distance H can be obtained, which can be compared in this environment. The distance traveled by the ultrasonic wave improves the measurement degree.

The transit time detection method is used in this design scheme. The working principle of the distance meter is: when the single-chip microcomputer sends out the driving signal, the timer in the single-chip microcomputer is turned on to start timing. The transmitting probe emits ultrasonic waves, and when the receiving probe receives the echoes, the timer of the single-chip microcomputer is stopped. Since the speed of the ultrasonic waves in the air is known, the distance between the probe and the target to be measured can be obtained according to the formula. Moreover, ultrasonic measurements can be sent out multiple times in a relatively short period of time, and the average value is calculated and displayed after completion.

Ultrasound propagates at the same speed in the same propagation medium (atmospheric conditions), that is, the speed of sound does not change with frequency within a considerable frequency range, but the higher the frequency, the stronger the attenuation and the shorter the propagation distance. Considering the actual engineering measurement requirements, when designing the ultrasonic range finder, the ultrasonic frequency f=40kHz is selected, and the wavelength is 0.85cm.

2 System hardware design

This system adopts AT89C52 single-chip microcomputer as the main controller, and uses 3-digit digital tube as the system Display screen. The 40 kHz pulse required for the ultrasonic transmission drive is sent by the single-chip microcomputer P0.0, and the timer is used for timing and control. The ultrasonic receiving uses CX20106A as the main receiving device. Control chip, use DS18B20 as temperature sensor for temperature correction. The system schematic diagram of the ultrasonic range finder is shown in Figure 2.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 2 Schematic diagram of system design

2.1 Ultrasonic emission

The ultrasonic transmitting module is composed of ultrasonic transmitting probes. The P0.0 port of the single-chip microcomputer directly transmits a 40 kHz signal, and uses a 9012 triode as a driving amplifier to drive the piezoelectric chip ultrasonic transducer to generate ultrasonic waves. The ultrasonic transmitting circuit is shown in Figure 3. Show. The flow of the ultrasonic emission subroutine is that the timer is first loaded during emission, and the timer is started. When the ultrasonic emission is completed, the timer is completed, and the timer is reloaded to wait for the next emission.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 3 Ultrasonic transmitting circuit

2.2 Ultrasonic receiver circuit design

The infrared receiving and processing chip CX20106A is used in the receiving circuit, because it processes the infrared signal of 38 kHz, and the ultrasonic signal of 40 kHz is relatively close to it, and the CX20106A chip has strong anti-interference ability. The peripheral circuit of this chip It is very simple and its central processing frequency can be adjusted through the peripheral resistance, and the sensitivity and anti-interference ability of the receiving circuit can also be changed by changing the capacitance of the peripheral circuit.

After the experiment, it is found that it is simpler and more reasonable to use the single-chip microcomputer to send a 40 kHz signal and the circuit using the CX20106A, which makes the calculation of the time easier.

The ultrasonic receiving module of the system is composed of ultrasonic receiving probe and infrared receiving and processing chip CX20106A. As shown in Figure 4. The flow of the ultrasonic receiving subroutine is to use the INT0 interrupt to detect the echo signal. If there is an echo signal (the INT0 port is low), the external interrupt is turned off, and the timer is stopped at the same time, and the ranging success flag is marked as 1 ( Ranging is successful), extract the time value at the same time, calculate the distance to be measured, save the final result and open the external interrupt, and wait for the next measurement.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 4 Ultrasonic receiving circuit

2.3 Ultrasonic ranging Display circuit

There are two types of display modules, one is to use a liquid crystal display, which has the advantages of being light, thin, short, high resolution, and capable of displaying various symbols such as Chinese characters. However, it is generally necessary to create a character library, and the programming workload is large; one is to use digital tubes, which have the characteristics of low power consumption, long life, easy maintenance, high precision, fast weighing, reliability, and easy programming. easy to use. The disadvantage is that Chinese characters and multi-data multi-line display cannot be realized. Considering this design, a 3-digit digital tube display is selected. Use the PNP type triode to drive the digital tube, and connect it to the P0 port of the single-chip AT89C52 for bit selection. Although the display is not as complete as the LCD screen, it can also display the required results completely and intuitively. Figure 5 shows the display circuit designed by the ultrasonic ranging hardware.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 5 Ultrasonic ranging display circuit

2.4 Design of temperature compensation circuit

In this system, the temperature chip DS18B20 is chosen as the temperature sensor. DS18B20 supports “one-wire bus” interface, the measurement temperature range is -55~125℃, and the accuracy is ±0.5℃ within the range of -10~85℃. The field temperature is directly transmitted in the digital mode of “one-line bus”, which greatly improves the anti-interference of the system. Field temperature measurement suitable for harsh environments. The pin description of DS18B20 is shown in Table 2.

Table 2 DS18B20 pin description

DS18B20 reads and writes data on one I/O line, so there are strict timing requirements for read and write data bits. DS18B20 has strict communication protocol to ensure the correctness and integrity of each data transmission. The protocol defines the timing of several signals: initialization timing, read timing, and write timing.

The design of the temperature compensation circuit is shown in Figure 6. The data input/output pin is connected to the P0.1 pin of the microcontroller, the power interface is connected to +5 V Voltage, and a pull-up resistor of 5.6 kΩ is added, because DS18B20 is a single bus temperature sensor , the data line is open-drain, if the DS18B20 is not connected to the power supply, the data line needs to be pulled up strongly to supply power to the DS18B20; if the DS18B20 is connected to the power supply, it needs a pull-up to work stably. Since DS18B20 does not need any peripheral components in use, all sensing components and conversion circuits are integrated in a transistor-like shape, the detected temperature value is converted internally, and the temperature measurement results are directly output as digital signals, and the single-chip microcomputer is output by DS18B20 The signal is read, and the digital temperature value is processed by software.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 6 Temperature compensation circuit

2.5 Schematic diagram of the main circuit

The schematic diagram of the main circuit of the system is shown in Figure 7. The single-chip microcomputer adopts the 89C52 series. The single-chip microcomputer uses an external clock source and an external 6MHZ crystal oscillator. The P0.0 port directly outputs a 40 KHZ drive signal to the amplifier circuit. After receiving the echo, it is filtered by CX20106 to generate an interrupt signal, which is interrupted by the output of the p3.2 port. The display circuit adopts a simple and practical 3-digit digital tube, which is connected to the P0 port of the single-chip AT89C52, and the triode is connected to the P2 port for the bit selection of the digital tube. When working, first initialize the system and start the timer. And send a 40KHZ drive signal from the P0.0 pin, turn on the INT0 interrupt at the same time, and start to wait for the received echo and interrupt signal, if the echo is received (the single-chip microcomputer receives the interrupt signal), the timer stops timing and saves the time information , and calculate the speed of sound in the current environment according to the temperature compensation, calculate the current distance to be measured and store it, and call the display subroutine. After the distance is measured, the result will be transmitted to the LED display in the form of decimal BCD code, and then the ultrasonic pulse will be sent to repeat the measurement process.

Ultrasonic Rangefinder Using Time-of-Flight Detection
Figure 7 The main circuit diagram of ultrasonic ranging

3 Conclusion

After actual measurement, this rangefinder can quickly detect short-distance obstacles within 250 m, and the error can be controlled within 1 cm within the range of 30-200 cm. The design has the advantages of simple and practical, low energy consumption, low cost, etc. Features. After the actual test, it is found that the accuracy of the system can meet the general needs. If the accuracy needs to be further improved, the dual-frequency ultrasonic ranging method with higher accuracy but more complex system can be used.

The Links:   HSMS-282N-BLKG SKIIP 32NAB125T12 INFIGBT

micohuang