Seek a microcontroller-based ultrasonic rangefinder design of English information (with Chinese translation more beautiful, huh), graduation design. Thank you!

This article described the three directions (before, left, right) ultrasonic ranging system is to understand the front of the robot, left and right environment to provide a movement away from the information. (Similar to GPS Positioning System)

A principle of ultrasonic distance measurement

1, the principle of piezoelectric ultrasonic generator

Piezoelectric ultrasonic generator is the use of piezoelectric crystal resonators to work. Ultrasonic generator, the internal structure as shown in Figure 1, it has two piezoelectric chip and a resonance plate. When it's two plus pulse signal, it's two plus pulse signal, it's two plus pulse signal. it's two plus pulse signal, the frequency equal to the intrinsic piezoelectric oscillation frequency chip, the chip will happen piezoelectric resonance, and promote the development of piezoelectric crystal resonators to work. resonance, and promote the development of plate vibration resonance, ultrasound is generated. Conversely, if the two are not inter-electrode voltage, when the board received ultrasonic resonance, the board will not be able to resonate. Conversely, if the two are not inter-electrode voltage, when the board received ultrasonic resonance, it will be for vibration suppression of piezoelectric chip, the mechanical energy is converted to The mechanical energy is converted to electrical signals, then it becomes the ultrasonic receiver.

2, the principle of ultrasonic distance measurement

Ultrasonic transmitter in a direction to launch ultrasound, in the moment to launch the beginning of time at the same time, the spread of ultrasound in the air, obstacles on his way to return immediately. obstacles on his way to return immediately, the ultrasonic reflected wave received by the receiver immediately stop the clock. Ultrasound in the air as the propagation velocity of 340m / s, according to the timer records the time t, we can calculate the distance between the launch distance barrier (s), that is: s = 340t / 2

Ultrasonic Ranging System for the Second Circuit Design

System is characterized by single-chip microcomputer to control the use of ultrasonic transmitter. the use of ultrasonic transmitter and ultrasonic receiver since the launch from time to time, single-chip selection of 8751, economic-to-use, and the chip has 4K of ROM, which can be used to control the ultrasonic receiver. chip has 4K of ROM, to facilitate programming. Circuit schematic diagram shown in Figure 2. Draw only the front range of the circuit wiring diagram, left Draw only the front range of the circuit wiring diagram, left and right in front of Ranging Ranging circuits and the same circuit, it is omitted.

1,40 kHz ultrasonic pulse generated with the launch

Ranging system using the ultrasonic sensor of piezoelectric ceramic sensors UCM40, its operating voltage of the pulse signal is 40kHz, which by the

puzel: mov 14h, # 12h; ultrasonic firing continued 200ms

here: cpl p1.0; output 40kHz square wave

nop;

nop;

nop;

djnz 14h, here;

ret

Ranging in front of single-chip termination circuit P1.0 input port, single chip implementation of the above procedure, the P1.0 port in a 40kHz pulse output signal, after amplification transistor T, the drive to launch the first ultrasonic UCM40T, issued 40kHz ultrasonic pulse, and the continued launch of 200ms. Ranging the right and the left side of the circuit, respectively, then input port P1.1 and P1.2, the working principle and circuit in front of the same location.

2, reception and processing of ultrasonic

Used to receive the first launch of the first pair UCM40R, the ultrasonic pulse modulation signal into an alternating voltage, the opens the door to the right side of the circuit, the left side of the circuit, respectively. into an alternating voltage, the op-amp amplification IC1A and after polarization IC1B to IC2. IC2 is locked loop with audio decoder chip LM567, internal voltage-controlled oscillator center frequency. IC2 is locked loop with audio decoder chip LM567, internal voltage-controlled oscillator center frequency of f0 = 1/1.1R8C3, capacitor C4 determine their target bandwidth. R8-conditioning in the launch of the R8-conditioning in the launch of the carrier frequency on the LM567 input signal is greater than 25mV, the output from the high jump 8 feet into a low-level, as interrupt request signals to the

Ranging in front of single-chip termination circuit output port INT0 interrupt the highest priority, right or left location of the output circuit with output gate IC3A access INT1 port single-chip, while single-chip P1.3 and P1. 4 received input IC3A, interrupted by the process to identify the source of inquiry to deal with, interrupt priority level for the first left right after. Part of the source code is as follows:

receive1: push psw

push acc

clr ex1; related external interrupt 1

jnb p1.1, right; P1.1 pin to 0, ranging from right to interrupt service routine circuit

jnb p1.2, left; P1.2 pin to 0, to the left ranging circuit interrupt service routine

return: SETB EX1; open external interrupt 1

