introduction
The automatic tracking vehicle is a comprehensive intelligent system with autonomous judgment and decision-making capabilities. Its design integrates mechanics, electronics, detection technology and intelligent control, and has a wide range of applications in social life, such as material distribution robots in automated production lines, robot nurses in hospitals, tour guide robots in shopping malls, etc.
The National "Freescale" Smart Model Car Competition was born under this background. The smart model car competition requires the use of the visual device on the car to make the smart car automatically move along the track in a given area. Under the condition of ensuring stability, the fastest one wins. According to the different principles of path discrimination, it is divided into three types: photoelectric group, electromagnetic group and camera group. The smart car described in this article is designed as a photoelectric group. It uses black lines with a large difference in color from the white ground to guide and reflective laser tubes to identify the path. The steering gear drives the front wheels to turn, the DC motor drives the rear wheels forward, and PWM is used to achieve motor speed regulation, so that the smart car can travel quickly and smoothly.
Overall design concept
In order to be able to track and drive autonomously, the smart car should have functions such as path recognition, direction control, speed detection, and drive control. According to the competition regulations, this design uses the competition-specific car model provided by Freescale as the carrier, Freescale's 16-bit microcontroller MC9S12XS128 single-chip microcomputer as the control core, laser sensors for path recognition, and front-axle steering and rear-axle driving. In order to accurately control the speed of the car, a photoelectric encoder is installed on the rear axle of the smart car to collect the pulse signal of the wheel speed, and the main controller performs PID automatic control to complete the closed-loop control of the smart car speed. The design of the entire smart car can be divided into two parts: hardware design and software design.
hardware design
The hardware system should include main controller selection, power management module, tracking sensor module, speed sensor module, servo control module and motor drive module.
Main controller module
This design uses the 16-bit microprocessor MC9S12XS128 as the control core, with a maximum bus speed of 40MHz, an analog-to-digital converter (ADC) conversion time of 3μs, and excellent EMC function. The main I/O ports are allocated as follows: PA0~PA7, a total of 8 bits, are used as input ports for path recognition in front of the car, PT7 is used as input port for speed sensor detection; PWM1 is used for PWM control signal output of the servo steering gear; PWM3 and PWM5 are used for PWM control signal output of the drive motor.
Power Management Module
The power management module provides power for each part. The power supply of all hardware circuits is provided by a 7.2V nickel-cadmium battery. Since the voltage and current capacity required by each module of the system are different, the chip LM2940 is used to convert the 7.2V battery into a 5V power supply to power the microcontroller system, the photoelectric sensor for path identification, the photoelectric encoder, etc. The chip LM2941 provides 6V to power the steering gear. In order to improve the response speed of the servo motor, the motor module is directly powered by a 7.2V battery.
Path detection module
Figure 1 Overall structure
Figure 2 Vehicle structure and sensor layout and coding
Infrared photoelectric sensors are often used because they are cheap and have simple circuit designs. RPR220 is an integrated reflective photoelectric detector that can identify two colors with large differences in reflectivity (such as black and white) to determine the direction of the track.
This design uses a total of 8 RPR220 infrared sensors, which are horizontally distributed on the sensor board at the front of the car. Due to its poor foresight, usually only 3cm~5cm, the sensor board is suspended in front of the front of the car, and a vertical detection method is adopted, as shown in Figure 2. The sensor spacing is 12mm, which is less than the width of the black line on the track, ensuring that there is always a sensor that can detect the black line when the car is driving on the track. The 8 sensors of the car can detect 8 precise positions, plus the situation where two adjacent sensors detect the black line at the same time and no sensor detects the black line, there are a total of 16 detection states. Such lateral detection accuracy can reach 6mm, which basically meets the tracking requirements.
Speed detection module
The main function of the speed measurement module hardware is to send the analog signal whose frequency changes with the speed into the signal processing circuit, and finally convert it into a digital pulse signal. In order to accurately control the movement of the car model, we use the method of controlling the encoder with a single-chip microcomputer to detect the motor speed of the car. For the encoder, we use a 100-line rotary encoder OME-100-1N photoelectric encoder produced by OMRON. It is connected to the drive shaft with a pair of gears at a 1:1 transmission ratio. When the drive shaft rotates one circle, the encoder can obtain 100 pulses. The single-chip microcomputer can get the specific value of the speed by counting the pulses.
Drive motor and servo module
The drive motor of this design uses a DC motor, and its control effect directly affects the speed of the car and the stability of its forward movement. In order to obtain a larger driving capacity, two MC33886 driver chips were initially selected to form an H-bridge drive circuit. The PWM pulses output by the PP3 and PP5 pins of the microcontroller were isolated by a 6N137 optocoupler and connected to the MC33886 H-bridge input. However, since the internal resistance of the motor is only 430 milliohms, and the on-resistance of each MOSFET inside the integrated chip is more than 120 milliohms, the total resistance of the armature circuit is greatly increased, and the drive circuit efficiency is low. Later, two BTS7960 chips were used to form a full-bridge drive circuit. The internal MOSFET on-resistance is 7+9 milliohms, which is directly connected to the microcontroller, improving the drive efficiency.
The S3010 motor used in the servo is essentially a position follow-up system, which consists of a steering wheel, a reduction gear set, a position feedback potentiometer, a DC motor and a control circuit. Through internal position feedback, the steering wheel output angle can be proportional to the control signal given by the PWM1 channel of the single-chip microcomputer. [page]
software design
The smart car competition is ultimately judged on speed, and the smart car path recognition algorithm, steering control, and speed control algorithm are the focus of research. The operation control of the smart car is to control the action of the servo and DC drive motor based on the current path and speed information obtained by path recognition and speed detection, thereby adjusting the driving direction and speed of the smart car. The control algorithm is equivalent to human thinking and is its core part. It is responsible for processing the data collected by the sensor according to the predetermined process. The software flow chart is shown in Figure 3. Among them, the FOR loop contains subroutines such as detecting the position of the black line and updating the servo output, as shown in Figure 4.
Figure 3 Main control program
Figure 4 FOR loop subroutine
Path identification algorithm
During the autonomous tracking process of the car, the photoelectric sensor will be interfered by environmental factors such as external light, vehicle body shaking, cross lines, ups and downs, and black spots on the path, which will cause the sensor to detect path information with deviations and affect the stability of the car's tracking. To this end, we use continuous detection filtering to eliminate interference: that is, the sensor detects the path five times in a row and stores the collected information in the array Line[5][8]. If a black line is detected, the value is 1, otherwise it is 0. If yes , then the nth column of Line[5][8] detects a black line, Line[n] = 1; otherwise it is interference, Line[n] = 0, and the array Line[5][8] is converted to the array Line[8]. Since the sensor spacing is slightly smaller than the width of the black line, Line[8] generally has 16 states: more than two are 1 (path cross lines are detected), one or two are 1 (black lines are detected), and all are 0 (no black lines are detected).
As shown in Figure 2, the offset of the car is e. When the number of black line points 0<Point≤2 is detected, as shown in Formula 1:
Formula 1
Steering control of smart cars
The direction of the smart car mainly depends on the offset between the track and the car, e. As shown in Figure 2, is the front wheel angle; y is the distance between the sensor and the front axle of the car. Then the forward direction angle of the car should be . The servo is installed above the center of the front axle and drives the front wheel to steer through the steering rod. Since the servo uses a position servo motor, its output angle is linearly related to the given PWM pulse width. The width of the high level of the PWM control signal determines the angle of the steering wheel output by the servo.
Since the steering gear is a large delay link, no control algorithm is needed. In order to improve the response speed, the direct table lookup method is used to control the turning angle, that is, a steering table for the steering gear is set in proportion to different offsets e, and the required turning angle value is directly looked up in the table during driving, which minimizes the impact of the steering gear execution delay. When Point>2 (path intersection), keep the original turning angle value.
speed control
The speed control of smart cars is relatively complex. During driving, not only is a reasonable instantaneous speed required for the driving wheels, but also a delicate and smooth speed change is required, "accelerating immediately when exiting a curve and decelerating immediately when entering a curve". That is, when the car is on a straight road, a higher speed is set to ensure that the car has sufficient acceleration space; when the car is on a curve, the speed should be changed according to the different curvature radii of the track to avoid running off the track. The speed control generally adopts PID closed-loop control, and the output u(t) and deviation e(t) are shown in Formula 2:
Formula 2
Among them, kp, ki, and kd are called proportional coefficient, integral coefficient, and differential coefficient respectively. The role of kp is to affect the deviation, so that the system changes in the direction of reducing the deviation. The role of ki is to eliminate the static error of the system, but too much increase in ki is not conducive to reducing overshoot and oscillation, making the system unstable, and the elimination of the static error of the system is slowed down. The role of kd is to speed up the response of the system, but the ability to suppress disturbances is weakened.
The key to using PID control is to adjust the three proportional coefficients, that is, parameter tuning. There are many methods for PID controller parameter tuning, which can be summarized into two categories: one is the theoretical calculation tuning method, which is mainly based on the mathematical model of the system and determines the controller parameters through theoretical calculation. The other is the engineering tuning method, which mainly relies on engineering experience and is directly carried out in the control system test. The method is simple and easy to master, and is widely used in engineering practice.
To simplify the problem, according to the Ziegler-Nichols empirical formula, the PID control algorithm can be simplified to a normalized parameter formula about kp. Therefore, the racing car speed calculation formula is designed as shown in formula 3:
Sst_speed=high_speed-e×kp
Formula 3
In formula 3: Set_speed is the speed of the car, high_speed is the maximum speed set on the straight road, and kp is the proportional coefficient. Considering the different racing environments, a set of experimental data kp is pre-stored in the microcontroller and selected through the DIP switch.
Conclusion
This paper proposes a design method for an intelligent car system based on infrared photoelectric sensor tracking. The system uses MC9S12XSl28 microcontroller as the main controller and DC motor as the actuator. The key design and analysis of the intelligent car are carried out, and a continuous detection filter processing method for eliminating interference is proposed. The modules used are initialized by writing a program, and the desired functions are realized by reading and writing the corresponding data registers or status registers.
After completion, the smart car was tested on a track made of white KT board with a black guide line pasted in the middle. It showed that the smart car can reach a very high speed and stability on a straight road, and can run smoothly if the speed is well controlled on a curve.
Previous article:Selection and three topology designs of portable LED drivers
Next article:Design of temperature control system for infant incubator based on fuzzy PID algorithm
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- From getting started with the development board evaluation to being ready to give up
- What is the principle of constant current source composed of operational amplifier and MOS?
- Talk about the high and low temperature test problems of CC2640 CC1310
- Professional standards for engineers in integrated circuits, artificial intelligence, the Internet of Things, etc. have been released. Come and see if you are qualified?
- EEWORLD University ---- Networking Technology
- Purgatory Legend-BCD to Binary War
- [Hua Diao Experience] 03 Building the Xingkong board development environment - Mind+ programming
- CCS51 Programming Project Tutorial
- How to write a good state machine_Verilog_CH06_FSM
- Go Bluetooth