Vous êtes sur la page 1sur 25

A Line-follower Robot Jaseung Ku 17 Dec 20051. Introduction For my final project, I decided to make a line-follower robot.

This simple robot is designed to be able to follow a black line on the ground without getting off the line too much. The robot has two sensors installed underneath the front part of the body, and two DC motors drive wheels moving forward. A circuit inside takes an input signal from two sensors and controls the speed of wheels rotation. The control is done in such a way that when a sensor senses a black line, the motor slows down or even stops. Then the difference of rotation speed makes it possible to make turns. For instance, in the figure on the right, if the sensor somehow senses a black line, the wheel on that side slows down and the robot will make a right turn. 2. Theory of operation 2i) How to sense a black line The sensors used for the project are Reflective Object Sensors, 0PB710F that are already ready in the Electronic Lab. The single sensor consists of an infrared emitting diode and a NPN Darlington phototransistor. When a light emitted from the diode is reflected off an object and back into the phototransistor, output current is produced, depending on the amount of infrared light, which triggers the base current of the phototransistor. In my case, the amount of light reflected off a black line is much less than that of a white background, so we can detect the black line somehow by measuring the current. (This current is converted to voltage.) ii) How to control a DC motor Instead of applying a constant voltage across a DC motor, we repeat switching on and off the motor with a fixed voltage (Vcc) applied to the motor. This is done by sending a train of PWM (Pulse Width Modulation) pulses to a power MOSFET in order to turn it on and off. Then, the motor sees the average voltage while it depends on duty cycle of PWM pulses. The speed of

rotation is proportion to this average voltage. By PWM method, its easier to control the DC motor than by directly controlling the voltage across it. All we have to do is to modulate pulse width, in order words, a duty cycle. Also, a power MOSFET consumes only negligible power in switching. 3. Circuit diagram My circuit consists of two parts: PWM (Pulse Width Modulation) part and a sensor part. First, we take a look at the sensor part. The photodiode turns on the phototransistor and then the output current is converted to output voltage through the first op-amp circuit. The R6 is a variable resistor, so that we can tune the scale of output voltage. The second op-amp circuit is added to change the polarity of voltage. (Positive CV is necessary later.) One thing we should know is that Vcc to Vcc of voltage rail is needed, not from 0 to Vcc. In the circuit built-up, LM747 Dual Operational Amplifiers were used. Second, in the PWM section, two 555 timers (LM555) are used to produce a pulse-width modulated train of pulses. The timer on the left works in astable mode to generate regular square-wave pulses. The frequency is fixed by the values of R1, R2 and C1 here. Then, this output Q1 is connected to the trigger pin of the second timer that works in monostable mode this time. As you can see in the diagram, at a falling edge of Q1, a pulse is triggered and stays 3high during some time. The time (width of a pulse) is purely determined by the value of R3 and C3 if CV (Control Voltage) pin is not connected at all. (Look at the pulse diagrams of Q1 and Q2 at the bottom of the circuit diagram.) CV plays a role of changing the threshold level of a timer. (Without CV, threshold = 2/3 * Vcc) CV just becomes the triggering voltage level. Therefore, the higher the CV is, the longer it takes time until discharge. In this way, the duty cycle of output pulses Q2 can be controlled. Back to my circuit, the output voltage of the sensor part provides CV. For instance, if any sensor senses a black line, the current from the photodiode decreases, the CV drops, the duty cycle gets low and the motor slows down.

