APP下载

Synchronous line-tracking robots based on STM 32❋

2013-02-08ZHUXiaoli朱晓莉LIShiguang李世光ZHANGKaiCHENYueyin陈曰印MENGQiangqiang孟强强

ZHU Xiao-li(朱晓莉),LIShi-guang(李世光),ZHANG Kai(张 锴),CHEN Yue-yin(陈曰印),MENG Qiang-qiang(孟强强)

(CollegeofInformationandElectricalEngineering,ShandongUniversityofScienceandTechnology,Qingdao 266590,China)

Aline-tracking robot isa relatively common event of intelligent car com petition.Usually,it requires the robot to reach the finish line along the regulated path and the resultof the com petition is determined by the used tim e[1].For attending the robot contest in the 12th college students science and technology cu lture art festival of Shandong p rovince,a pair of synchronous line-tracking robots are designed.

Fig.1 Playing field and size

The rule of the competition is as follows:black skidproof adhesive tape is used to make up the path consisting of two parallel ellipses on a white foam board asshown in Fig.1.Two robots carrying asynchronous rod start to move from the starting line and walk along the track,respectively.The contest w ill be end up with the second arriving at the starting line.Any part of the rod is not allowed to touch the ground during the race.

In this design,the rod and the sm all cars are fixed at both ends.The speeds of the rear-wheelm otors are ad justed by changing pulse-w idth modulation(PWM)values in real time.Besides,the angular disp lacement transducer is used to detect the relative position of the cars so that their speeds can be adjusted prom ptly.

1 Overall structure and working princip le of control system

Three-wheeled car body is adop ted.Two d riving wheels are installed on both sides in the rear.only one driven wheel is in the front,lying in the m idperpendicular of the two driving wheels.The advantage is that the touchdown of all the wheels can be guaranteed,so that none of the wheels hang in the air.Thus,the stable control can be realized[2].

The contro l system structure of synchronous robo ts is shown in Fig.2.It ism ain ly com posed of a master controlmodule,a power module,a path detectionm odule,a relative position detection module,a controlmodule of the front-wheel servo and a driving module of the rear-wheelmotors,etc.

Fig.2 System structure diagram

Theworking principle of the system isas follows:The route condition is firstly detected by the reflective in frared photoelectric in the front of the cars.The real-time leaning judgment of the cars ismade after the analysis of the control part.Then,the angle of the servo m otor is adjusted so that the cars can veer.In this way,the cars can run along the preset path accurately.A t the same time,the speeds of the cars are controlled by the real-tim e ad justment of PWM values.Besides,the synchronous rod that the cars carry drives the angular disp lacement transducer to shift a corresponding angle.Thespeed of the inner car is then ad justed slightly after the data processing of the contro l part.Thus,the synchronous running of the two cars can be guaranteed.

2 Hardware design

2.1 Master control chip

Main contro l chip is the core of thewho le design.It coordinates and contro ls all theWork of themodules and p lays a decisive role in the overall per formance of the system.Given the requirements of low power consumption,high performance and low cost,and considering thestability of thesystem,the number of peripherals resources on chip and som e other factors,the 32-bit m icroprocessor of STM 32 series STM 32F103ZEmade by STM icroelectronics is adopted as the main control chip.The advanced Cortex-M 3 ARM kernel is used inside every m icroprocessor of STM 32 series.All devices offer an extensive range of I/Os,three 12-bit ADCs,four general-purpose 16-bit tim ers p lus two PWM timers.with the operating voltage of 2.0-3.6 V,it has a series of power savingm odes to ensure the low power consum ption operation of the chip.Considering all the above,this chip can m eet the demands of high perform ance and low power consumption well.

2.2 Path detection

Seven reflective infrared photoelectric sensor ST188 and 2 quad operational amp lifiers LM 224 are used tom ake up the path detection module.The detection circuit is shown in Fig.3.Every sensor consists of an infrared lightem itting diode and a receiving transistor.When inf rared light is em itted to the playing field,w hite color absorbs few rays,and most rays are reflexed.The receiving transistor then switches into breakover w hen receives the reflexed in frared rays,and pin 7 of LM 224 in Fig.3 outputs high level.W hile black color absorbs many rays,only a few rays are reflexed and received by the receiving transistor.Asa result,the receiving transistor doesn't get to breakover,and pin 7 of LM 224 outputs low level.