clr ex1; related external interrupt 1

pop? acc

pop? psw

reti

right: ...? ; right location entrance circuit interrupt service routine

? Return

left: ... ; left Ranging entrance circuit interrupt service routine

Right: ...? ; left Ranging entrance circuit interrupt service routine

? Return

4, the calculation of ultrasonic propagation time

When you start firing at the same time start the single-chip circuitry within the timer T0, the single-chip circuitry will start at the same time. Within the timer T0, the use of timer counting function records the time and the launch of ultrasonic reflected wave received time. When you receive the ultrasonic reflected wave, the receiver will be able to receive the ultrasonic reflected wave, the receiver will not be able to receive the ultrasonic reflected wave. When you receive the ultrasonic reflected wave, the receiver circuit outputs a negative jump in the end of INT0 or INT1 interrupt request generates a signal, single-chip microcomputer in response to external interrupt request, the implementation of the external interrupt service subroutine, read the time difference, calculating the distance . calculating the distance . Some of its source code is as follows:

RECEIVE0: PUSH PSW

PUSH ACC

CLR EX0; related external interrupt 0

? MOV R7, TH0; read the time value

MOV R6, TL0?

CLR C

MOV A, R6

SUBB A, # 0BBH; calculate the time difference

MOV 31H, A; storage results

MOV A, # 0BBH. storage results

MOV A, R7

SUBB A, # 3CH

MOV 30H, A?

SETB EX0; open external interrupt 0

POP ACC? p> RETI

Fourth, the ultrasonic ranging system software design

Software is divided into two parts, the main program and interrupt service routine, shown in Figure 3 (a). routine, shown in Figure 3 (a) (b) (c) below. Completion of the work of the main program is initialized, each sequence of ultrasonic transmitting and receiving control.

Interrupt service routines from time to time to complete three of the rotation direction of ultrasonic launch, the main

Interrupt service routines from time to time to complete three of the rotation direction of ultrasonic launch, the main interrupt service subroutine to read the value of completion time, distance calculation, the results of the output and so on.

V. CONCLUSIONS

Required measuring range of 30cm ~ 200cm objects inside the plane to do a number of measurements found that the maximum error is 0.5cm, and good reproducibility. Single-chip design can be seen on the ultrasonic ranging system has a hardware structure is simple, reliable, small features such as measurement error. Therefore, it can be used not only for mobile robot can be used in other detection systems.

Thoughts: As for why the receiver do not have the transistor, it can be used in other systems. receiver do not have the transistor amplifier circuit, because the magnification well, CX20106 integrated amplifier, but also with automatic gain control level, magnification to 76dB. control level, magnification to 76dB, the center frequency is 38k to 40k, is exactly resonant ultrasonic sensors frequency

=====

This article introduces the The three-direction (front, left and right) ultrasonic ranging system is to provide a motion distance information for the robot to understand its environment in front, left and right side. (Similar to the GPS positioning system)

A principle of ultrasonic ranging

1, the principle of piezoelectric ultrasonic generator

Piezoelectric ultrasonic generator is actually the use of piezoelectric crystal resonance to work. The internal structure of the ultrasonic generator is shown in Figure 1, which has two piezoelectric wafers and a **** vibration plate. When its poles plus a pulse signal, its frequency is equal to the piezoelectric chip's intrinsic oscillation frequency, the piezoelectric chip will occur *** vibration, and drive the *** vibration plate vibration, it produces ultrasonic waves. On the contrary, if the two electrodes are not applied voltage, when the *** vibration plate receives ultrasonic waves, will force the piezoelectric chip for vibration, the mechanical energy is converted into electrical signals, then it becomes an ultrasonic receiver.

2, ultrasonic ranging principle

Ultrasonic transmitter to a certain direction to launch ultrasonic waves, the moment of launching at the same time to start timing, ultrasonic waves propagate through the air, on the way to encounter obstacles immediately return to the ultrasonic receiver to receive the reflected wave will immediately stop timing. Ultrasonic propagation speed in the air for 340m / s, according to the timer recorded time t, you can calculate the launch point from the obstacle distance (s), that is: s = 340t / 2

Two ultrasonic distance measurement system circuit design

System is characterized by the use of microcontroller control of ultrasonic emissions and ultrasonic emissions from the reception of round-trip time of the time of the timing, microcontroller Selected 8751, economical and easy to use, and the chip has 4K ROM, easy to program. Circuit schematic shown in Figure 2. Which only draws the wiring diagram of the front ranging circuit, the left and right ranging circuit is the same as the front ranging circuit, so omit it.

1, 40kHz pulse generation and ultrasonic emission