Third, the PWM pulses are supplied to the gate of a power MOSFET (IRF520) to switch the DC motor on and off. Then, the DC motor only sees the average voltage proportional to the duty cycle of the pulses. When CV is high, so is the duty cycle and the motor turns fast. In my robot, the distance between sensors and the ground is fixed. So, when a sensor is off the black line (The sensor sees white paper.), CV keeps its maximum value and both motors keep turning in a constant speed. As soon as the sensor enters the black line part, CV drops down and thus duty cycle decreases, which means the slowdown of a wheel. * Component Values: R1=6K, R2=1K, R3=20K, R4=10, R5=82, R6=5K(variable), R7=1K C1=1F, C2=0.1F, C3=0.1F, 44. Building the robot Before starting to build a real circuit, I built is on the lab breadboard and verified everything worked fine. Then, I bought a blank breadboard from ECE storeroom. I put together each electronic part and wires on the board and soldered them all. (The work would have been much easier to use a PCB (Printed Circuit Board).) After that, I checked if there is any bad connection, and tested if the circuit generates correct pulses at each point. (i.e. Q1 and Q2) This whole work took quite a time, much longer than I expected. For a robot body, I bought a container and two flying wheel toys at the Wal-Mart. With 5every part ready, I drilled holes to fix two DC motors, some supporting aluminum plates and sensors in front 5. Result For a test, I held my robot in the air and I approached a white paper to sensors. Then, both wheels rotated as expected and they slowed down when either the paper moved away or sensors passed across a black line. Next, I put it down on the track, but unfortunately, it didnt move. I found the torque of motors not enough to drive my robot. Even though the chosen DC

motor was slowest and gave highest torque among other DC motors in the lab, it wasnt enough. For solving this problem, I will have to find a suitable DC motor with large torque. Overall, the robot project wasnt successful, but it was quite a fun to go through all the process. I also realized that there were many things to consider practically such as installation of motors, building up a circuit by soldering and putting all parts together. This experience hopefully would be helpful in the future work. Some snapshots of my robot are on the next page.

6 7

World Transactions on Engineering and Technology Education Vol.8, No.4, 2010 455 INTRODUCTION Learning by doing is a very effective idea for students to acquire knowledge, if they are well motivated. It was found that students will be willing to do tedious research work to solve practical problems when these problems are related to an interesting and competitive contest [1][2]. Racing contests of line-following robots are examples [1][3-5]. Linefollowing robots are self-operating robots that move along a line on the floor. Recently, the Fortune Institute of Technology held six line-following robot racing contests to encourage students from the technological and vocational education system in Taiwan to show their creativity and techniques [3]. It is a very successful contest not only because of the high prize, but also in attracting senior high school students to join the contest. The Taiwan micromouse and intelligent robot contest even included the line-following robot racing contest as a major event last year [5]. The rules, which are similar to those in Japan [4], encourage line-following robot contestants to memorise what the racing track is like by providing hints along the line whenever the curvature is changed. The contestants, therefore, can plan the speed command profiles for their motors for straight-line segments and curves. In addition to the intelligence of judging precisely where the line is, of memorising the racing track patterns and of speed command profile planning for motors, the mechanical parts and design of the line-following robot are also important to reduce the effect of weight transfer and to prevent skidding when making turns at high speeds. According

to the experience of the micromouse world champion [6], the turn speed is a decisive factor in robot speed contests. To make a line-following robot with a speed faster than 1m/sec even when it is making turns, the correct prediction of the line position is a key factor. Unfortunately, algorithms which are able to predict accurate line position depend heavily on the assumption that reflective optical sensors have similar output characteristics. It is also found that the spacing between reflective optical sensors and the distance between the reflective optical sensor and the ground are important factors for line detection algorithms to work accurately. Therefore, calibration of the reflective optical sensor outputs is an important procedure for a fast line-following robot. The calibration procedure described in Chans Web page uses white paper and a gain value for each reflective optical sensor to adjust the corresponding output value to a pre-specified value [7]. Lee et al use a more complex approach which needs 20% and 80% of grey patterns to determine the calibration parameters [8][9]. Although the approach in References [8] and [9] is effective, it can only be manually performed. Therefore, an automatic calibration procedure, which uses a pulse-width modulation technique to adjust the light emitted from lightemitting diodes and to simulate the reflecting conditions of 20% and 80% of grey surfaces, is proposed in this article to remedy the problem. The other requirement for line-following robots to run as fast as possible is its ability to memorise what the racing track is like so that the robot can plan the speed command profiles for its motors for straight lines and curves. This is possible An intelligent line-following robot project for introductory robot courses Juing-Huei Su, Chyi-Shyong Lee, Hsin-Hsiung Huang, Sheng-Hsiung Chuang &Chih-Yuan Lin

