Detailed Design Of Electronic Circuit For Measuring Distance By Ultrasound

- Mar 22, 2019-

In the autonomous walking robot system, in order to walk in unknown and uncertain environments, the robot must collect real-time environmental information in order to avoid obstacles and navigate, which must rely on the sensor system that can realize environmental information perception. Sensors such as vision, infrared, laser and ultrasonic are widely used in walking robots. Because of its simple equipment, cheap price, small size, simple design, easy to achieve real-time control, and can meet the requirements of industrial application in measuring distance and measuring accuracy, the ultrasonic ranging method has been widely used. The robot introduced in this paper adopts a tripartite ultrasonic ranging system, which can provide information about the distance of the robot to recognize the front, left and right environments of its motion.




Principle of ultrasonic ranging




The inner part of the ultrasonic generator is composed of two piezoelectric plates and a resonant plate. When the external pulse signal is applied at its two poles and its frequency is equal to the natural oscillation frequency of the piezoelectric wafer, the piezoelectric wafer will resonate and drive the resonant plate to vibrate, and then the ultrasonic wave will be generated. Conversely, if there is no external voltage between the two poles, when the resonant plate receives the ultrasonic wave, it becomes the ultrasonic receiver. Ultrasound ranging generally has two methods: 1. Take the average voltage of output pulse, which is proportional to the distance, and measure the distance by measuring the voltage; 2. Measure the width of output pulse, that is, the time interval t between transmitting and receiving ultrasound, and get the distance by measuring the distance S = V t? 2. Because the velocity V of ultrasound is related to temperature, if the temperature changes greatly. It should be corrected by means of temperature compensation.




The second method is used in this measurement system. Because the measurement accuracy is not particularly high, it can be considered that the temperature is basically unchanged. This system takes PIC16F877 as its core, realizes its real-time control of peripheral circuit through software programming, and provides the signal needed by peripheral circuit, including frequency vibration signal and data processing signal, thus simplifying the peripheral circuit, and has good transplantation. The block diagram of the system hardware circuit is shown.






Block diagram of system hardware circuit




Because the system only needs to know whether there are obstacles in front, left and right of the robot, and not the specific distance between the obstacles and the robot, so it does not need to display circuit, only need to set a distance threshold, so that when the distance between the obstacle and the robot reaches a certain value, the single chip computer controls the motor of the robot to stop, which can be realized by software programming.





Ultrasound Transmitting Circuit




PIC16F877 is the core of the ultrasonic transmitting circuit. When the MCU is on power, the MCU generates 40 kHz ultrasonic signal from RA0 port. But at this time, the signal can not enter the amplifying circuit through the non-gate to make the ultrasonic emitter emit ultrasound. Only when the switch S1 is closed, a gate-controlled signal is emitted from RA1 port. The frequency of the signal is 4 kHz, and the timer TM inside the MCU is activated. R1, start counting. Every time the gating signal transmits a period of waveform, the ultrasound will emit 10 complete waveforms, which can be derived from their frequencies. The period of ultrasound is 1 (40 kHz) = 01025 ms, while the period of gating signal is 1 (4 kHz) = 0125 Ms. Finally, the distance between obstacle and mobile robot is calculated according to s=vt2. When the ultrasonic receiver receives the reflected ultrasonic wave, the counter stops counting, and the time t can be calculated according to the counting of the counter and the period of the gated signal. RA2 port is connected with RS trigger, RS trigger can automatically control the emission and stop of ultrasound. The circuit of this system also includes manual reset circuit, which is controlled by MCL pin-to-pin S2, and the circuit diagram of ultrasonic transmission is shown.






Ultrasound Emission Circuit Diagram




Gated Circuit (RS Trigger)




In order to realize the automatic control of the transmission and reception of ultrasonic wave, a control circuit must be added to the circuit. The frequency of the gate control signal is 4 kHz. If the output pulse is used as the gate signal and the pulse of the known frequency fc passes through the gate, then t = NTc, where Tc is the period of the known pulse and N is the number of the pulses. Gating circuit is composed of RS flip-flops, which reset when input R = 1 (S = 0), i.e. output Q = 0, and set when R = 0 (S = 1), i.e. Q = 1. RS flip-flop is connected with the RA2 port of single chip computer.





Ultrasound amplifier circuit




Ultrasound amplification circuit is composed of triodes and so on. Because the single-chip computer RA port only has up-pull current of 20 mA to 25 mA at most, and the ultrasonic transmitter needs current of 60 mA at least, a first-order amplification circuit is added behind the non-door to amplify the current to complete the transmission of ultrasound. See the transmission circuit of ultrasonic amplification.






Ultrasound Receiving and Amplifying Circuit




Because the ultrasonic signal received by the ultrasonic receiver is very weak, an ultrasonic receiving amplifier circuit is needed after that. The circuit adopts two integrated operational amplifiers, which are designed as two stages and two stages are in-phase input. Because the voltage amplification factor of in-phase input is 1+RfR, the amplification factor of each stage is 10, and the amplification factor of two stages is close to 100 times. Thus, the input signal can be easily detected by subsequent circuits. The integrated operational amplifier is powered by dual power supply. The ultrasonic receiving amplifier circuit is shown in Fig. 4.






Figure 4. Circuit diagram of ultrasonic receiving and amplifying




Signal filter circuit




The sound wave from the signal amplification circuit has some interference. In order to remove the interference signal, a filter circuit is needed. The signal filter circuit uses a band-pass filter circuit, which has a center frequency of 40 kHz, a bandwidth of 2 kHz, and a zero-crossing comparator to convert the output signal into a square wave signal. The signal filtering circuit is shown in Fig. 5.






Figure 5 Signal filter circuit diagram




Signal shaping circuit




The way out of the signal filter circuit