Fig.3 Reflective infrared photoelectric sensors path detection circuit

As the difference in illumination intensity of the com petition field,aswell as that in fabrication process of the photoelectric sensors and some other factors,leakage current exists in receiving transistor.Thus,the accurate detection of the path is in fluenced.As a resu lt,the operational amp lifier LM 224 is used to equip the system with self-learning function.In this way,the environmental lights interference to photoelectric sensor can be elim inated and the resisting disturbance capacity of the system can be enhanced.In Fig.3,DAC0 is the given voltage com parison value which can be ad justed according to the site light condition.Thus,the light-adaptive line-tracking can be realized.

Radial reach-out distance refers to the radial distance that the photoelectric sensors reach out from the front of the car.Theoretically,the longer the reach-out distance is,the better the situation w ill be.This is because for the unknown track,the earlier the situation in f ront is known,the faster the ad justment can be made.In this way,the cars can run along the route with the best strategy[3].Through experim ents,w hen the radial reach-out distance is fixed to about10 cm,the p rom pt and accurate turning can be ensured.

2.3 Relative position detection

Combined with the realtime control of the speeds of the cars in the program,angular disp lacement transducer is used to detect the relative position distance between the cars in real tim e to ensure the synchronism.

Angular displacement sensor converts the mechanical angular displacem ent of the measured parts to electricity param eter with internal potentiom eter.M echanical angu lar disp lacement m akes m echanical structure inside the sensor to slide on the potentiometer.The corresponding electric signal is then output so that the angle can bem easured[4].

One end of the synchronous rod is fastened to the shaft of the angular displacement sensor with a screw.The other end is fixed on the other robot car.The initial position of the angular disp lacement sensor should be regulated.As the cars running,the relative position distance between them is ref lected through the angular disp lacement sensor shaft.The distance is then converted to digital quantity through ADC.Real-tim e deviation rectification according to the num erical value is then conducted with the program.Thus,the synchronous running of the cars can be further assured.Synchronization control flow chart is shown in Fig.4.

Fig.4 Synchronization control flow chart

2.4 Control of front-wheel servo

Servo motor is a kind of position servo driver.It is suitable for the control systems of which the angle changes continuously and needs to be held frontwheel servo.A servo is actually a position servo system com posed of a tiller,a reduction gear group,a position feedback potentiom eter,a DC motor and a control circuit.Through the internal position feedback,the output turning ang le of the tiller can be proportional to the given contro l signal.Thus,when the load torque is sm aller than the m axim um output torque,the output turning angle w ill be proportional to the given pulsew idth[6].

The control signal of the servo motor is a pulse signal with a period of 20ms.Itshigh level lasts for 0.5-2.5 ms,with the corresponding control angle of 0-180°,and the relationship between them is linear.The corresponding control relationship is shown in Table 1.

Table 1 Relationship between pulse high level durations and controlangles

Contro l circuit of the servo is shown in Fig.5.

Fig.5 Servom otor control circuit

The veer of the cars are realized through the controlof the front-wheels servo motor and the different speees ad justment to the rear wheels in the program.

2.5 Drivering of rear-wheelsmotors

Two H-bridge driving circuitsare used in the drivering modu le of rear-wheel motors.An H-bridge structure,also named a who le bridge structure,has two half bridge drivers.It is com posed of fourm etal oxide semiconductor field-effect transistors(MOSFETs)[7].AO3400 and AO3401 MOSFETs are used in this design.As shown in Fig.6,when BG1 and BG2 sw itch into breakover,the current flow s from the power supp ly VCC through BG1 to the motor,and then down to the ground though BG2 f rom left to right.Thus,the m otor can be driven to run clockw ise.Sim ilarly,when BG1 and BG2 sw itch into breakover,the current flow s through the motor from right to left.Thus,them otor can be d riven to run anticlockw ise.

The tim ers of STM 32 can generate PWM waves generally used in motor control and power electronics field.The outputvoltage is controlled with PWM technology by changing the pulse w idth.And the ch ange of output f requency can be achieved through ch anging the modu lation cycle of the pu lse.In this way,the needed wave,including the shape and amplitude,can be acquired equivalently[8].TIM 4 is used to produce PWM w aves to regulate the speeds of the motors.

