The following is the actual picture:
I. Introduction
Background:
In daily life and industrial control, position monitoring and distance measurement are often required. There are many methods available, including laser ranging, radar ranging, and ultrasonic ranging. Compared with microwave radar ranging and laser ranging, ultrasonic ranging has the advantages of strong directional directivity, relatively slow energy consumption, and relatively long propagation distance in the medium. However, since the propagation speed of sound is related to temperature, in general, the speed of sound will change by about 0.61 m/s for every 1°C change in temperature. Therefore, the accuracy of ultrasonic ranging is greatly affected by temperature. To achieve high-precision ultrasonic ranging, the impact of temperature changes on the speed of sound must be considered, so as to make necessary compensation.
Current status of development at home and abroad:
In the past decade, domestic researchers have conducted a lot of theoretical analysis and research on ultrasonic echo signal processing methods, new ultrasonic transducer development, and ultrasonic transmission pulse selection. They have also proposed temperature compensation and automatic gain adjustment in the receiving circuit to improve the accuracy of ultrasonic ranging. At present, domestic low-power ultrasonic probes are generally not used to detect objects beyond 15m. The Airducer AR30 ultrasonic sensor produced by AIRMAR in the United States has an effective range of up to 30m, but the price is relatively high. With the continuous development of sensors and single-chip control technology, non-contact detection technology has been widely used in many fields.
Requirements for the project design:
The specific requirements are:
1) Use ultrasonic sensors to achieve non-contact distance measurement and use temperature sensors for ultrasonic compensation. Students are required to design a hardware structure diagram based on the information of each sensor and its application methods.
2) Master the ability to design and draw hardware circuit diagrams based on hardware structure diagrams, and build, install and manufacture hardware.
3) Master the basic methods of debugging hardware using various instruments and equipment, such as multimeters, oscilloscopes, etc.
4) Record the experimental data, use data processing methods and related software to process and analyze the experimental data, compare it with the actual data results, and draw meaningful conclusions.
2. Overall solution design
System solution block diagram:
Option One:
System working principle and functions:
When the system is working, the microcontroller provides a 40 kHz pulse signal, which is amplified and output through the ultrasonic transmitter. Ultrasonic waves propagate in the air, and are reflected back when they reach the object to be measured, and are received by the ultrasonic receiver. When the ultrasonic receiver receives the reflected wave, it is first amplified by the amplifier, and then a negative jump is generated after the phase-locked loop circuit detection processing, and an interrupt request signal is generated in INT0. The microcontroller responds to the external interrupt request and executes the external interrupt service program. When the microcontroller starts the transmitting circuit, it also starts the timer T0 inside the microcontroller, and uses the timer to record the time of ultrasonic emission and the time of receiving the reflected wave. Read the time difference in the external interrupt program to calculate the distance. The temperature compensation link is: temperature compensation link, assuming that the ultrasonic speed is v, the round-trip time is t, and the temperature is T, v = 331.5 + 0.61T, and the distance is obtained by dividing the speed by two.
Option II:
System working principle and functions:
The interface sends a pulse trigger signal of ≥10 μs to the trigger pin. The module will emit 8 40 kHz cycle levels and detect echoes. Once an echo signal is detected, pin 3 will output an echo signal. The measured distance is proportional to the pulse width of the echo signal. Therefore, the distance can be calculated from the time interval from transmitting the signal to receiving the echo signal.
The ultrasonic timing diagram is as follows:
Comparison and selection of solutions: From the overall system block diagram, it can be seen that the structure of Solution 2 is simpler, and the HC-SR04 module integrates the ultrasonic transmitting and receiving circuits, which is easy to use and cheap, so Solution 2 is selected.
3. Working Principle of Sensor
1) Temperature sensor DS18B20
The pin diagram of DS18B20 is shown in the figure on the right: UDD is connected to the power supply, GND is connected to the ground, and I/O is the data input/output port.
The read and write timing and temperature measurement principle of DS18B20 are the same as those of DS1820, except that the number of bits of the obtained temperature value varies due to different resolutions, and the delay time during temperature conversion is reduced from 2s to 750ms. The temperature measurement principle of DS18B20 is shown in the figure. The oscillation frequency of the low temperature coefficient crystal oscillator in the figure is little affected by temperature, and is used to generate a fixed frequency pulse signal to counter 1. The oscillation rate of the high temperature coefficient crystal oscillator changes significantly with temperature changes, and the generated signal is used as the pulse input of counter 2. Counter 1 and the temperature register are preset to a base value corresponding to -55℃. Counter 1 subtracts the pulse signal generated by the low temperature coefficient crystal oscillator. When the preset value of counter 1 is reduced to 0, the value of the temperature register will be increased by 1, the preset of counter 1 will be reloaded, and counter 1 will start counting the pulse signal generated by the low temperature coefficient crystal oscillator again. This cycle continues until counter 2 counts to 0, and stops accumulating the temperature register value. At this time, the value in the temperature register is the measured temperature. The slope accumulator in the figure is used to compensate and correct the nonlinearity in the temperature measurement process, and its output is used to correct the preset value of counter 1.
Ultrasonic module HC-SR04
The pin diagram of the HC-SR04 module is shown in the figure:
VCC Trig Echo GND
Vcc, Trig (control end), Echo (receiving end), Gnd, the working principle is as follows:
(1) Use IO to trigger the distance measurement and give a high-level signal of at least 10us;
(2) The module automatically sends 8 40khz square waves and automatically detects whether there is a signal return;
(3) When a signal is returned, a high level is output through IO. The duration of the high level is
(4) The time from the ultrasonic wave being emitted to returning. Test distance = (high level time * sound speed)/2;
4. Hardware Circuit Design
The overall hardware design schematic is shown in the figure below:
1) Temperature measurement module
For temperature measurement, select DS18B20. The microcontroller port is connected to the DS18B20 data bus. The DS18B20 is controlled to perform temperature conversion and transmit data. The data bus is connected to a 10kΩ pull-up resistor to prevent the bus controller from having to maintain a high level during temperature conversion. The DS18B20 protel hardware diagram is shown in the figure on the right.
Ultrasonic ranging module
This design uses the HC-SR04 module, uses the microcontroller IO to trigger the distance measurement, and gives a high-level signal of at least 10us; the module automatically sends 8 40khz square waves and automatically detects whether there is a signal return; if there is a signal return, a high level is output through the IO, and the duration of the high level is the time from the ultrasonic wave from emission to return. Test distance = (high level time * sound speed) / 2; HC-SR04 hardware protel diagram is shown in the figure below:
Digital tube display module
The digital tube used in this display is a common cathode digital tube, and the display content is the temperature value and the detected distance value. The microcontroller controls its segment selection code and bit selection code to control the lighting of the digital tube. At the same time, the display mode of the digital tube used in this experiment is dynamic display. The protel hardware diagram of the digital tube is shown in the figure below:
5. Software design and simulation debugging
Software design flow chart:
Main function flow chart
Process after adding temperature sensor and ultrasonic module
Simulation debugging
Since the ultrasonic sensor cannot be found in the proteus software, a square wave is used as the echo signal received by the microcontroller. The simulation results are shown in the figure below:
The left side of the picture shows the temperature of 29 degrees, and the right side shows the measured distance of 290cm.
Changing the echo signal frequency or changing the temperature value will result in different measured distances, as shown in the following figure:
Increasing the frequency of the echo signal, the results are as follows:
Increase the temperature value and the results are as follows:
At the same time, you can also use an oscilloscope to observe the waveforms of the transmitted signal and the echo signal, as shown in the following figure:
In the figure, the yellow represents the transmitted signal pulse (about 20us), and the red represents the echo signal waveform.
The final hardware debugging result is shown in the figure: the left side shows the distance before compensation, and the right side shows the distance after compensation
Previous article:Simulation Design of Signal Generator Based on Single Chip Microcomputer
Next article:51 MCU measures PWM pulse width LCD1602 displays current PWM duty cycle frequency
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Introduction to TI_DSP link command file (*.cmd)
- [N32L43x Review] 2. Turn on the lights, blink, blink, blink...
- EEWORLD University Hall - Talking about the development creativity of electronic products and using network resources to help development
- The output of the op amp in the active integrator circuit oscillates. What should I do?
- Developing Minitel Applications with ESP32 and MicroPython
- Tmall Murata official flagship store, spend 1000-200, get a gift! What do you want to buy this Double 11?
- Understanding of op amp parameters
- How to adjust the minimum spacing
- Celebrate National Day, play with Guoxin! Jiefa invites you to try out the AC7801x motor demo board for free
- 7 must-know PCB design tips for engineers