GAO Zheng-zhong,WANG Xiao-hui,LI Zhi-wen
(College of Electrical Engineering and Automation,Shandong University of Science and Technology,Qingdao 266590,China)
In the recent robot contests and electronic design contests,most of the competition tasks request robots to walk along the white or the black guide lines in the field. The paper puts forward the design strategy of intelligent line-tracking robots based on STM32,which focuses on the control principle of systematic line-tracking as well as the design of sensor circuits,and introduces proportion integration differentiation (PID) speed regulation of the system briefly.
Any embedded intelligent system needs to obtain outside information through the sensor. According to the feedback information,a micro-controller is used to calculate and make decision,and it can generate control commands and control the system’s corresponding actuator to complete the relevant tasks through the output port. Using the background of white KT board and the navigation route to make up of black non-slip tape whose color is greatly different from the ground's color,it's used to guide direction of the robot. We design an intelligent robot which relies on reflective infrared photoelectric sensor of ST188 to move the probe forward along navigation routes,and uses the micro-controller of STM32 which is based on input sensor to control servo motor and guide direction of the robot.
Walking ground of the robot is the white KT board,and the navigation line is the black tape. We choosing the reflective infrared photoelectric sensor of ST188 aim to take the advantage of the substances of different colors which can absorb light in varying degrees. The sensor's emitting diode constantly emits infrared light outward. When emitter enters into the white area,the receiver tube of the sensor detects the reflected back infrared rays. When it enters into the black tape area,the infrared rays are absorbed,and the receiver tube almost can't detect,any reflected back infrared ray. Due to strength of the received infrared rays,the input sensor will show different levels (high or low). According to changes of input levels,the micro-controller can take control of the robot and make decisions.
In order to exactly locate position of the robot with the line-tracking sensor in the front and on the sides of the car,two DC speed-reduce motors are adopted by changing direction of the voltage to control the positive inversion of the motor and respectively realize master drive of left and right wheels,and adopt the photo electricity encoder to test the speed of the robot. The structure of the system is shown in Fig.1.
Fig.1 System structure
A high-performance ARM Cortex-M3 32-bit RISC inner core is adopted in the STM32F103RBT6,where the ARM Cortex-M3 32-bit RISC inner core is provided with operating frequency up to 72 MHz. A build-in 128 KV byte high-speed memory,three USARTs,two SPIs,two I2Cs,four 16-bit timer/counter and two measurable 12-bit synchronous ADCs,each of which has 16 external channels respectively. And every port can be configured into various modules through software programming. A plurality of I/Os are provided with multi-functional two-way compatible capacity,and the overturning speed can be up to 18 MHz[1].
3.2.1 Layout of sensor
The system is installed in the front of horizontal pitch of seven sensors with the left portion,and right portion of vertical mounting pitch five sensors are set the same parts of the width of the two adjacent sensor black antislip tapes of bandwidth. The horizontal parts are installed with an odd number of sensors in order to accurately determine the front midline,when the car is in the black tape. And the deflection can be judged based on location of the respective sensor. The front portion of the left and right sides sensors can determine mutual cross vertical navigation line to adjust posture of the vehicle body based on location of the respective sensor,which plays a key role for the intelligent robot in running to cross line of turning movement. The layout ensures the car to run along a given direction after numerous tests. Due to the reflective infrared sensor,strength of the infrared receiver sensor tube has a certain relationship with its height from the ground,which leads to that the output current value of the sensor has a certain relationship with its height from the ground. Therefore,the distance from the ground to installation of the sensor is crucial. The data obtained by experiments is shown in Table 1,so we can know that the optimum height of the sensor above the ground is 0.8 cm.
Table 1 Output current of different installation height
3.2.2 Black-and-white calibration
The system adopts reflective infrared photoelectric sensor of ST188,which is much more sensitive to interference of outside light. Therefore,the design of software is calibration of black-and-white areas. A dial switch is used to calibrate the black-and-white areas before walking of robot,which can reduce outside interference,and enhance ability of the robot to adapt to the external environment. Schematic diagram of hardware calibration is shown in Fig.2.
Fig.2 Schematic diagram of hardware calibration
First,all the sensors in the car point to the black navigation lines. The dial switch is turned to predefined black calibration grade until the light-emitting diode flashes and the calibration of black navigation lines is completed. Then all the sensors point to the white area,and the dial switch is turned to predefined black calibration grade until the light-emitting diode flashes and verification of white areas is completed. The software flow chart is shown in Fig.3.
The system uses two H-bridge driver circuits constituted by four discrete components of metal oxide semiconductor (MOS) to drive the motors of left and right respectively. Each motor's driven circuit has three control terminals,and the control terminals are respectively motor enable control,motor forward control,motor reverse control. By changing values of the polarity of the voltage wave and pulse width modulation (PWM) to control the travelling direction and speed of the intelligent robot,it can avoid the chip fever caused by the integrated motor driver chip and realize quick start motor and make motor speed smooth.
The three typical forms of digital PID controllers are proportional,proportional integral and proportional integral differential regulators. Control intensity of the proportional regulator depends on the proportion coefficient. Increasing of the proportion coefficient reduces the steady-state error. But if the proportional coefficient is too large,it will damage the dynamic performance of the system,and even lead system to instability[2,3]. Integral-action of proportional integral regulator eliminates the residual steady-state error of proportional control,and improves stability of the system,but it reduces rapid response ability of the system at the same time[4]. The joint of the derivative actions of the proportional integral differential regulator reduces the system overshoot,overcomes oscillation and makes the system stability.
The digital PID control algorithm is divided into two types of the positional PID controller and the incremental PID controller[5]. The system adopts the incremental PID controller,and the standard form is
Δu(k)=u(k)-u(k-1)=
wherekis the sample number,k=0,1,2,3,…;u(k) is thek-th PWM output; Δu(k) is thek-th output increment of the PWM;e(k) is deviation value of thek-th sampling;Tis the sampling time;KPis proportional gain of the controller;TIis the controller's integration time constant;TDis the controller's derivative time constant.
Schematic diagram of the incremental PID controller is shown in Fig.4.
Fig.4 Schematic diagram of incremental PID controller
Compared with obscure PID,self-adaptive PID and expert PID algorithm,the conventional PID can not only satisfy the practical requirement,but also be good,simple and convenient for real-time performance,and easy to implement,so it's suitable for robot car competitions[6].
STM32F103RBT6 is adopted as the core controller of the system,and the controlling system of the intelligent line-tracking robot is analyzed and designed. Meanwhile,in order to reduce the interferences on the line-tracking of the intelligent robot from the surroundings,a black-and-white sensor calibration program is designed[7]. Two DC motors are respectively driven by the two H-bridge driven circuits,which are adopted by the system and formed by four discrete components (MOS tube). By altering voltage directions and PWM,speed modification of the DC motor rotation in positive and negative directions is achieved,and the PID control is adopted to adjust walking process of the robot[8]. Test results show that the simple and low-cost sensor is reasonable,and the driven circuits are stable and highly efficient[9]. The robot is strong in adaptability to the external environment,good in flexibility and valuable in study and applications[10].
[1] LIU Long-ji,LI Shi-guang,GAO Zheng-zhong. Design of mobile robot line-tracking control system. Coal Mine Machinery,2009,30(7): 124-126.
[2] GAO Yue-hua. Design of autonomous tracing system in intelligent vehicle based on infrared photoemectric sensor. Semiconductor Optoelectronics,2009,30(1): 134-137.
[3] LIU Yuan-ming,LI Dao-lin,HAN Xu-peng. Design and implementation of inductive line-tracking car. Electronic Design Engineering,2011,19(10): 70-73.
[4] DUAN Ying-kang. Hardware design of smart line-tracking car based on MC9S12XS128 MCU. Electronic Component & Device Applications,2010,12(1): 33-35.
[5] PENG Gang,QIN Zhi-qiang. Application practice of embedded microcontroller based on ARM Cortex-M3 STM32 series. Beijing: Beijing Electronic Industry,2011.
[6] JIANG Xue-jun,LIU Xin-guo,LI Xiao-jing. Computer control technology. Beijing: Tsinghua University,2009.
[7] GONG Mao-fa,HUANG He-song. MCS-51/52 microcontroller theory and practice. Beijing: Beijing University of Aeronautics and Astronautics,2009.
[8] HUA Cheng-ying,TONG Shi-bai. Basis of analog electronic technology. Beijing: Higher Education Press,2006.
[9] ZHUO Qing,HUANG Kai-sheng,SHAO Bei-bei. Learn to make smart cars,Challenge “Freescale” Cup. Beijing: Beijing Aeronautics and Astronautics university,2007.
[10] ZHU Xiao-li,LI Shi-guang,ZHANG Kai. Synchronous line-tracking robots based on STM32. Journal of Measurement Science and Instrumentation,2013,4(1): 58-62.
Journal of Measurement Science and Instrumentation2014年2期