Fig.6 H-bridge d riving circuit diagram

2.6 Power supply

Two levelsof power supply are adopted.One uses seven rechargeable batteries of 1.2 V and the voltage regulator AMS1117 adjustable voltage output version to get 6 V,which powers them otors(6 V,646 r/m)and theservo(6 V,0.09 s/60°).The other uses the AMS1117 3.3 V fixed voltage output version to get 3.3 V from 6 V,which powers the STM 32 chip.

3 Software design

Based on the hardware circuit,the tested path information and running situation of the cars,it is available to realize the control of the servo and the motors with an information processing and control program.Thus,the cars can run along the track with high speed and good stability[9].

The software control p rogram ism ainly com posed of ARM initialization,black and white calibration,track detection,steering contro l,speed control,synchronism control,finish line braking,etc.The control system software is realized in KeilμVision3 development environment programm ing with C language.

Among the above,the turning control flow is shown in Fig.7.If the photoelectric sensor in the middle detects the black line,it show s that the car does not deviate from the track.The servo m otor w ill not turn,and the car w ill run in the largest given speed.If the photoelectric sensors on the left(or right)side detect the black line,it shows that the car deviates right(or left)f rom the track.And the more left(or right)the sensors detect the b lack line,the more the car deviates right(or left)from the track.Theservo motor is controlled to drive the car to turn left(or right).And themore the car deviates,the greater the deflection angle is given.

Fig.7 Turning control flow chart

4 Robot cars and playing field display

This design has been made into material object and has actually been tested on the required p laying field.The results show that this kind of synchronous line-tracking robots can track the linewell.

The synchronism can bewell realized and the synchronous rod w ill not d rop.The speed is sofast that the cars can run around the field for a round within seven seconds and stop as they get to the starting line again.Carsand playing field is shown in Fig.8.

Fig.8 Cars and p laying field

5 Conclusion

For the robot contest,STM 32F103 m icroprocessor of STM 32 series is used to design a kind of synchronous line-tracking robots carrying a rod.Ref lective inf rared photoelectric sensor ST188 is used to track the line.Two H-bridge circuits are used to drive them otors.The direction of the cars is controlled by the turning of the servo motor and the speed adjustm ent of the rear w heels.The PWM technology and angular disp lacement transducer are used to guarantee the synchronicity of the two cars.Through experiments,the line-tracking robots can successfully run around the p laying field for a circle with a rod in a short tim e.The robots can track the linewellwith a high response speed.They also have a certain ornam ental value and practical application value.

[1]LIU Yuan-m ing,LI Dao-lin,HAN X u-peng.Design and implemen tation of inductive line-tracking car.Electronic Design Engineering,2011,19(10):70-73.

[2]WANG Zhi-Liang.M anufacture technology of competition robot.Beijing:Mechanical Industry Press,2007:58-70.

[3]GAO Yue-hua.Design of smart car automatic tracing system based on the reflective in frared photoelectric sensor.Sem iconductor Op toe lec tronics,2009,30(1):134-145.

[4]FAN Mao-jun.Sensor techno logy,the neuron of in formationalw eapons and equipm ents.Beijing:National Defence Industry Press,2008:45-47.

[5]HUANG Zhi-w ei,SHUIMeng-ling,ZHANG Qiang,et al.ARM em bedded system app lication design and p ractice of the national undergraduate electronic design contest.Beijing Aeronautics and Astronautics University Press,Beijing,2011:116-117.

[6]DUAN Y ing-kang.Hardw are design of smart line-tracking car based on MC9S12XS128MCU.Elec tronic Com ponent&Device App lications,2010,12(1):33-35.

[7]LIU Long-ji,LI Shi-guang,GAO Zheng-zhong,et al.Design ofm obile robot line-tracking control system.Coal M ine Machinery,2009,30(7):124-126.

[8]PENG Gang,QIN Zhi-qiang.App lication practice of embedded m icrocontroller based on ARM Cortex-M 3 STM 32 series.Beijing:Electronic Industry Press,2011:172-180.

[9]ZHUO Qing,HUANG Kai-sheng,SHAO Bei-bei.Learn to make sm art cars,Challenge“Freescale” Cup.Beijing:Beijing Aeronautics and Astronautics university Press,2007:1-22.