High-performance RISC CPU adopts RISC architecture, with only 37 single instructions (all other instructions except program jump instructions are single cycle instructions, and program jump instructions are double cycle instructions

Source: Solution Development Department Date: 2020-11-25

Design thinking analysis
This design circuit includes ultrasonic transmitter and receiver circuits, 51 single chip microcomputer, LCD liquid crystal display, infrared remote control, temperature acquisition and other peripheral auxiliary circuits. By writing the corresponding program, the 51 single-chip microcomputer can control the entire system to work stably, realize the measurement of the actual distance, and display the measurement results on the LCD screen and a series of functions. In the ultrasonic distance measurement system, it is mainly the control of ultrasonic transmission and reception, as well as the calculation and processing of the transmission and reception time. The design principle and process of the ultrasonic ranging system are described in detail below.
1. What is ultrasound
Ultrasound is a sound wave with a frequency higher than ⒛ kHz. It is a straight-line propagation method and has good directivity. The higher the frequency, the weaker the diffraction ability, but the stronger the reflection ability. It can travel long distances in air, water and other media. Used for distance measurement, speed measurement, cleaning, welding, stone crushing, sterilization and disinfection. It is widely used in medicine, military, industry and agriculture. Ultrasound gets its name because its lower frequency limit is approximately equal to the upper limit of human hearing.
In the air, the attenuation of ultrasonic waves is very sensitive to the frequency r, so the ultrasonic frequency should be selected reasonably, generally around 40kHz. Ultrasonic waves with too high frequency cannot spread in the air. The operating frequency of the sensor is the main technical parameter of the ranging system, which directly affects the diffusion and absorption loss of ultrasonic waves, the reflection loss of obstacles and background noise, and directly determines the size of the sensor. The working frequency of the sensor is determined based on the following considerations:
① If the ability of distance measurement is very high, the sound wave propagation loss will increase relatively. Since the absorption of sound waves by the medium is proportional to the square of the sound wave frequency, in order to reduce the sound wave propagation loss, the operating frequency must be lowered.
② The higher the working frequency, the stronger the directionality of the sensor relative to the transducer of the same size, the more accurate the measurement of the complex surface of the obstacle, the shorter the wavelength, the higher the size resolution, and the "details" are easy to identify. The surface and measurement of complex obstacles require an increase in operating frequency.
③ From the perspective of sensor design, the lower the operating frequency and the larger the sensor size, the more difficult it is to manufacture and install.
In summary, select the operating frequency of the rangefinder as 40kHz. In this way, the sensor has strong directivity, avoids noise, and improves the signal-to-noise ratio. Although the propagation loss is increased relative to low frequency, it will not cause difficulties in transmission and reception.
2. Transmit pulse width
The transmitted pulse determines the measurement blind zone of the rangefinder, and also affects the measurement, and at the same time is related to the emission energy of the signal. Reducing the transmission pulse width can improve the measurement and reduce the measurement blind area, but it also reduces the transmission energy, which is not good for receiving echo. Finally, a short-distance (within 2m) transmission pulse width of ⒛0us (8 40kHz square wave pulses) is adopted, and a long-distance (2m outside) transmission pulse width of 800us (32 40kHz square wave pulses) is transmitted. At the same time, the MCU program avoids blind spots. At this time, it is more appropriate to measure the pulse width from the two aspects of receiving echo signal amplitude and measuring blind area, and the receiving is accurate and the response speed is fast. Therefore, in general long-distance ranging, a pulse width of 800us is selected.
3. The principle and measurement method of ultrasonic ranging

Ultrasonic distance measurement methods include pulse echo method, resonance method and frequency difference method. Among them, the pulse-echo method of ranging is common. It is mainly based on the identification of the echo signal of ultrasonic ranging, and it is realized with a circuit using an analog method, as shown in Figure 1.

Figure 1 Principle of Ultrasonic Ranging

The principle of ranging is that the ultrasonic sensor emits ultrasonic waves, which propagate in the air to the measured object. After reflection, the ultrasonic sensor receives the reflected pulse, and measures the time from emission to reception of the ultrasonic pulse. Under the premise of known ultrasonic sound velocity, use the formula

When the measured distance S is less than the blind zone distance h (h=2m), the distance S between the sensor and the reflection point can be calculated, and the measurement distance formula is

When the measured distance S>=h, d is approximately equal to S, that is
4. Processing of ultrasonic measurement data
In the entire ultrasonic ranging system, the single-chip microcomputer is systematic, and it controls the working process of the entire system. The single-chip microcomputer makes the ultrasonic transmitter module emit a signal with a frequency of 40kHz, which is amplified and output by the ultrasonic transducer, and at the same time, the timer starts to count. After the signal is reflected by an obstacle, it is collected by the ultrasonic receiving module. Through the signal detection and amplification, the phase-locked loop locks the signal, generates a lock signal to start the MCU interrupt program, and obtains the time; then the system software performs the time After calculation and discrimination, the corresponding calculation results are sent to the LCD liquid crystal display circuit for display.
hardware design
MCU control part
Figure 2 The hardware circuit of the microcontroller
Ultrasonic module part
The HC-SR04 ultrasonic distance measuring module can provide 2cm-400cm non-contact distance sensing function, measuring
The distance can reach up to 3mm; the module includes an ultrasonic transmitter, receiver and control circuit.

Basic working principle:

(1) Use IO port TRIG to trigger distance measurement, giving a high level signal of less than 10us.
(2) The module automatically sends 8 40khz square waves, and automatically detects whether there is a signal return;
(3) There is a signal return, a high level is output through the IO port ECHO, and the duration of the high level is the ultrasound
The time from launch to return of the wave. Test distance = (high level time * speed of sound (340M/S))/2;
LCD display part
The LCD in this system uses a 1602 character liquid crystal module, which can display 16 characters × 2 lines or 32 characters at the same time. The controller of 1602 liquid crystal module adopts HD44780. The pin description of 1602 liquid crystal module is listed in Table 1.
Design of Ultrasonic Distance Measuring System Based on 51 Single Chip Computer and LCD Liquid Crystal Display
Table 1 LCD1602 LCD module function table
According to the 1602 pin table of Table 1, the hardware circuit of LCD display can be easily designed. The hardware circuit of LCD1602 liquid crystal display module is shown in Figure 3.

software design
The software system design is the same as the hardware design. The whole system can be divided into different modules according to the function. This is convenient for software writing and management, and also for system debugging. In this system, the whole system can be divided into the following functional modules: main program, infrared remote control receiving subprogram, temperature detection subprogram, ultrasonic emission subprogram, ultrasonic receiving interruption and calculation display subprogram.

To

Development strength

Professional and experienced software and hardware

Global channels

Provide customers with cost-effective products and services

Quality Assurance

The professional test guarantee team guarantees the stability

After-sales service

Professional technical service team, 24 hours to provide customers