The system consists of two parts: hardware and application software. The hardware part is composed of an ultrasonic ranging module and an interface module, and the software part is composed of a single-chip control program and a warning processing interface.
The specific working process of the ultrasonic ranging module is as follows. After the single-chip microcomputer generates a reset signal, a control signal is generated to control the ultrasonic transmitter circuit to generate an intermittent 40kHz driving square wave, which is added to the ultrasonic transmitter to emit an ultrasonic wave with a frequency of 40kHz.
At the same time, the internal timer of the single-chip microcomputer is started. After the ultrasonic wave encounters obstacles and reflects back, it is received by the ultrasonic receiver and processed by the ultrasonic receiving circuit to generate a receiving signal, which is used as the input capture mark of the internal timer of the single-chip microcomputer to measure The time it takes for the ultrasonic signal to be sent out to receive, and to complete an ultrasonic ranging time operation. At the same time, the current ambient temperature is measured by the temperature compensation circuit, read into the single-chip microcomputer, and then processed by it to calculate a more accurate sound velocity to obtain a more accurate distance, and display the corresponding distance measurement value on the display module as well as Current Temperature.
The ultrasonic transmitter circuit uses a 555 timer to generate a 40kHz drive square wave. The ultrasonic receiving circuit uses an ultrasonic receiver paired with the transmitter to convert the ultrasonic modulated pulse into an alternating voltage signal. The processing of the received signal adopts the infrared receiving chip CX20106A. The single-chip microcomputer is the core of the system control. Its peripheral circuits include power supply circuit, reset circuit, oscillation circuit, which is the smallest system of the single-chip microcomputer, and display module circuit, temperature sensing circuit, and USB interface circuit to achieve control of transmitting and receiving, temperature measurement, and distance measurement. Systematic function of display and communication with computer.
The STC89C51 can be selected as the single-chip microcomputer to meet the processing requirements;
The display device can be a nixie tube or a liquid crystal display, or this hardware module can be omitted, and the user interface can be displayed on the computer monitor;
The temperature sensor adopts the digital temperature sensor DS18B20, which has high measurement accuracy and convenient application;
As for the USB interface circuit, because the device only needs to transfer the measured data to the USB interface and does not need to obtain the data from the computer, it can use the USB-to-serial chip CP2101, which can easily turn the computer’s USB interface into a single-chip microcomputer. A serial port that can be used directly.
The MCU control program flow is as follows: First, the system is initialized, and then the following operations are mainly performed every 2 seconds:
1. Read the temperature value measured by the temperature sensor circuit, convert it into a certain data format and store it.
2. The single-chip microcomputer controls the ultrasonic transmitter circuit to transmit 2ms ultrasonic waves, and at the same time start T0 timing
Device.
3. Waiting for the interrupt signal, that is, waiting for the received signal of the echo.
4. After the MCU receives the interrupt signal, it enters the interrupt service routine, closes T0, calculates the time from ultrasonic transmission to reception, and then uses the temperature information to compensate for the speed of sound to calculate the final measured distance.
5. The microcontroller sends the measured distance to the USB interface.
6. Execute the display subroutine every 4ms to refresh the digital tube. The system application software process is shown in Figure 6. Define a counter, and then continuously read the data of the USB port. When there is data sent, it will be compared with the set minimum distance. ) When the distance is less than the minimum distance, a warning window will pop up, otherwise the counter will be cleared to 0 after returning. This can avoid false alarms when the user accidentally enters the warning distance, and can also ensure that the user has a warning effect.
In addition, the user interface also provides functions such as data modification and password protection, and you can choose whether to display the distance on the display according to your needs. There are other embodiments of the present invention. For example, other square wave generating circuits can be used for ultrasonic transmission, and audio decoding integrated chips can be used for ultrasonic receiving processing; the display circuit can be a liquid crystal display or directly displayed on a computer screen; and the interface circuit can be based on Need to use serial interface or parallel interface, can also be directly integrated into the display.
The above content is a further detailed description of the present invention in combination with specific preferred modes, and it cannot be considered that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, without departing from the concept of the present invention, several simple deductions or substitutions can be made, all of which should be regarded as within the scope of the patent as determined by the claims submitted by the present invention.
