Abstract In order to increase the safety of passenger cars, a bus safety system based on STC89C52 single-chip microcomputer with anti-overload and anti-collision functions was proposed. By studying the principle of ultrasonic ranging and the principle of pulse width modulation, real-time monitoring of the weight of the vehicle body and the obstacle is realized to achieve its function. The safety performance and measurement accuracy of the system were tested. The results show that the system meets the design requirements.

This article refers to the address: http://

Statistics show that in traffic accidents involving passenger cars, overspeed and overload are the main causes of accidents. This design explores how to prevent the occurrence of vehicle impact and anti-overload due to overspeed. When all the passengers get on the bus, the door is closed, the smart car is weighed by the load cell, and the weight is displayed on the LCD screen. If the weight exceeds the rated value, the buzzer alarms and the car cannot be activated to achieve the anti-overload function. . After the car is started, the ultrasonic module starts to measure the distance. When the distance between the car and the obstacle in front is less than the specified distance of 30 cm, the motor decelerates; when the distance decreases to within 15 cm of the safety distance, the car stops until the vehicle in front is far away from the car. Only continue to drive, played a role in collision prevention. The design has the characteristics of low cost, simple operation and small size.

1 Overall design and working principle

1.1 Overall design

The block diagram of the system is shown in Figure 1. The smart car uses STC89C52 as the main control chip, and uses the resistance strain sensor to weigh, and the collected data is sent to the MCU through analog-to-digital conversion and the result is displayed on the LCD screen. In this paper, the HC-SR04 module is used to realize the transmission and reception of ultrasonic waves, and the measured data is transmitted to the single-chip microcomputer. According to the distance between the trolley and the obstacle, different pulse width modulation signals are generated to achieve the purpose of adjusting the motor speed in real time, and the 1602 liquid crystal is simultaneously Show distance.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

1.2 Motor speed principle

The speed of the motor is related to the magnitude of the input voltage and the on/off. Therefore, pulse width modulation (PWM) is the best solution for adjusting the speed of the car. Pulse width modulation is to turn the power on and off according to a certain frequency, and change the time of power on and off according to different conditions. The speed of the motor is achieved by changing the average voltage across the motor. The average voltage value can be changed by the duty cycle of the voltage. As shown in Figure 2, when the power is turned on, the motor runs; when it is turned off, the motor stops; the longer the power-on time, the faster the motor speed. Therefore, according to the PWM principle, the motor can be energized and de-energized according to the frequency, so that the precise control of the motor speed can be realized. The motor can run at the fastest speed when the voltage is +6 V. If the motor is continuously connected to the power supply, the motor speed can reach the maximum, and the voltage across the motor is Umax. When the power is turned on and off according to the frequency, it is occupied. ratio

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

, T(s) is the signal period, and the average voltage is

Uav=Umax×P (1)

Therefore, the average speed is

v=kUav (2)

Where k is the coefficient. In the case where T is constant, changing the time t at which the power is turned on can change the average speed. In this design, the duty cycle and voltage are considered to be approximately linear.

After testing and calculation, the relationship between average speed and average voltage is

v=2.78Uav (3)

In the formula, the unit of v is cm/s.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

1.3 Ultrasonic ranging principle

The design adopts ultrasonic round-trip time detection method. The principle is: when the propagation medium is gas, the time from the ultrasonic transmitter to the receiver through the gas medium, that is, the round-trip time, the round-trip time and the speed of sound in the gas medium Multiplication is the sound wave transmission distance, and the measured distance is 1/2 of the sound wave transmission distance, that is,

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

In equation (4), L is the distance to be measured; v is the speed of sound (about 340 m/s); t is the time of the round trip of the pulse wave.

2 hardware design

2.1 main control chip design

In the design, the main control chip selects the STC89C52, because of its easy operation, powerful function, strong encryption, and also has strong anti-interference performance, large operating temperature range, and supports online system programming (ISP).

2.2 Ranging module design

Ultrasonic uses a rectangular pulse wave with a frequency of 40 kHz, because the acoustic wave propagation efficiency of this frequency is best in the air. The HC-SR04 is a transceiver-integrated ultrasonic sensor that provides a non-contact distance telemetry function from 0 to 200 cm with a center frequency of 40.0 ± 1.0 kHz. The IO port of the MCU sends a high level signal exceeding 10 mV, and the module will send 8 consecutive 40 kHz pulse waves. The receiving end starts to detect the presence or absence of the return signal, and the timer T1 of the MCU starts timing. When a signal is returned, the external interrupt INT0 is triggered to enter the formula calculation program, and the result is finally obtained.

2.3 Weighing module design

2.3.1 Analog to Digital Conversion Module

The HX711 is a 24-bit dual-channel analog-to-digital converter chip designed for high-precision load cells. It is small in size, easy to operate, and highly resistant to interference. It contains A and B dual channels for the user to choose, and the channel is internally connected to its low noise programmable amplifier. Channel A has a programmable gain of 128 or 64 and a channel B gain of 32. The interface and programming of HX711 and 51 MCU are simple, only need to program the serial communication PD_SCK and DOUT.

PD_SCK should input 25~27 clock pulses, and select different channels and gains according to the number of pulses. The system software selects A channel 128 times gain to convert data.

2.3.2 Resistance strain gauge load cell