Lunghwa University of Science and Technology Taoyuan County, Taiwan ABSTRACT: Line-following robots are very popular with technical university and vocational high-school students in Taiwan. Therefore, these projects are quite helpful in motivating students to learn actively the implementation skills for intelligent mobile robots. The line-following robot devised in this article for educational purposes includes not only accurate line detection algorithms with analog outputs of reflective optical sensors, but also homemade encoders, which help record all information about the racing track. The firmware can then plan profiles for the fastest run. The integration of the software control algorithms and hardware circuits make it a suitable teaching aid for introductory autonomous mobile robot courses. The devised robot won first prize in several national contests for line-following robots, which shows its superiority of implementation.456 because the rules used in the 5 th Taiwan micromouse and intelligent robot contest, and the all Japan robotrace contest both provide hints when the curvature of the racing track changes. Because of the weight transfer effect, the speed on curves should be slower than for straight lines to prevent skidding [10]. Therefore, the line-following robot should not only differentiate curves from straight lines, but also know the lengths of all the straight line segments. This is why the line-following robot described in this article is equipped with a quadrature encoder. How the encoder is designed and the algorithm used to calculate the lengths of all the straight line segments are also discussed in this article and it was

experimentally verified as also reported in this article. Although the robot was developed mainly for both national and international line-following robot contests, the integration of the software control algorithms and the hardware circuits make it a very suitable teaching aid for introductory autonomous robot courses. OVERVIEW OF THE INTELLIGENT LINE-FOLLOWING ROBOT The prototype intelligent line-following robot described in this article, the block diagram of which is shown in Figure 1, is a single board computer and costs about NTD2,000. The robot, used for contests and laboratory exercises, consists of a microcontroller dsPIC30F6011, dual H-bridge dc-motor drivers, an RS232 port to communicate with a PC, an LCD display for debugging, an in-system programming (ISP) port for downloading programs from a PC to the 48K byte flash memory, 9 A/D ports for accessing the sound and reflective optical sensor circuit signals and an encoder wheel (Figure 1). The necessary integrated development environment and C-language compiler for the robot can be freely downloaded from the Microchip Inc. Web site. Line detection Sensor Circuits: 9 optical sensors + Gyro 10 A/D ports Micro-controller dsPIC 30F6015 Download program via ICD2 RS232 H-bridge Drivers Right/Left Motors

2 PWMs forward/reverse control Personal computer Program & Debug dsPIC 33FJ128MC804 2 Quadrature encoder interfaces control LCD/Buttons User Interface Distance and curvature calculation UART Figure 1: The proposed line-following robot and its corresponding block diagram. AUTOMATIC CALIBRATION OF REFLECTIVE OPTICAL SENSOR OUTPUTS To detect the line in the racing track, most people use two or more reflective optical sensors [11][12], and the outputs of these sensors are fed to comparators with predefined threshold trigger values to get the corresponding digital information. Although this approach works fine in detecting the line, the analog information about the reflection rate of the floor, which is related to whether or not the sensor is right on the line, is lost. As can be seen in Reference [13], the reflective collector current of the circuit in Figure 2 can give users the information about how far the reflective optical sensor is from the line. Therefore, the analog output voltage at the collector would become larger and larger as the reflective optical sensor moves away from the line when the floor is black and the line is white. This is the main idea used in Reference [7]. A K

C E sensor R2 R3 vDD PWM Control Analog output floor AKCE Control Switch Reflective optical sensor Emitted light (a) (b) Figure 2: a) The working principle of reflective optical sensors; b) The application circuit. Unfortunately, the analog outputs for different sensors working under the same conditions vary a lot even if their part numbers are the same. This is why calibration is necessary for those reflective optical sensors installed on the linefollowing robot. Chan uses gain parameters for each reflective optical sensor such that the analog output values can be adjusted to be the same when white floor is used for calibration [7]. Although it is a relatively simple approach and can be done automatically, it adjusts only the largest analog output values. Lee et al proposed a different approach [8][9]. 457 They tried to fix the analog outputs corresponding to 20% and 80% of grey floor to the same level for all reflective

