Ultrasonic rangefinders are widely used in car reversing, construction sites and some industrial sites. Its measurement range is 0.10~4.0 m, and the measurement accuracy can be as high as about 1 cm.
This design uses the new 8051 controller c8051f020, and the system uses a 22.1184MHZ high-precision crystal oscillator to obtain a stable time frequency to reduce measurement errors. C8051f020 uses the P3.0 port to output the 40khz square wave signal required by the ultrasonic transducer, and uses the interrupt port to detect the return signal output by the ultrasonic receiving circuit. The display circuit uses an SPI extended LCD1602 liquid crystal.
The focus of this design is the ultrasonic receiving and transmitting circuit.
The ultrasonic transmitting circuit is shown in Figure 1.2
Figure 1.2
The transmitting circuit is mainly composed of the inverter 74HC04 and the ultrasonic transducer. The 40khz square wave signal output from the P3.0 port is sent to one electrode of the ultrasonic transducer through the inverter, and the other is sent to the other electrode of the ultrasonic transducer after passing through two-stage inverters. This method can improve the transmission intensity of the ultrasonic wave.
The ultrasonic receiving circuit is shown in Figure 1.3
Figure 1.3
Integrated circuit CX20106A is a dedicated chip for infrared reception, commonly used in TV infrared remote controls. The commonly used carrier frequency 38khz is close to the 40khz of distance measurement, so it can be used as a receiving circuit. Appropriately changing the size of C3 can change the sensitivity and anti-interference ability of the receiving circuit.
The display circuit is shown in Figure 1.4
Use the SPI of c8051f020 to drive 595 to control lcd1602. LCDCS is the chip select signal of 595.
This design defines the chip select signal as P3.1.
sbit LCDCS P3^1;
Another focus is the algorithm calculation of ultrasonic ranging.
D = S/2(v+t)/2 --------------------------------------------------------------------------- (1-1)
Where D is the distance between the object to be measured and the rangefinder.
S is the round trip distance of the sound wave.
V is the speed of sound.
T is the time taken.
C8051F020 has rich peripherals. This design only uses external interrupts and some pins of SPI. On this basis, a lot of content can be added. Purely using the front and back systems will limit the timeliness of the system. In the next article, I will introduce in detail the transplantation of ucos_II based on c8051f020.
Code part:
//----------------------------------------------------------------------------------
// SPI_Init()
//----------------------------------------------------------------------------------
void SPI0_Init (void)
{
SPI0CFG = 0x07; // data sampled on 1st SCK rising edge
// 8-bit data words
SPI0CFG|=0x40; //CKPOL =1;01000111
SPI0CN = 0x03; // Master mode; SPI enabled; flags
// cleared
SPI0CK R = SYSCLK/2/2000000-1; // SPI clock <= 8MHz (limited by
// EEPROM spec.)
}
void MSPI_SendData(unsigned char ddata)
{
LCDCS = 0; // Chip select HC595
SPIF = 0;
SPI0DAT = ddata;
while (SPIF == 0); // Wait for the completion of writing
LCDCS = 1;
}
Previous article:Easy step-down conversion using simulated ripple mode
Next article:Main factors affecting insulation resistance measurement during testing
- Popular Resources
- Popular amplifiers
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Issues with changing MAC when batch flashing blueNRG-1 with BlueNRG-X Flasher Utility
- EEWORLD University Hall ---- Lao Wu's MCU Practice_NO.1 Project Practice
- [NXP Rapid IoT Review] + Rapid IoT Studio online IDE
- I'm studying BQ76940 recently and want to develop a BMS. I've been looking for information and encountered some questions during the process.
- [Sipeed LicheeRV 86 Panel Review] 4. Building a cross-compilation environment
- [Speech and vision module based on ESP32S3] Software development progress - ESP32S3 JPEG encoding performance test
- 【GD32E231 DIY Contest】4. Achieve 60-second timing
- 【DIY Creative LED V2】V2 version
- How to analyze the role of this diode in the MOS tube perfusion circuit?
- [RVB2601 Creative Application Development] Unboxing and Getting Started