The working principle of the resistance strain gauge load cell is to establish a linear relationship between the voltage change across the internal strain gauge and the weight of the object. The strain gauge is attached to the force-sensitive elastic element. When the elastic element is stressed, the strain gauge is deformed correspondingly, and the resistance of the strain gauge itself is also changed, thereby converting the mechanical signal into an electrical signal, and the force is caused by the force. The change of the strain gauge resistance is proportional to the voltage change of the circuit. It is only necessary to measure the value of the output voltage, and then the formula can be converted to obtain the weight of the measured object.

2.4 Circuit driver module design

L298N is a double H-bridge DC motor driver chip, which can directly provide signals through the IO port of the MCU, and has a large voltage range of input and output, supports DC voltage input of 5~35 V, and can pass IN1, IN2, IN3, IN4 and ENA. The ENB outputs a voltage of 3 to 15 V to ensure stable operation of the DC motor. In terms of control, the IO port of the MCU can realize the function of positive and negative rotation and stop of the motor with different high and low levels of INX input. The input level of IO port and the running state of the motor are shown in Table 1; Air ratio PWM signal input ENA, ENB two ports can achieve motor acceleration and deceleration.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

2.5 power supply unit

The power supply part is shown in Figure 3. It is powered by a 7.4 V lithium battery. The L298N motor and the PWM signal input port provide a stable 6 V voltage to the motor. However, most of the system's chips operate at 5 V, so the power supply is required. The module supplies 5 V to the system. Therefore, the LM7805 power module is used, which converts 7.4 V to 5 V. As shown in Figure 3, in order to improve the stability of the output voltage, the Zener diode VD2 is connected in series between the 2 pin of the LM7805 and ground. VD1 acts as an output protection diode. When the output voltage is lower than the regulation value of VD2, VD1 Turn it on and bypass the output current to ensure that the output of the LM7805 is not damaged.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

3 software design

The overall flow of the program is shown in Figure 4. The software is mainly composed of three parts: driver, weighing program and ranging program. First, the initialization modes of the initialization timers T0 and T1 are respectively assigned initial values, the initial value of T0 is set to 1 mV, and the initial value of T1 is set to zero.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

The driver generates a PWM signal to control the motor speed, and determines the period of the PWM signal by setting the initial value of the timer T0 and the counter maximum value 100. Each time the timer T0 generates an interrupt counter, it is incremented by one. When the value of the counter is less than a given value, it outputs a high level, otherwise it outputs a low level.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

The weighing program programs the DOUT and PD_SCK pins according to the characteristics of the HX711 chip. First, the PD_SCK serial port has 25 clock pulses. When the falling edge of the 25th clock pulse comes, the data is written bit by bit from the DOUT to the MCU port. The 25th pulse is written to the most significant bit (MSB) of the read data. The MCU reads the data from the high to the low, and then converts the weight to the formula.

The ranging program uses the timer T1 to calculate the time of the ultrasonic back and forth. When the receiving end receives the reflected 40 kHz pulse wave, it triggers the INT0 external interrupt, and T1 stops counting. The data in TH1 and TL1 is the measured time. In addition, when the timer T1 overflows, the timer interrupt is triggered, and the timer is cleared to prevent the result of the ultrasonic wave from entering the measurement dead zone. The weighing program and the ranging program are in two separate infinite loops, and when the button is pressed, the conversion of the two functions is completed.

4 test results

4.1 Weighing module testing

The test selects different weight items such as 1 kg and 2 kg weight. First, the object to be tested is placed on the adjusted zero point electronic scale for measurement, and the data is used as a reference value. Then turn on the power, wait for the reading on the LCD screen to display 0 stably, and then place the measured object on the weighing platform. After the reading is stable, record it. At the same time, use the method of averaging for 3 times to record and calculate the measurement error.

The error formula is

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer
Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

4.2 Ultrasonic Ranging Module Test

Fix a hand-held ruler on the level ground as a reference value and place the cart at 0 cm. Place a baffle on the test points of 10 cm, 30 cm, 50 cm, etc., and read the readings displayed on the LCD screen. Record the average value by measuring 3 times and calculate the error.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

4.3 Vehicle crash performance test

When the distance between the vehicle and the obstacle is 30 cm, the vehicle speed is decelerated to 8.3 cm/s; when the distance between the two is 15 cm, the vehicle stops, and when the distance is >30 cm, the vehicle runs normally. The test sets different initial speeds such as: measuring the braking distance after the vehicle encounters an obstacle, the distance from the obstacle when stopping, and the distance and error displayed on the LCD.

The results show that when the car is driving at the maximum speed and facing the obstacle in front, the car can still be safely braked and does not collide with the obstacle, thus verifying the safety of the design. The results are shown in Table 4.

Design and Implementation of Passenger Car Safety System Based on STC89C52 Single Chip Computer

5 Conclusion

The innovation of the design is to combine the weighing and ranging functions. At the same time, the driving control of the trolley is completed by the single-chip microcomputer and the total weight of the small vehicle is accurately weighed by the weighing module. At the same time, the distance between the trolley and the obstacle in front is measured by the ultrasonic module, and various operating states and measurement results are displayed using the liquid crystal screen. From the operational point of view, the design is stable and reliable, and meets the design requirements.

Replacement Bulb Lamp With Housing

Replacement Projector Lamp with housing has one more case than the bare bulb lamp, which can be directly put into the projector and more convenient than the installation of the bare bulblamp. The projection effect is the same as the compatible projector lamp, with stable light source and brightness, which can support daily life use

Replacement Bulb Lamp With Housing,Bulb Lamp,Dynamic Projector Lamp,Led Projector Lamp

Shenzhen Happybate Trading Co.,LTD , https://www.happybateprojectors.com

Posted on