Smart applications
The Design of Car Wheel Error Warning System Based on AT89C51 Single-chip Microcomputer and CAN Bus Device
1 Principle of inner wheel difference
The inner wheel difference is the difference between the turning radius of the front inner wheel and the turning radius of the rear inner wheel when the vehicle is turning. Due to the existence of the inner wheel difference, when the vehicle turns, the trajectories of the front and rear wheels do not coincide. The magnitude of the inner wheel difference is related to the amplitude of the steering wheel and the length of the vehicle wheelbase. The greater the steering wheel rotation, the greater the steering angle, the greater the inner wheel difference, and vice versa; the longer the wheelbase of the vehicle, the greater the inner wheel difference. Larger, conversely, smaller. Heavy-duty vehicles are relatively long, especially after the front of the vehicle is turned, there is still a long body that does not turn around, which can easily form a "blind spot" for drivers of large vehicles. Passers-by will easily endanger their lives when they step into the inner wheel range. The shaded area in Figure 1 is the formation area of the inner wheel difference.
Figure 1 Schematic diagram of inner wheel difference
2 Principles of Ultrasonic Early Warning
2.1 Principle of Ultrasonic Ranging
Sound waves with a resonance frequency higher than 20KHZ are called ultrasonic waves. Ultrasonic waves travel in a straight line. The higher the frequency, the weaker the diffraction ability and the stronger the reflection ability. There are various methods of ultrasonic ranging, such as phase detection method, acoustic wave amplitude detection method, and round-trip time detection method. Although the phase detection method has high accuracy, the detection range is limited; the acoustic wave amplitude detection method is easily affected by the reflected wave. This article adopts the round-trip time detection method, and its working principle is: make the ultrasonic transmitting probe emit ultrasonic pulses to the medium, and the reflected wave must act on the receiving probe after the sound wave encounters the measured object. If the speed of sound in the medium is known to be V, and the time difference between the moment of emission of the pulse and the moment of arrival of the first reflected wave is T, the distance between the probe and the measured object is S=VT/2, and the measurement of the change in the distance value can achieve the required Control purpose. The velocity V of the ultrasonic wave is related to the temperature, and the relationship between the velocity of sound in the air and the temperature can be expressed as:
2.2 Arrangement of ultrasonic sensors in wheel difference detection
When a car is driving, it will turn to the left and also to the right, so the ultrasonic sensors should be installed symmetrically on both sides of the body. A total of three pairs of sensors need to be installed in this system, one pair is installed near the front wheel, in order to remind the driver whether the back of the vehicle will hit an object inside the turn when turning; the second pair is installed near the middle of the wheelbase to prevent objects from being in the car It suddenly appears on the inside of the turn when turning; the third pair is installed in the rear wheel attachment to promptly remind the driver of the dangerous situation.
3 System hardware design
This system combines single-chip microcomputer technology, ultrasonic distance measurement technology and CAN bus communication technology, etc., and can detect the condition of the inside of the car during the turning process. The three pairs of ranging sensors of the early warning system work independently, and transmit data to the main controller through the CAN bus via the interface chip PCA82C250. Ranging uses SensComp 600 sensor and SensComp 6500 ultrasonic distance module; MCU uses low-cost AT89C51 main functions: 1. Used to control the ranging sensor and send the measurement data to the CAN bus through the CAN controller SJA1000 in real time; 2. Pass The temperature parameters transmitted by the temperature sensor DS18B20 can correct the propagation speed of ultrasonic waves in the air; a high-speed linear optocoupler 6N137 is added between the PCA82C250 and SJA1000 for isolation, which effectively prevents transient interference in the harsh working environment of the car, and ensures Accuracy of data transmission. Because the hardware systems of the three pairs of ranging sensors are exactly the same, only one is used for illustration this time. The hardware structure of the system is shown in Figure 2.
Figure 2 Hardware structure diagram of wheel difference early warning system
3.1 CAN bus communication module
The CAN bus protocol follows the ISO standard model and is divided into a data link layer and a physical layer. These two layers are usually implemented by CAN controllers and transceivers. CAN bus devices can be roughly divided into two types, one is with on-chip CAN controller, such as 87C196CA/CB, MC6837, etc.; the other CAN controller needs to be used independently with a microprocessor, such as Philips SJA1000, Intel Company 82526 and MCP251. The former is mostly used in many specific situations, using integrated devices to facilitate the user to make printed boards, making the circuit design simplified, compact, and improving efficiency; the latter is more flexible in use, and it can be used with various types of single-chip microcomputers and various buses of microcomputers. Make interface combinations. In this system, combined with the comprehensive consideration of the previously selected microcontroller, SJAl000 of Philips Semiconductors is selected as the independent CAN controller. The main features of SJA1000: extended receive buffer (128-byte FIFO); support CAN 2.0B protocol; support 11-bit and 29-bit identifiers at the same time; bit communication rate is 1Mbits/s; enhanced CAN mode (PeliCAN); use 24MHz clock Frequency; supports multiple microprocessor interfaces; programmable CAN output drive configuration; working temperature range is -40℃~+125℃, which is enough to adapt to various harsh environments. The CAN bus driver uses Philips PCA820250, which has high speed (up to 1Mbps) and can meet the control needs of high real-time requirements such as self-braking; it has the ability to protect the bus against instantaneous interference and has the ability to reduce radio frequency interference. Slope control. In addition, it can be connected to 110 nodes to prevent a short circuit between the power supply and the ground, and does not affect the bus when a node is powered off.
CAN bus communication module mainly consists of AT89C5l microcontroller, independent CAN communication controller SJAlO00 and CAN bus driver PCA82C250. In order to improve the anti-interference ability of the system, a photoelectric isolator 6N137 is added between SJAl000 and the CAN bus driver PCA82C250. When the microprocessor AT89C51 sends the ranging result data to the CAN bus controller SJAl000 through the P0 port, the SJAl000 converts the parallel data into serial data and sends it out from the port TX0. After passing through the photoelectric isolator 6N137, it reaches the CAN bus driver PCA82C250, and finally The data is sent to the CAN bus. On the contrary, the data from the CAN bus can also reach the microprocessor through the corresponding circuit. In this way, the communication function between the ultrasonic ranging sensor and the host computer can be realized.
3.2 Introduction to Ultrasonic Sensor
This system uses single-chip AT89C51 to realize the control of SensComp 600 series ultrasonic sensors and SensComp 6500 ultrasonic ranging module. The frequency of SensComp 600 series electrostatic transducer is 50kHz; the measuring range is 6 inches to 35 feet (0.15 meters to 10.7 meters). When combined with SensComp's 6500 drive circuit, the sensor can measure from 2.5 cm to 15.2 meters. AT89C51 controls the transmission of ultrasound through the P1.0 pin, and then the single-chip microcomputer constantly detects the INT0 pin. When the level of the INT0 pin changes from low to high, it is considered that the ultrasound has returned. The data counted by the counter is the time elapsed by the ultrasound, and the distance between the sensor and the obstacle can be obtained by conversion. Figure 3 shows the hardware schematic diagram of the ultrasonic ranging.
Figure 3 The hardware schematic diagram of the ultrasonic ranging circuit
3.3 Temperature compensation design
As the temperature changes by 10°C, the sound velocity changes by 0.6m/s, so the influence of temperature on distance measurement is quite large. In order to realize the detection function more accurately, this design uses the single-wire temperature sensor DS18B20 from DALLAS Semiconductor Corporation of the United States. The sensor can directly read the measured temperature and can realize a 9-12-digit digital value reading method through simple programming according to actual requirements. The temperature measurement range is -55℃~+125℃, and the accuracy is ±0.5℃. The field temperature can be directly measured by The digital transmission of the "one-wire bus" greatly improves the anti-interference of the system. The whole product is small in size, low in price, and flexible in use. It can meet the requirements of the system in terms of temperature measurement accuracy, conversion time, transmission distance, and resolution. . Figure 4 shows the schematic diagram of the connection between the temperature sensor and the microcontroller.
Figure 4 Schematic diagram of temperature correction part
4 System software design
The software adopts modular design, and the program is composed of main program, ranging subprogram, CAN bus communication subprogram and other modules. During the debugging process, debug each function module and subroutine one by one. After each subroutine has completed its designated function, it is integrated to complete the final comprehensive debugging. The main program flowchart and the ranging subprogram flowchart of the wheel difference early warning system are shown in Figures 5 and 6, respectively. The early warning system is activated when the car is turning. AT89C51 first sets P1.0 to 0, starts the ultrasonic sensor to emit ultrasonic waves, and starts the internal timer T0 to start timing. The ultrasonic sensor we use is a transceiver. After sending 16 pulses, the ultrasonic sensor still has aftershocks. In order to identify and eliminate the transmission signal of the ultrasonic sensor from the return signal, the return signal must be detected 2.38ms after the start of the transmission signal. . When the ultrasonic signal hits an obstacle, the signal returns immediately, and the microprocessor keeps scanning the INT0 pin. If the signal received by INT0 changes from low to high, it indicates that the signal has returned and the microprocessor enters an interrupt Turn off the timer. Then the data in the timer is combined with the on-site temperature sent by the temperature sensor to be corrected and converted, and the true distance between the ultrasonic sensor and the obstacle can be obtained; then the distance measurement result is displayed, if the distance measurement result is lower than the set threshold value Generate an alarm signal; finally, the obtained distance data is sent to the main controller of the car through the CAN bus network in real time, so that the communication and network control functions of the early warning system and other nodes of the CAN network and the upper computer can be realized.
5 Conclusion
This paper proposes a wheel difference early warning system for heavy-duty vehicles. It performs distance measurement based on the principle of ultrasonic pulse distance measurement, corrects the data according to the on-site temperature, and connects the wheel difference warning system with the digital platform of the car through the CAN bus to reduce The influence of environmental factors is improved, and the detection accuracy of the system is improved. Real-time display is performed according to the distance from the obstacle to the vehicle body. When the calculated distance is less than the safe distance, an early warning can be given to remind the driver to take necessary measures to avoid a collision. The system has a simple structure and high reliability, can economically and effectively reduce the incidence of large-scale automobile wheel difference accidents, and has a good application prospect.