1 Car model installation
The control of the smart car adopts front-wheel steering. The B-type car model adopts the chassis of a 1:16 electric off-road remote control car produced by a domestic manufacturer. Its outstanding features are four-wheel drive and four-wheel independent suspension. The reflective photoelectric sensor is simply arranged in a straight line in front of the car, with 14 transmitters and 7 receivers, one transmitter with two receivers. The sensor's forward vision can reach more than 40cm, and the distance between the two laser transmitters is 1.8cm. The sensor unit installation diagram is shown in Figure 1.
The system uses an infrared sensor as a speed sensor. The infrared sensor is installed on the rear wheel, and black and white tape is pasted on the inner wall of the rear wheel at equal distances. This installation makes full use of the space and meets the speed measurement requirements. The infrared sensor speed measurement installation diagram is shown in Figure 2. When the wheel rotates, the infrared sensor will output a pulse level, and the speed of the car will be obtained by detecting the pulse frequency. This speed measurement method cannot achieve the accuracy of the photoelectric decoder, but it does not have much effect on the speed processing of the car. The photoelectric decoder is expensive and installed on the gear. When the power supply and PWM output are the same, the speed of the car will slow down.
2 Hardware Design
The power management module uses a 7.2 V 2 000 mAh Ni-Cd battery as the system energy source, and uses a step-down voltage regulator circuit to separate 6 V and 5 V to power the servo and microcontroller respectively; an H-bridge and its related devices are used to make a 直流电\'); companyAdEvent.show(this,\'companyAdDiv\',[5,18])"> DC motor drive module; the steering servo servo controls the steering of the smart car; an infrared sensor measurement module is used to measure the speed of the smart car in real time; a laser sensor is used as a track detection; the system makes full use of the peripheral modules of the M9S8AC16CG microcontroller, including: timer module, PWM pulse width modulation module, interrupt module, I/O port and real-time clock module.
2.1 Minimum system and motherboard
The system adopts the commonly used minimum system board. The minimum system of the single-chip microcomputer system with MC9S08AC16 as the core mainly includes the following parts: clock circuit (external 8 MHz quartz crystal oscillator), power supply circuit (provides 5 V DC power supply), reset circuit, BDM interface (download and debug programs to the single-chip microcomputer through the BDM head).
The main circuits that make up the system are located on the motherboard, including:
The 7.2 V battery power supply of the power supply voltage regulator circuit will be processed into two 5 V and one adjustable DC output of about 5 to 7.2 V through three integrated voltage regulator circuits. One of the 5 V DC power supplies is for the microcontroller and related peripherals, and the other 5 V DC is for the laser sensor alone. The adjustable DC output is for the servo. This power supply design can provide the required power supply of different sizes, and at the same time, the working power of the microcontroller will not be affected when the servo and laser sensor are working.
The interface circuit includes a servo interface, a motor drive interface, a power supply interface, a human-machine interface circuit interface for debugging, and a single-chip microcomputer minimum system socket.
The motor driver board is made as a separate unit for the DC motor "H" type bipolar drive circuit.
2.2 Sensor module
14 transmitters and 7 receivers are used, and two transmitters and one receiver are arranged in a row. Each time, two non-adjacent transmitters are selected for transmission, and two receivers receive them respectively. The IO port of the AC16 microcontroller is controlled, and the sensor to be transmitted is selected by the 74LD164 driver. A 555 chip sends out a 100 kHz frequency oscillation wave, and the laser tube emits light. The receiving part has a matching 100 kHz receiving tube to receive the returned light, and the receiving signals of the 7-way receiving tube are directly fed into the microcontroller. The principle of the sensor is shown in Figure 3.
[page]
3 Software Design
3.1 Software Design Overview
The main function of the system will execute the program corresponding to the flowchart shown in Figure 4. The debugging program can complete the following functions: checking sensor faults, debugging speed control parameters, setting the servo midpoint, controlling the servo angle parameters, etc. The reading of sensor data refers specifically to the reading of laser sensors. In the timer program, a new round of laser scanning starts every 5 ms, and a group of laser emission tubes are replaced every 125μs. Each group emits two non-adjacent laser signals. After all lasers are emitted 5 times, the track track signal is detected more than 3 times to confirm that it is valid. Only then will the sensor data reading completion flag be set, so the system enters the subsequent program execution every 5 ms. The steering control and speed control of the trolley servo will be discussed in detail later. For the trolley motor speed control, it is a closed-loop control, which combines bang-bang control with P algorithm control. The speed reading of the trolley is completed by the input capture function. When the car moves, the wheels rotate. Every 1/5 of a circle, the infrared sensor will output a complete pulse cycle. The speed of the trolley is determined by reading the output pulse frequency of the infrared sensor.
3.2 Determination of the vehicle's driving state
The track used by the system is 50 cm wide and 25 mm in center. The sensor reads 1 on black and 0 on white. The sensor may read 1 or 0 on the floor outside the track. The laser sensors are arranged in a straight line, with a distance of 20 mm between two adjacent sensors. The track is shown in Figure 5.
The possible states of the sensor on the track can be divided into: on the normal track, at the cross line, and out of the track. The system defines a variable Car_State to represent the current state of the car. The following situations may occur:
1) When the car is on the track, one or two sensors will output a high level. If two sensors hit the black spot at the same time, and the two sensors are not adjacent, it is considered an interference signal and no special processing is done. The other coordinates are calculated from -13 to 13 from left to right according to the sensor arrangement method shown in Figure 6. At this time, Car_State is counted as the coordinate hit by the sensor;
2) If more than 10 black dots are hit, it is counted as a cross line, and Car_State is counted as 20;
3) If the black spot is not hit, the car is considered to be about to run off the track, and Car_State is counted as 30;
4) There is another situation where the sensor has hit the outside of the track. The sensor that hits the outside of the track may output a high level or a low level. At this time, the situation that may be read may be judged as the first situation, as shown in Figure 5. At this time, the car should continue to turn left, but the judgment is the first situation, so it may turn right. The judgment of this situation cannot be determined solely by reading the sensor, but the trend of the car's movement in front should also be considered for judgment. Because this situation generally only occurs when the car turns a big corner, because the turning angle is not enough, when the car's sensor will hit the outside of the track in the opposite direction, when the left or right turn angle exceeds a certain value (such as 60°), the sensor on the other side should be shielded, and only the sensor on the side turned to is read. As shown in Figure 5, the car now turns a big left corner, and the right sensor detects an error black spot. At this time, just shield the 7 sensors on the right and read only the left sensor value. In this case, Car_State is counted as 40.
3.3 Steering gear control
The car is on the track: Car_State is an integer between -13 and 13. Due to the small number of photoelectric tubes, the discreteness of the sensor return value is too large, which is not suitable for feedback control. Therefore, the sampling rate should be increased, oversampling should be performed, and then first-order iteration filtering should be performed :
PVal=((Car_State×1 000)+(Pvalx10))/11;
The deviation of the position of the car after 5 ms is iteratively filtered:
Err=((PVal-PVal1)+(Errx10))/11; // Position deviation between two times
P_Offset=Err/P_err; //Negative value is biased to the left, positive value is biased to the right
if(P_Offset<-5)P_Offset=-5; //The maximum left deviation is -5 units
if(P_Offset>5)P_Offset=5; //The maximum right deviation is 5 units
Err is sampled and divided to obtain the P_Offset variable. The value of P_Offset is an integer from -5 to 5. A negative number indicates a deviation to the left, and a positive number indicates a deviation to the right. The larger the absolute value, the larger the deflection angle. The sampling resolution is an adjustable parameter P_err. When P_err is too large, the car will react more slowly. When P_err is too small, the car will react more sensitively, and even a small deviation will easily cause the car to turn more sharply.
The data table Angle_Table[] is organized according to the current position of the car and P_Offset. The table has a total of 27 rows and 11 columns. The element j in the nth row and mth column indicates that when the car's position Car_State is n-13 and the deviation P_Offset is m-5, the value of j is between -10 and 10. A negative value represents a left turn and a positive value represents a right turn. The angle that the car's servo should turn is jxAngle_C. The adjustable parameter Angle_C can be adjusted according to the track conditions, the servo's reaction sensitivity, etc. Its adjustment is completed in the debugging program. The larger its value, the greater the turning angle under the same conditions.
The control of the servo is achieved by looking up the data table Angle_Table instead of solving it through formulas. This method is more suitable for 8-bit microcontrollers. By looking up the table, the system speed can be achieved that cannot be achieved by calculation.
When the car is crossing the line, Car_State=20 does not change the control of the servo. When the car's sensor cannot hit the black spot and is about to run out of the track or has already hit the track, Car_State=30 or 40. At this time, according to the direction of the car's rotation, the servo is set to the maximum angle to achieve the purpose of finding the black line on the track as soon as possible.
The output PWM of the servo adopts a 5 ms period, which is consistent with the sampling frequency of the car sensor.
4 Experimental results and summary
Through the above method, the car has achieved relatively good test results. On a track with a minimum curvature radius of not less than 50 cm, the car can achieve a speed of more than 2 m per second. Its speed is not much different from that of a system using a 16-bit microcontroller. It should be noted that using variables of different data types during calculations will bring different effects. Experiments have shown that if variables of byte storage type can be used as double-byte variable storage, it will seriously affect the operation of the car. This is caused by the mathematical operations performed in the microcontroller compilation environment. Inappropriate variable definitions and arithmetic operations should be avoided as much as possible.
Compared with the currently popular dual-servo smart car controlled by a 16-bit single-chip microcomputer, this system has a lower hardware cost. The software also avoids more complex calculations based on the characteristics of the 8-bit single-chip microcomputer and adopts a table lookup method. Only a small amount of mathematical calculations are involved in the car position and deviation calculation and the speed P algorithm, so as to achieve a fast response of the system.
Previous article:Design of electric vehicle control system based on DSP microcontroller
Next article:Low-cost 8-bit single-chip controlled photoelectric tracking intelligent car
Recommended ReadingLatest update time:2024-11-16 19:34
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Can you tell me the steps to construct a distance 3 Hamming code?
- CC3200-LAUNCHXL development board experience sharing - CC3200 Getting Started - cugxiao
- Is there any website that specializes in mobile phone hardware and software?
- Working principle and application of power management chip
- Please help me find out how this formula is calculated, thank you
- Digital Modulation Series: Basic Theory of IQ Modulation
- Season 1 has passed, are Season 3 and 4 far away?
- Share: Power analyzer directly connected to CAN network
- A collection of fast charging reference designs. See if there is anything you are interested in?
- [RVB2601 Creative Application Development] Yoc creates a task to display the IP address and signal strength