1, ultrasonic sensor and its ranging principle
Ultrasonic wave refers to mechanical wave with frequency higher than 20KHz [1]. In order to use ultrasound as a detection means, it is necessary to generate and receive ultrasound. The device to realize this function is an ultrasonic sensor, usually called an ultrasonic transducer or an ultrasonic probe. Ultrasonic sensors have transmitters and receivers, but ultrasonic sensors can also have dual functions of sending and receiving sound waves. Ultrasonic sensor uses the principle of piezoelectric effect [1] to convert electric energy and ultrasonic wave to each other.
Conversion, that is, when emitting ultrasonic waves, converting electric energy and emitting ultrasonic waves; When the echo is received, the ultrasonic vibration is converted into an electrical signal.
The principle of ultrasonic ranging generally adopts TOF (Time of Flight) [2]. First, measure the time from the launch of the ultrasonic wave to the return of the obstacle, and then multiply it by the speed of the ultrasonic wave to get twice the distance from the sound source to the obstacle, that is
1, hardware circuit design
The ultrasonic ranging system we designed consists of Polaroid 600 series sensors, Polaroid 6500 series ultrasonic ranging modules and AT89C5 1 single chip microcomputer.
2. 1 polaroid 600 series sensor
This kind of ultrasonic sensor is a kind of sensor which integrates sending and receiving. There is a circular thin sheet in the sensor, made of plastic, with a metal film on the front and an aluminum back. The thin plate and the back plate form a capacitor. When a square wave voltage with a frequency of 49.4kHz and a voltage of 300VAC pk-pk is applied to the thin plate, the thin plate vibrates at the same frequency, thus generating ultrasonic waves with a frequency of 49.4kHz. When receiving echoes, Polaroid 6500 has a tuning circuit, so it can only receive signals with a frequency close to 49.4kHz, and signals with other frequencies are filtered out.
The ultrasonic wave emitted by Polaroid 600 ultrasonic sensor has a beam angle of 30 degrees [3], as shown in figure 1:
Figure1beam angle
Ultrasonic sensors can be used as both transmitters and receivers. The sensor emits a string of ultrasonic beams, which lasts for a period of time, and can only be received after the emission is over. If the time of sending the light beam is d, the signal reflected from the object within d time cannot be captured. In addition, the ultrasonic sensor has a certain inertia, and there is still some residual vibration after transmission. This residual vibration will also generate a voltage signal through the sensor, which will interfere with the system's work of capturing the return signal. Therefore, before the aftershock disappears, the system cannot be started to receive the echo. The above two reasons have caused the ultrasonic sensor to have a certain measuring range. This ultrasonic wave can measure 37cm recently.
2.2 Polaroid 6500 Series Ultrasonic Distance Module
The hardware circuit of Polaroid 6500 series ultrasonic ranging module is shown in Figure 2:
Fig. 2 Hardware circuit of Polaroid 6500 series ultrasonic ranging module
TL85 1 is an economical digital 12-step ranging control integrated circuit. There is a 420KHz ceramic crystal oscillator in it. When the 6500 series ultrasonic distance module starts to work, in the first 16 cycle of transmission, Tao
The ceramic crystal oscillator is divided by 8.5 to form an ultrasonic signal of 49.4KHz, which is then transmitted to the ultrasonic sensor through the transistor Q 1 and the transformer T 1. After sending, the ceramic crystal oscillator is clocked by a single chip microcomputer at 4.5 frequency division. TL852 is a chip specially designed for receiving ultrasonic waves. Because the returned ultrasonic signal is weak, it needs to be amplified before it can be received by the single chip microcomputer. TL852 mainly provides an amplifier circuit. When TL852 RECeives four pulse signals, it sends high level to TL85 1 through rec, indicating that ultrasonic waves have been received.
2.3 AT89C5 1 single chip microcomputer
The system adopts AT89C5 1 control Polaroid 600 series sensors and Polaroid 6500 series ultrasonic ranging module. The single chip microcomputer controls the emission of ultrasonic waves through the frequency converter through the P 1.0 pin, and then the single chip microcomputer continuously detects the INT0 pin. When the level of the INT0 pin changes from high level to low level, it is considered that the ultrasonic wave has returned. The data counted by the counter is the ultrasonic time, and the distance between the sensor and the obstacle can be obtained by conversion. The hardware schematic diagram of ultrasonic ranging is shown in Figure 3:
Fig. 3 Hardware schematic diagram of ultrasonic ranging
3. System software design
The system program flow chart is shown in Figure 4:
Fig. 4 Flow chart of ultrasonic ranging program
When working, the microprocessor AT89C5 1 first sets P 1.0, starts the ultrasonic sensor to emit ultrasonic waves, and starts the internal timer T0 to start timing. Because the ultrasonic sensor we use is a transceiver, there are aftershocks in the ultrasonic sensor after sending the 16 pulse. In order to identify and eliminate the signal sent by the ultrasonic sensor from the echo signal, it is necessary to detect the echo signal 2.38ms after starting to transmit the signal, so as to suppress the output interference. When the ultrasonic signal hits an obstacle, the signal returns immediately, and the microprocessor continues to scan the INT0 pin. If the signal received by INT0 changes from high level to low level, it indicates that the signal has returned and the microprocessor enters the interrupt turn-off timer. Then the data in the timer can be converted to get the distance between the ultrasonic sensor and the obstacle.
4. Experimental data processing
Due to the influence of ambient temperature and humidity, there is always a certain deviation between the measured value of ultrasonic sensor and the actual value. Table 1 lists the measured values and corresponding actual values of the ultrasonic ranging system:
Table 1 Measured value and actual value of ultrasonic ranging system: cm
As can be seen from the data in the table, the measured value is always about 7cm larger than the actual value. After analysis, there are three main reasons: on the one hand, the data measured by ultrasonic sensors are affected by environmental temperature; On the other hand, it takes a certain time for the instruction to run, which makes the measured data too large; Thirdly, in order to prevent the interference of other signals, when the microcontroller starts counting, the driving circuit sends out 16 pulse trains. For single echo mode, when
The driving circuit stops counting when it receives the fourth pulse returned by the obstacle, so the time finally measured is four pulses longer than the time corresponding to the actual distance. In order to reduce the deviation between the measured value and the actual value, we use the least square method [4~5] to correct the data in table 1. After fitting, we get the following equation:
Y= 1.0 145x-9.3354 (where: y is the actual value and x is the measured value).
The corresponding relationship between the measured value and the actual value of the improved ultrasonic ranging system is shown in Table 2:
Table 2 Measured value and actual value of improved ultrasonic ranging system: cm
It can be seen from the revised data that the measurement error of the system is within 2%, which meets our measurement requirements.
5. Conclusion
Using ultrasonic sensor to measure distance is mainly to ensure the reliability and stability of circuit design. Through experiments and analysis, we think that distance measurement with 6500 series distance module and 600 series ultrasonic sensor is simple, economical and reliable, and the measurement data error is relatively small.