optical sensors. Although this approach is effective in adjusting the sensor analog output values to similar levels under the same working conditions, it would take users quite some time to finish the entire calibration process. An automatic calibration procedure based on the result in References [8] and [9] and pulse-width-modulation (PWM) technique, therefore, was devised to remedy this problem. Assume that the floor is white. The duty ratio of the PWM control signal shown in Figure 2b is set to be 20% and 80% such that the light energy emitted from the diode of CNY70 would be 20% and 80% of that when the PWM control signal is kept high and the control switch is turned on. This is because the light energy emitted from the diode is proportional to the input energy to the diode, and the forward voltage drop is almost constant throughout the operation range (20mA-100mA) [13]. Therefore, the condition in which one uses full-scale emitted light energy on a 20% grey floor and the other condition in which one uses 20% of emitted light energy on a white floor would have similar analog output voltages in Figure 2b. This is the main idea of the proposed automatic calibration procedure in this article. Let the reflective optical sensors be arranged along a line with equal space between each other. The length of the space can be determined by how far away the sensor is from the line such that the analog value would drop to 50% of its maximum value. The experimental result is shown in Figure 3, in which the line width is 19mm and the value for the space between two consecutive optical sensors is chosen to be 12.5mm. The values in Figure 3 show that the seven reflective optical sensors actually do not give identical outputs even if the

test conditions are the same. The calibration procedure tries to map the output values of each reflective optical sensor with respect to 20% and 80% of grey to the same maximum and minimum values using the following formula: ( min, ) max, min, max min min ji i ii jo xx xx yy yy

where xmax,i , xmin,i , are the maximum and minimum values of the i th reflective optical sensor outputs; ymax , ymin, are the predefined maximum and minimum values for all reflective optical sensor outputs; xji

is the j th output value for the i th reflective optical sensor, and yjo is the normalised output value for xji . It can be seen in Figure 3 that the output values of different reflective optical sensors are quite similar to one another after the calibration using Equation (1). Once the calibration procedure is done, the output values of these seven reflective optical sensors are ready to be used in estimating the line position. 02468 0 50 100 150 200 250 300 350 Sensor number Analog ADC values Outputs of reflective optical sensors before calibration 02468 0 50

100 150 200 250 300 350 Sensor number Analog ADC values Outputs of reflective optical sensors after calibration 40% of gray 60% of gray 80% of gray 100% of gray 40% of gray 60% of gray 80% of gray 100% of gray Figure 3: The reflective optical sensor outputs for different grey scales before (left) and after calibration (right). LINE DETECTION ALGORITHMS After the calibration procedure, the line position can be calculated based on the adjusted analog output values from the corresponding reflective optical sensor circuits. Various ways are described and experimentally compared in the following. Assume that the line to be followed is black and the floor is white, and there are seven reflective optical

sensors installed on the line-following robot. The ideas described below are applicable even if the line to be followed is white and the floor is black. Line Detection via Quadratic Interpolation Let the coordinate of the left most sensor be - 3, and the distance between two consecutive sensors be 1. The output of the reflective optical sensor circuit in Figure 4a is higher when the sensor is closer to the black line. Therefore, one can458 always find 3 consecutive sensors with higher output readings than the other 4 sensors as shown in Figure 4a. Assume that the coordinate of these 3 sensors are x1, x1+1, and x1+2, and the true shape of the sensor output values in the range of [x1, x1+2] can be approximated by a quadratic curve. One can then find the following relationships between the coordinate of the sensors and the output values: y 1 1 2

1 2 1 2

1 3 1

1 The coordinate value at which the output value of the quadratic curve is the maximum is considered as the true position of the line. By using the basic calculus, one would know that the coordinate value is: a b x 2

2 a y 1 3 2 , b 2 1 1 It is assumed that the coordinate for the center position of the line-following robot is 0. Therefore, the error e between the line position and the center position of the robot is e Line Detection via Weighted Average This technique is the commonly used in defuzzification procedures of fuzzy systems [14]. It can also be viewed as