Ranging system in the ultrasonic sensor using UCM40 piezoelectric ceramic sensor, its operating voltage is a 40kHz pulse signal, which is generated by the microcontroller to perform the following program.

puzel: mov 14h, #12h; ultrasonic emission lasts 200ms

here: cpl p1.0; outputs a 40kHz square wave

nop;

nop;

nop;

nop;

djnz 14h, here;

ret<

The input of the front distance measuring circuit is connected to the P1.0 port of the microcontroller, and after the microcontroller executes the above program, it outputs a 40kHz pulse signal at the P1.0 port, which is amplified by the transistor T, and drives the ultrasonic transmitter head, UCM40T, to emit a 40kHz pulsed ultrasonic sound, and continues to emit the sound for 200 ms. The inputs of the right and left distance measuring circuits are connected to the P1.1 and P1.2 ports, respectively. The inputs of the right and left distance measuring circuits are connected to the P1.1 and P1.2 ports respectively, and the working principle is the same as that of the front distance measuring circuit.

2, ultrasonic reception and processing

Receiver head and transmitter head paired UCM40R, ultrasonic modulation pulse into alternating voltage signal, amplified by operational amplifiers IC1A and IC1B poles to the IC2. IC2 is a locked-loop audio decoder integrated block LM567, the internal voltage-controlled oscillator center frequency f0 = 1/1.1R8C3, the internal voltage-controlled oscillator center frequency f0 = 1/1.1R8C3, and the internal voltage-controlled oscillator center frequency f0 = 1/1.1R8C3. The center frequency of the internal voltage controlled oscillator f0=1/1.1R8C3, capacitor C4 determines its locked bandwidth. Adjust R8 on the carrier frequency of the transmitter, then the LM567 input signal is greater than 25mV, the output pin 8 from the high level jumped to a low level, as an interrupt request signal, sent to the microcontroller processing.

The output of the front ranging circuit is connected to the INT0 port of the microcontroller, with the highest interrupt priority. The output of the left and right ranging circuits is connected to the INT1 port of the microcontroller through the output of the gate IC3A, while the P1.3 and P1.4 of the microcontroller are connected to the input of the IC3A, and the recognition of the interrupt source is handled by the program query with the interrupt priority of the right first and then the left. Part of the source program is as follows:

receive1: push psw

push acc

clr ex1; turn off external interrupt 1

jnb p1.1, right; P1.1 pin 0, go to the right ranging circuit interrupt service program

jnb p1.2, left ; P1.2 pin 0, go to the left distance measuring circuit interrupt service program

return: SETB EX1; open external interrupt 1

pop? acc

pop? psw

reti

right: ...? right: ...; right ranging circuit interrupt service program entry

? ajmp? return

left: ...? Left: ...; left ranging circuit interrupt service program entry

? ajmp? return

4. Calculate the ultrasonic propagation time

Start the timer T0 inside the microcontroller at the same time of starting the transmitter circuit, and use the counting function of the timer to record the time of ultrasonic wave transmission and the time of receiving the reflected wave. When the reflected ultrasonic wave is received, a negative jump is generated at the output of the receiving circuit, and an interrupt request signal is generated at the INT0 or INT1 terminal, and the microcontroller responds to the external interrupt request, executes the external interrupt service subroutine, reads the time difference, and calculates the distance. Part of the source program is as follows:

RECEIVE0: PUSH PSW

PUSH ACC

CLR EX0 ; Off external interrupt 0

? 3CH

MOV 30H, A?

SETB EX0; turn on external interrupt 0

POP ACC?

POP PSW

RETI

Four, ultrasonic distance measurement system software design

Software is divided into two parts, the main program and interrupt service program, as shown in Figure 3 (a)(b)(c). )(b)(c) shown. The main program completes the initialization work, the control of each ultrasonic transmission and reception sequence.

Timing interrupt service subroutine completes the three-direction ultrasonic emission in turn, and the external interrupt service subroutine mainly completes the work of time value reading, distance calculation, and output of results.

V. Conclusion

The required measurement range of 30cm ~ 200cm within the plane object to do a number of measurements found that the maximum error of 0.5cm, and good repeatability. It can be seen that the ultrasonic ranging system designed based on microcontroller has the characteristics of simple hardware structure, reliable operation and small measurement error. Therefore, it can be used not only for mobile robots, but also in other detection systems.

Think: as to why the reception does not use transistors to do the amplifier circuit, because the amplification can not get it right, CX20106 integrated amplifier circuit, but also with automatic level gain control, amplification of 76dB, the center frequency is 38k to 40k, just the resonant frequency of the ultrasonic transducer