Smart test
Design of Ultrasonic Velocity Measurement System Based on AT89C51
Abstract: At present, in ultrasonic speed measurement technology, a single time difference method or frequency difference method is usually used for speed measurement. When the speed of the measured object changes in a large range, a single speed measurement method will introduce a larger measurement error. The system uses the single-chip AT89C51 as the single-chip microcomputer, which integrates the time difference method and the frequency difference method into the same system, realizing the simultaneous measurement of the two methods. Analysis shows that the method has small measurement errors and high measurement accuracy, and has certain theoretical value and application prospects in real-time speed measurement at close range.
Keywords: Time difference method for speed measurement; Frequency difference method for speed measurement; AT89C51; Ultrasonic transmitter circuit; Ultrasonic receiver circuit
Ultrasonic speed measuring equipment can work in various harsh environments such as rain, snow, fog, etc., and the system is easy to manufacture and low in cost. Ultrasonic speed measurement is divided into time difference method and frequency difference method. The time difference method is mostly used for low-speed measurement, while the frequency difference method is mostly used for high-speed measurement. In the existing ultrasonic speed measurement system, either a single time difference method or a single frequency difference method is used for speed measurement. When the measured speed has a large variation range, the single ground speed measurement method will reduce the measurement accuracy. The system uses the single-chip AT89C51 as the single-chip microcomputer, which integrates the time difference method and the frequency difference method into the same system, realizing the simultaneous measurement of the two methods.
1 Principle of Ultrasonic Velocity Measurement
1.1 Speed measurement by time difference method
Time difference method is suitable for low-speed moving objects. Set the time from ultrasonic transmission to reception as △t1, and send the ultrasonic signal after receiving the echo signal. The second transmission and reception interval time is △t2. When the second ultrasonic signal reaches the object, the distance between the transmitting probe and the object is S1, and when the second ultrasonic signal reaches the object, the distance between the transmitting probe and the object is S2, and the moving speed of the object is as follows
1.2 Frequency difference method for speed measurement
The Doppler effect is the theoretical basis of the frequency difference method for speed measurement. Set the speed of sound to c and the speed of the object to be measured as v. When the ultrasonic beam emitted by the ultrasonic probe B1 encounters an object moving at speed v, due to the principle of the Doppler effect, The ultrasonic frequency f0 received by the ultrasonic probe B2 changes, the difference between the ultrasonic frequency received by the receiver and the transmitted ultrasonic frequency △f=|f0-f|, the Doppler frequency shift value is:
From formula (3), it can be known that as long as the Doppler frequency shift signal △f is obtained, the moving speed v of the object can be obtained. The system design uses the Doppler frequency shift of the ultrasonic wave to time the echo signal period reflected by the moving object, so as to obtain the echo signal frequency.
2 Ultrasonic speed measurement system design
The ultrasonic speed measurement system designed by is shown in Figure 1. The system is composed of a single-chip 89C51 as the main control module, plus an ultrasonic transmitter module, an ultrasonic receiver module and a display module. The ultrasonic transmitter module in the system uses the 40 kHz square wave signal generated inside the single-chip microcomputer, and the ultrasonic transmission is controlled by the button. The receiving module is responsible for detecting and analyzing the echo signal and then transmitting it to the single-chip microcomputer for arithmetic processing. After the single-chip calculation is completed, the data Transfer to the display module for display.
2.1 Ultrasonic sensor
Ultrasonic sensor is a device that realizes the conversion between sound and electricity. This device can emit ultrasonic waves and receive ultrasonic echoes, and convert them into corresponding electrical signals. The system uses a split single crystal straight probe, the ultrasonic probe model is TCT40T/R (diameter 16 mm), TC is a piezoelectric ceramic ultrasonic sensor; T is universal; T is transmitting/R is receiving. The shape of the probe is shown in Figure 2. Its effective range is relatively large and cost-effective; its center frequency is 40 kHz. The relevant parameters are as follows:
1) Nominal frequency (kHz): 40 kHz
2) Transmit sound pressure 10 V (0 dB=0.02 mPa): ≥117 dB
3) Receiving sensitivity 40 kHz (0 dB=V/ubar): ≥-65 dB
4) Electrostatic capacitance 1 kHz: 1V (PF): 2 000+30%
2.2 Ultrasonic transmitter circuit design
The schematic diagram of the ultrasonic transmitter circuit is shown in Figure 3. The transmitting circuit is mainly composed of an inverter 74LS04 and an ultrasonic transmitting transducer B1. The 40 kHz square wave signal output from the P1.0 port of the single-chip microcomputer is sent to one electrode of the ultrasonic transducer after passing through the inverter, and the other is passed through two The stage inverter is sent to the other electrode of the ultrasonic transducer, and the square wave signal is added to the two ends of the ultrasonic transducer in this push-pull form, which can increase the ultrasonic emission intensity. The output terminal adopts two inverters in parallel to improve the driving ability. On the one hand, the upper resistors R1 and R2 can improve the high-level driving capability of the inverter 74LS04, and on the other hand, it can increase the damping effect of the ultrasonic transducer and shorten its free oscillation time.
2.3 Ultrasonic detection and receiving circuit
The ultrasonic signal is reflected back when it hits a moving object after traveling a certain distance in the air. The principle of the ultrasonic receiving circuit is shown in Figure 4. It uses the integrated circuit CX20106A. CX20106A is a chip that integrates signal amplification, shaping, filtering, and detection. It can be used to make ultrasonic detection and receiving circuits. In the figure, by appropriately changing the size of C3, the sensitivity and anti-interference ability of the receiving circuit can be changed.
Working principle: When the ultrasonic receiving probe receives the ultrasonic signal, the CX20106A integrated chip presses the piezoelectric crystal to vibrate and converts the mechanical energy into an electrical signal. After receiving the electrical signal by the infrared detector receiving integrated chip CX20106A, it recognizes the connected signal If the frequency is about 38 kHz to 40 kHz, the output is low level, otherwise the output is high level.
2.4 Control and display module
This system uses AT89C51 as the data processing chip. The single-chip microcomputer system composed of AT89C51 is shown in Figure 5. The clock uses an external 12MHz oscillator circuit, and the system is reset through the S key. P1.0 port is connected with the ultrasonic transmitter circuit, and P3.2 port is connected with the ultrasonic receiver circuit. The system adopts LCD1602A LCD screen. The first and second pins of LCD1602 liquid crystal are connected to the driving power: the third pin VL is the contrast adjustment of the liquid crystal. By connecting a 10K multi-turn adjustable resistor between VCC and GND, the middle tap is connected to VL to realize liquid crystal Contrast adjustment; LCD control lines RS, R/W, E are respectively connected to P2.5, P2.6, P2.7 of the single-chip microcomputer; the data port is connected to the P0 port of the single-chip microcomputer; BL+, BL- are the power supply of the liquid crystal backlight. Liquid crystal LCD1602 has the advantages of ultra-thin, low power consumption, small size, etc., and is widely used in low-power electronic products and smart meters.
3 System software design
The software design of ultrasonic velocity measurement is mainly composed of the main program, the ultrasonic generation subroutine, the ultrasonic receiving program, the object motion velocity program and the display subroutine, and it is programmed in C language.
The designed ultrasonic speed measurement system has both time difference method and frequency difference method for speed measurement. After the microcontroller is initialized, the launch subroutine is called. The microcontroller generates a 40kHz square wave, which is output by port P1.0, and is output by B1 through the ultrasonic transmitter circuit. At the same time, it is a timer. T0 starts timing. When the ultrasonic signal hits the object and reflects back, when the receiver receives the echo signal, the timer T0 stops working, and the timer T1 starts at the same time. When the next rising edge comes, the timer T1 stops timing, according to P3 .When the port 2 is low level, the timer T0 will stop, the data of T0 is stored as △t1, and the timer T1 will be started at the same time. When the P3.2 level jumps to the high level and the next low level comes, T1 The timing stops, and the T1 data is stored as t, and T0 repeats the timing to obtain data △t2. After obtaining the timer data, use the two time records of timer T0 to obtain the speed of movement of the object using the time difference method, and use the time record of timer 1 to obtain the frequency of the echo signal, and then use the principle of frequency difference to obtain the object speed. The main program flow chart of ultrasonic speed measurement is shown in Figure 6.
4 System performance analysis
4.1 Speed measurement by time difference method
In the time difference method of speed measurement, the 40 kHz square wave has a wavelength of 25μs. According to the requirements of the ultrasonic speed measurement system, when the measurement distance is less than 10m, set the sound speed at this time to 340m/s, then for the two launches of the time difference method The time spent with receiving can be controlled within 0.09 s, and the system can realize the design requirement that the measurement period does not exceed 0.1 s.
4.2 Frequency difference method for speed measurement
In the frequency difference method, the cycle of the echo signal is captured. The accuracy loss of the measurement is mainly due to the circuit and the continuous running speed. Another factor that affects the measurement accuracy is the fluctuation of the ambient temperature. In general, the temperature is relatively constant, so the measurement accuracy Relatively high, the system can achieve the expected accuracy requirement of 0.1 m/s. When the measurement period is less than 30 m, the sound velocity is set to 340 m/s, and the measurement period is less than 0.09 s. The design requirements of the speed measurement system.
5 Conclusion
In the article, the method of measuring speed with ultrasonic time difference method and frequency difference method at the same time is proposed. The system is based on the single-chip AT89C51, integrates the time difference method and frequency difference method speed measurement in the same system, and completes the design of the hardware circuit and software of the system. Analysis shows that this system has reasonable design of software and hardware, strong anti-interference ability, and good real-time performance. After system expansion and upgrade, it can effectively solve the position monitoring of car reversing, construction sites and some industrial sites.