finding the center of mass [15]. Suppose that the coordinate of the 7 reflective optical sensors are x0, x1, x2, x3, x4, x5, x6, respectively, and the corresponding analog output values are y0, y1, y2, y3, y4, y5, y6, as shown in Figure 4b. The estimated line position can then be calculated by the following weighted average formula:

0 605142 7 0 7 0 3( ) 2( ) ( ) i i i i i ii y yyyyyy y

xy x . (4) Estimated position Estimated error x1 x1+1 x1+2 estimated position analog outputs

y1 y0 y2 y3 y4 y5 y6 x0 x1 x2 x3 x4 x5 x6 Line to follow (a) (b) Figure 4: The line detection algorithm via a) quadratic interpolation, and b) weighted average. Experimental Verifications and Comparisons of Line Detection Algorithms To verify the correctness and effectiveness of these line detection algorithms, a linear platform was constructed using a desktop inject printer, as shown in Figure 5. Figure 5: The linear platform devised to verify the correctness and effectiveness of the line detection algorithms.459 The resolution of the linear platform is 0.1mm/pulse. A black line on a white floor is attached to the movable part of the inject printer, and the optical sensor module was fixed. The height of the optical sensor module from the white floor can

be adjusted to check whether or not the resistance values in Figure 2b are appropriate. The patterns of the 7 reflective optical sensor outputs, when the track on the linear platform is moved from 130mm to 220mm after calibration, is shown in the upper-left of Figure 6, which shows the patterns are quite similar after calibration. The other 3 plots in Figure 6 show the experimental verifications of the line detection algorithms via weighted average (lower-left), and quadratic interpolation (lower-right) respectively by using calibrated sensor outputs. The mean-squareerrors (MSE) of these methods are also shown in the titles of these plots. It was seen that the line detection algorithm via weighted average has the least mean-square-error, although the mean-square-error for the method of linear interpolation is only a little bit bigger. AUTOMATIC CONTROL ALGORITHMS FOR THE LINE-FOLLOWING ROBOT The popular proportional-integral-derivative (PID) controller was introduced in this project to make the robot follow the racing track [16]. The error between the centre of the reflective optical sensors and the track to be followed was then processed by the PD controller in Figure 7 to generate velocity commands for the right and left wheels. The proportional term is only a gain amplifier, and the derivative term is applied in order to improve the response to disturbance, and also to compensate for phase lag at the controlled object. The D term will be required in most cases to stabilise the tracking motion. Although the integral control is not used, the steady state error is small enough and does not cause too much trouble. 130 140 150 160 170 180 190 200 210 220 0

50 100 150 200 250 track position in mm 7 reflective optical sensor outputs after calibraion 140 150 160 170 180 190 200 140 150 160 170 180 190 200 Real track position (mm) Estimation via linear interpolation method, mse = 2.7922 140 150 160 170 180 190 200 140 150 160 170 180 190 200

Real track position (mm) Estimation via weighted average method, mse = 2.5922 140 150 160 170 180 190 200 140 150 160 170 180 190 200 Real track position (mm) Estimation via quadratic interpolation method, mse = 5.3909 Ideal position estimation Estimated track position Ideal position estimation Estimated track position Ideal position estimation Estimated track position Figure 6: The experimental comparisons of various line detection algorithms by using calibrated sensor outputs. Base speed command Optical Sensors Find error: Using line detection algorithms +

+ + PD controller: Speed correction Feedback optical sensor outputs Figure 7: The automatic feedback control structure for the intelligent line-following robot.460 WORKSHOPS AND CONTESTS The idea described in this article has been used for two years in workshops for vocational high-school teachers and students in Taiwan. The workshops are supported by the Ministry of Education and, therefore, the workshops are free. All the vocational high schools are also given free line-following robot kits to help speed the learning process. To see how well the participants integrate all the skills learned in the workshops to implement line-following robots, a race was held after the hands-on laboratory was finished (Figure 8). The results have shown that the line-following robot, when integrated with a conventional curriculum, was very helpful in motivating students and keeping their interest high. Winning one or two awards at a competition not only gives students a sense of accomplishment but also pride and visibility to their schools. This is an important factor for technology-oriented high school students in Taiwan, because of their low learning in traditional theoryoriented lecture courses. The student far left in Figure 8, who won second prize in the national contest (shown in Figure 8), is such an example [5].

