The hardware part of this system mainly includes: single chip system module, temperature acquisition module, ultrasonic transceiver module, digital tube display module, sound and light alarm module, battery voltage measurement module, lithium battery charging module, button module, voltage reduction module, and serial download interface module . The hardware components are shown in the figure below.
This system uses the STC8H1K16 microcontroller. The microcontroller has its own A/D conversion module, which eliminates the need for an external A/D conversion chip, saving costs and simplifying the circuit. The microcontroller has 26 I/O ports , which can directly drive peripherals such as digital tubes without the need to expand additional I/O ports. It has up to five 16 - bit timers, 1K RAM and 16K ROM inside to meet the design needs of this system . Low price is also its advantage. Before the domestic microcontroller prices increased significantly, the unit price of this type of microcontroller was around 1.6 yuan, which was very cost-effective.
The STC8H1K16 microcontroller pin function diagram is shown in the figure:
The ultrasonic transceiver part uses the HC-SR04 ultrasonic transceiver module.
The ranging range and ranging accuracy of this module meet the design requirements of the system. And the price of this module is low, which can save the cost of the system.
The actual picture of the ultrasonic module is shown in the figure:
The working principle of HC-SR04 ultrasonic module is shown in the figure:
The microcontroller sends a 10us control pulse to the control terminal TRIG , and the ultrasonic module starts to work. Cyclically emit 8 40KHZ ultrasonic oscillating sound waves. The time from transmission to reception of the ultrasonic wave is the duration of the high level of the ECHO pin. The microcontroller can accurately measure the distance of the measured object by reading the duration of the ECHO high level, plus the measured ambient temperature information, and through compensation calculations.
The wiring diagram of the ultrasonic module and microcontroller is as shown in the figure:
The ultrasonic module is powered by 3.3V voltage. Similarly, a 100nF decoupling capacitor is added between the VCC pin and the GND pin to avoid interference from other components or electromagnetic waves. The TRIG pin is connected to an I/O port of the microcontroller, and the ECHO pin is also connected to an I/O port of the microcontroller.
The voltage of lithium battery is directly proportional to the power of the battery, which can reflect the power of the battery from a certain perspective. Since the lithium battery used in this system does not have a hardware lithium battery protection module, in order to prevent the battery from being overcharged and affecting the battery life, and so that the user can know the remaining battery power, a battery voltage detection module is added to this system.
The battery voltage measurement module circuit is shown in the figure:
This module has two networks connected to the microcontroller, namely the "OUT2" network and the "ADC" network. When the "OUT2" network outputs low level, S8050 is cut off, the SI2302 MOS tube is in the off state, and the voltage dividing circuit composed of two 100K resistors is disconnected. This state is to save power consumption. When the "OUT2" network outputs high level, the S8050 transistor is turned on, the SI2302 MOS tube is in a low resistance state, the voltage divider circuit composed of two 100K resistors starts to work, and the A/D conversion function pin of the microcontroller is connected through the "ADC" network Divide the voltage portion and measure the voltage. The function of the resistor R5 is to limit the current and prevent the output current of the microcontroller from being too large. The resistor R7 and the transistor form a logic circuit, which is responsible for providing high and low levels for the MOS tube, and also has the function of discharging the charge of the MOS tube. R10 and R13 form a battery voltage dividing circuit to convert the battery voltage to within the A/D reference voltage. C13 functions to stabilize the voltage and prevent voltage mutations from interfering with the accurate measurement of the battery voltage.
The main component of this module is the TP4056 lithium battery charging chip.
The pins and functions of TP4056 are as shown in the figure:
The lithium battery charging module circuit is shown in the figure:
This circuit is designed based on the data sheet of the TP4056 lithium battery charging chip. The 5V power input interface uses a MICRO-USB interface, which is compatible with most data cables on the market and has good compatibility. R9 is a current limiting resistor, which plays a role in protecting the chip. C3 and C8 are input power supply filter capacitors that filter out low-frequency ripples and high-frequency ripples, making the input voltage smoother. Similarly, C4 and C9 also play a filtering role, making the current charged to the battery smoother. LED1 and LED2 form the display part, which is used to display the charging status of the battery. When it is still charging, the red LED2 lights up, and when the charging is completed, the blue LED1 lights up. R8 and R11 are LED current limiting resistors, and R12 is a current programming resistor. Different resistance values determine the maximum charging current of the lithium battery. Please refer to the figure for the specific relationship :
The lithium battery used in this system has a capacity of 400mAh. Considering the service life of the battery, the charging current cannot be too large or too small. If it is too large, it will affect the battery life. If it is too small, the charging time will be long. Finally , R12 with a resistance of 4.7K was chosen. The resistor is used as a current programming control resistor, and the maximum charging current is about 255mA .
The main features of the system are as follows :
(1) Easy to operate: The system has only one control button. The user only needs to press the button, and the system can measure the distance and display the result.
(2) Low power consumption: The operating current of the system is only about 20mA during normal operation , and it can theoretically work continuously for 20 hours using a 400mAh small-capacity polymer lithium battery .
(3) High accuracy: In the actual verification process, the accuracy of the ultrasonic range finder can reach 1cm
(4) Sensitive response: During the actual operation, the system was responsive and there was no lag.
This system is of great significance to the development of ultrasonic ranging, but it also has some shortcomings:
(1) The object to be measured is preferably a flat object. Objects with complex shapes will interfere with the ranging of the rangefinder and cause inaccurate ranging results.
(2) The ranging accuracy is affected by the ranging distance. When the ranging distance is larger, the ranging accuracy will decrease.
(3) The automatic standby function is not perfect. Currently, it can only reduce power consumption by reminding the user to shut down, which is not intelligent enough. In the future, the hardware circuit and program will need to be improved to realize automatic standby.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet