1 Composition and working principle of the robot
The robot consists of two parts: hardware and software. The STC12CSA60S2 single-chip microcomputer is used as the core component of the system control to complete functions such as road information detection, DC motor control, motor speed detection, digital tube display, buzzer alarm, and keyboard input. The hardware system block diagram is shown in Figure 1.
Figure 1 Hardware system block diagram
The software part mainly completes road condition detection, PID motor control, input and output human-machine interface, and can realize various robot cruising actions, intelligent tracking and other functions.
2 STC12 series microcontroller
The STC12C5A60S2 microcontroller used in this article is a STC12 series microcontroller produced by Hongjing Technology. This microcontroller is a single clock/machine cycle (1T), with many advantages such as high speed, low power consumption, super strong anti-interference and inability to decrypt. The instruction code is fully compatible with the traditional 8051 and is 8-12 times faster. The operating voltage is 3.3 V ~ 5.5 V (5V microcontroller), there are 6 16-bit timers, compatible with ordinary 8051 timers or 4 external interrupts, with watchdog and EEPROM functions, and an internal integrated MAX810 dedicated reset circuit.
3 Hardware Design
3.1 System Power
Since the motor has a large current at the moment of starting, the power supply must have sufficient driving capability, so the system uses dual power supply. The LM7805 is used to convert the 12 V lithium battery pack voltage into a 5 V regulated power supply to power the microcontroller minimum system circuit, road surface detection circuit, digital tube display circuit and motor speed measurement circuit. The motor drive circuit is directly powered by the 12 V voltage output by another group of lithium batteries.
3.2 Motor drive circuit
The DC motor used in this system has a rated voltage of 12 V and a rated speed of 300 rpm. The motor drive circuit uses a dedicated chip L298N as the motor drive chip. Using this chip as a motor drive not only has good stability and greatly simplifies the drive circuit, but also has a large driving capacity, which is conducive to the stability of the motor speed. The motor drive circuit is shown in Figure 2.
[page]
3.3 Infrared photoelectric sensor tracking array module
The working principle of the infrared photoelectric detection circuit is: infrared rays are emitted to the road surface and reflected. The infrared rays have different reflection coefficients on black and white lines. White reflects light, while black absorbs light. The circuit is designed with an infrared light emitter and an infrared photosensitive diode. When a black line is detected, the detection circuit sends a high-level signal to the microcontroller. When a white line is detected, the detection circuit sends a low-level signal to the microcontroller.
An infrared photoelectric sensor array module is composed of 7 groups of infrared photoelectric detection circuits arranged in a row and placed at the front of the robot. In the process of tracking the black line, the infrared photoelectric sensor array module can obtain the displacement offset of the robot to the black line track. The signal of the infrared photoelectric sensor array module detected by the single chip and the displacement offset of the robot are shown in Table 1.
When the robot is in different driving states, the output values of the 7 sets of sensors are also different. From the table, we can get the offset between the robot's position and the black track during the cruising process.
3.4 Vehicle speed detection module
The educational robot system reads the current vehicle speed through the vehicle speed detection module. The method used is to paste a coding disk with evenly distributed black and white stripes on the rear left and right wheels respectively (see Figure 3 (a)), and use the detection circuit of Figure 3 (b) to detect the black and white stripes on the coding disk. When the wheel rotates, the intensity of the reflected light received by the infrared receiving tube will change, which will generate a pulse signal corresponding to the wheel speed. The pulse signal is amplified and shaped, and then input into the pins P3.4 and P3.5 of the microcontroller. The number of pulses obtained per unit time can be recorded to indicate the speed of the left and right wheels of the current vehicle. At the same time, the distance traveled by the vehicle can be calculated by accumulation.
3.5 Other circuits
The digital tube display circuit mainly displays the current walking speed of the robot. LED digital tubes are used for dynamic display, and the segment code is driven by PNP transistors. The system displays a distance range within 10 meters. A 4-bit LED common anode digital tube is selected, and dynamic scanning display is realized through single-chip microcomputer programming. The display characters are sent out by the single-chip microcomputer P0 port, and P1.6, P1.7, P3.0 and P3.1 control the dynamic display of each digital tube respectively.
The alarm circuit is completed by controlling the buzzer through the single-chip microcomputer P3.7. When P3.7 outputs a low level, the buzzer alarms; when P3.7 outputs a high level, the buzzer does not alarm. The touch buttons are connected between the external interrupt input ports P3.2 and P3.3 of the single-chip microcomputer and the ground as the start and stop switches of the system, as a key input circuit.
[page]
System software design
The realization of system control is completed by software. The software design is based on keilC51, adopts modular structure design, and each functional sub-block is independent. Structurally, it consists of 1 main program file main.c and 8 sub-program files (key.c, pid.c, detect.c, seg.c, speed.c and motor.c). The main.c main program file completes the initialization of a series of tasks and the coordination of processing each task. The key.c file completes the key interrupt detection and buzzer alarm tasks; the seg.c file completes the digital tube display; the sp∞dc file completes the motor speed detection; the motor.c completes the PWM configuration and motor control; the detect.c file completes the infrared photoelectric sensor array detection; the pid.c file implements the fuzzy parameter self-tuning PID operation processing. Among them, the timer TO generates a sampling period T second timing interrupt, interrupts once every T seconds, completes a PID control calculation, and calls the fuzzy parameter self-tuning PID operation subroutine to calculate the difference between the test speed and the set speed to obtain the output value, which is used to configure the PWM output and control the motor speed. The main program and timer TO interrupt processing flow chart is shown in Figure 4.
Figure 4 Main program and timer TO interrupt processing flow chart
4.1 Principle of Fuzzy PID Parameter Self-Tuning Controller
PID parameter fuzzy self-tuning is to find out the fuzzy relationship between the three parameters in PID and e and ec. During operation, by continuously detecting e and ec, the three parameters are modified online according to the fuzzy control principle to meet the different requirements of e and ec for control parameters, so that the controlled object has good dynamic and steady-state performance. Considering the stability, response speed, overshoot and steady-state accuracy of the system, the functions of Kp, Ki and Kd are as follows: Kp is used to speed up the response speed of the system and improve the regulation accuracy of the system; Ki is used to eliminate the steady-state error of the system; Kd improves the dynamic performance of the system. Figure 5 is a schematic diagram of the design structure of the PID controller.
Figure 5 PID controller design structure schematic diagram
The influence of various PID parameters on the system is as follows:
(1) When the error |e| is large, it means that the absolute value of the error is large. Regardless of the error change trend, the controller Kp should be considered to take a larger value to improve the rapidity of response; and to prevent |ec| from being too large instantaneously, kd should take a smaller value; to control overshoot, ki should also take a very small value.
(2) When the error |e| is of medium size, in order to ensure the response speed of the system and control overshoot, Kp should be reduced, Ki value should be increased, and Kd should be moderate.
(3) When the error |e| is small, in order to ensure that the system has good steady-state characteristics, the values of Kp and Ki should be increased. At the same time, in order to avoid oscillation, the value of Kd should be linked to |ec|.
Educational robots are typical nonlinear, time-varying, and model-uncertain complex systems. In practice, the roads on which robots travel include straight roads, large curves, and "S"-shaped small curves. Taking advantage of the fact that the characteristics of educational robots remain basically unchanged under the same road conditions, the optimal PID parameters under these three road parameters can be determined respectively. The core idea is to regard the robot state within the control cycle as unchanged. As long as the control cycle is short, a good control effect can be achieved. In the actual operation of the robot, control is performed once every 10ms, which meets the requirements.
4.2 PID parameter setting
Fuzzy PID control considers the relationship between Kp, Ki and Kd according to different operating states of the system. Based on engineering experience and the role of each parameter, a large number of tests are conducted to obtain the PID parameters of this system under corresponding road conditions. The experimental data are as follows:
(1) On the straight road, the system takes kp=3, Ki=5, kd=0, and the test environment is a long straight road with a length of 5 m;
(2) On the large curve, the system takes kp=10, Ki=1, kd=1, and the test environment is a straight road entering a 3/4 circle with a radius of 100 cm;
(3) On the "S"-shaped small curve, the system takes kp=7, Ki=4, kd=3, and the test environment is an "S"-shaped small curve composed of three 90-degree arcs.
5 Conclusion
The STC12C5A60S2 single-chip computer is used in conjunction with the infrared photoelectric array detection module to execute the parameter self-tuning fuzzy PID controller of the DC motor, which solves the control problem of the DC motor's jittering forward during cruising, making the educational robot more stable during walking, and the control method is simple and practical.
References:
[1]. MAX810 datasheet http://www.dzsc.com/datasheet/MAX810_1019165.html.
[2]. LM7805 datasheet http://www.dzsc.com/datasheet/LM7805_843721.html.
[3]. L298N datasheet http://www.dzsc.com/datasheet/L298N_442931.html.
Previous article:Basic knowledge of single chip microcomputer application programming
Next article:Features of MSP430 MCU and its application in receiver
Recommended ReadingLatest update time:2024-11-16 15:42
- 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