Figure 8: The free workshop and contest for vocational high school teachers and students at Lunghwa University of

Science and Technology. CONCLUSIONS A description of an intelligent line-following robot for introductory robot courses is presented in this article. The intelligent line-following robot was a revision of a previous design that won some national contests. An automatic calibration procedure for reflective optical sensors using pulse-width-modulation techniques was proposed and verified. Three different kinds of line-detection algorithms are also described and experimentally compared by using a linear platform following the calibration procedure. It was found that the weighted average line-detection algorithm was the best in these line-detection methods using mean square errors. A homemade encoder was also devised to help the firmware remember all the information of the racing court. When all these functions were put together in the intelligent line-following robot, the average speed could be 1.3m/sec. Although this outcome is still not good enough to compete in an international Robotrace contest, the ideas all proved to work well in a test racing court. The line-following robot also can be used in an introductory robot course since it requires knowledge of sensors, motor control, calibration and line-detection algorithms. Most of all, it is not expensive. Several laboratory exercises have been designed and offered to vocational high-school teachers and students in Taiwan, and the feedback from workshop participants was quite good. One of the students even won second prize for linefollowing robots in a national contest. REFERENCES 1. Hussmann, S. and Jensen, D., Crazy car race contest: multicourse design curricula in embedded system design. IEEE Transactions on Educ., 50, 1, 61-67 (2007).

2. Paulik, M.J. and Krishnan, M., A competition-motivated capstone design course: the result of a fifteen-year evolution. IEEE Transactions on Educ., 44, 1, 67-75 (2001). 3. Fortune Institute of Technology, The line following robot speed contest (2007), 5 August 2009, www.ee.fjtc.edu.tw/contest/contest.htm 4. New Technology Foundation, All Japan Robotrace contest (2010), 5 December 2010, www.ntf.or.jp/mouse 5. Lunghwa University of Science and Technology, The 5 th Taiwan micromouse and intelligent robot contest (2009), 5 August 2009, robot2009.lhu.edu.tw 6. Ng, B-K., Micromouse technology (2009), 5 August 2009, www.np.edu.sg/alpha/nbk 7. The Electronic Lives Manufacturing, Desktop line following robot (2003), 5 August 2009, elmchan.org/works/ltc/report.html 8. Lee, C.-S., Su, J.-H., Lin, K.-E., Chang, J.-H., Chiu, M.-H. and Lin, G.-H., A hands-on laboratory for autonomous mobile robot design courses. Proc. 17 th Inter. Federation of Automatic Control World Congress, Korea, 9,473-9,478 (2008).461 9. Lee, C.-S, Su, J.-H., Lin, K.-E., Chang, J.-H. and Lin, G.-H., A project-based laboratory for learning embedded system design with industry support. IEEE Transactions on Educ., 53, 2, 173-181 (2010). 10. TurnFast, Weight Transfer (2000), 5 December 2010, www.turnfast.com/tech_handling/handling_weightxfr 11. Vroman, J., JavaBot1 - A line following robot (2007), 5 December 2010, www.james.vroman.com/javbot1a.htm 12. Cook, D., Jet - the ultra-fast line following robot (2006), 5 December 2010, www.robotroom.com/Jet.html

13. Vishay Semiconductor, CNY70 - Reflective optical sensor with transistor output (2008), 5 December 2010, www.vishay.com/docs/83751/cny70.pdf 14. Zimmermann, H.-J., Fuzzy set theory - and its applications. (4 th Edn), Springer (2001). 15. Wikipedia, Center of mass - alternative derivation (2009), 14 June 2009, http://en.wikipedia.org/wiki/Center_of_mass 16. Franklin, G.F., Powell, J.D. and Mami-Naeini, A., Feedback control of Dynamic Systems. (4 th Edn), Prentice-Hall, Inc. (2002).

Vous aimerez peut-être aussi