+ All Categories
Home > Documents > Line Following Robot (Barrister Ranjit Mohanty International Institution of Technology, Bhubaneswar)

Line Following Robot (Barrister Ranjit Mohanty International Institution of Technology, Bhubaneswar)

Date post: 24-Sep-2015
Category:
Upload: princepallav
View: 4 times
Download: 1 times
Share this document with a friend
Description:
The line following robot, operates as the name specifies. It is programmed tofollow a dark line on a white background and detect turns or deviations andmodify the motors appropriately. The optical sensor is an array of commerciallyavailable IR reflective type sensors.The core of the robot is the ATMEGA 16 microcontroller. The speed control ofthe motors is achieved by the two PWM modules in the μC. The directioncontrol is provided by 2 I/O pins. The H-Bridge motor driving/control chiptakes these signals and translates it into current direction entering the motorarmature. The motors require separate supply for operation.The differential steering system is used to turn the robot. In this system, eachback wheel has a dedicated motor while the front wheels are free to rotate. Tomove in a straight line, both the motors are given the same voltage (samepolarity). To manage a turn of different sharpness, the motor on the side of theturn required is given lesser voltage. To take a sharp turn, its polarity isreversed.The robot uses IR sensors to sense the line. An array of 8 IR LEDs (Tx) andsensors (Rx), facing the ground has been used in this setup. The output of thesensors is an analog signal which depends on the amount of light reflected back,this analog signal is given to the comparator to produce 0s and 1s which arethen fed to the micro-controller.The control has 6 modes of operation, turn left/right, move left/right, and driftleft/right. The actual action is caused by controlling the direction/speed of thetwo motors (the two back wheels), thus causing a turn. The actualimplementation is a behavior based (neural) control with the sensors providingthe inputs. The robot can also be programmed to find the line by pseudo-randommovement in case no line is detected by the optical sensor.
Popular Tags:
59
Barrister Ranjit Mohanty International Institution of Technology Project Work Report On LINE FOLLOWING ROBOT Submitted in partial fulfillment of Live Project By PALLAV KUMAR NAYAK [08EE-093] Under the guidance of RAJENDRA KUMAR BHOI Dept. of CS, BRM IIT Department of Electrical and Electronics Engineering BRM IIT, PANDRA, BHUBANESWAR 2008-2012
Transcript
  • Barrister Ranjit Mohanty International Institution of Technology

    Project Work Report On

    LINE FOLLOWING ROBOT

    Submitted in partial fulfillment of Live Project By

    PALLAV KUMAR NAYAK [08EE-093]

    Under the guidance of

    RAJENDRA KUMAR BHOI Dept. of CS, BRM IIT

    Department of Electrical and Electronics Engineering

    BRM IIT, PANDRA, BHUBANESWAR

    2008-2012

  • Barrister Ranjit Mohanty International Institution of Technology River View Campus, Barrister Ranjit Mohanty Marg, Rasulgarh,

    Bhubaneswar, Orissa

    DEPARTMENT OF ELECTRICAL AND ELECTRONICS

    CERTIFICATE

    It is certified that the project work entitled LINE FOLLOWING ROBOT carried out by Mr. Pallav Kumar Nayak [08EE-093] a bonafide student of 3rd Semester in partial fulfillment for the Live Project of BRM IIT, Bhubaneswar, during the year 2009. It is certified that the corrections/suggestions indicated for Internal Assessment have been incorporated in the Report department library. The project report has been approved as it satisfies the academic requirements in respect of project work prescribed for the said purpose.

    Signature of the Guide Signature of the Principal

    (R.K.BHOI) (-------------------)

    External Viva

    Name of the Examiners

    1.

    2.

    Signature with date

  • ACKNOWLEDGEMENT

    An endeavor over long period can be successful only with advice and guidance of many well wishers. My sincere thanks to the management and -----------, DEAN, BRM IIT, for providing me the opportunity to conduct my project works. I am highly indebted to Mr. R.K.BHOI, CS DEPARTMENT, BRM IIT for his assistance and constant source of encouragement.

    I wish to express my profound and deep sense of gratitude to Mr. SASMIT HOTA, IT DEPARTMENT, BRM IIT for sparing his valuable time to extend help in every step of my project work.

    Last but not the least we would like to thank our friends and family for their help in every way for the success of this project report.

    PALLAV KUMAR NAYAK

  • CONTENTS

    1. SYNOPSIS. 2. PREAMBLE... 2.1 INTRODUCTION.... 2.2 PROBLEM DEFINITION..... 2.3 OBJECTIVES OF THE STUDY. 2.4 SCOPE OF STUDY. 2.5 REVIEW OF LITERATURE.. 2.6 APPLICATIONS.........

    2.7 LIMITATIONS....

    2.8 METHODOLOGY... 3. THEORY.... 3.1 THE DIFFRENTIAL STEERING SYSTEM.. 3.2 D.C. MOTORS 3.3 H-BRIDGE MOTOR CONTROL... 3.4 INTELLIGENCE. 3.5 THE AVR-ATMEGA16 MICROCONTROLLER.. 3.6 PWM SPEED CONTROL... 3.7 THE PICMICRO CCP MODULES. 4. DESIGN AND IMPLEMENTATION. 4.1 SCHEMATIC.... 4.2 PROCESS EXPLANATION.....

    4.3 FLOW CHART..... 4.4 CODE.... 4.5 CODE EXPLANATION... 5. RESULT & CONCLUSION.. 6. BIBLIOGRAPHY..

    7. APPENDIX

    PAGEPAGEPAGEPAGE

  • 1. SYNOPSIS

    The line following robot, operates as the name specifies. It is programmed to follow a dark line on a white background and detect turns or deviations and modify the motors appropriately. The optical sensor is an array of commercially available IR reflective type sensors.

    The core of the robot is the ATMEGA 16 microcontroller. The speed control of the motors is achieved by the two PWM modules in the C. The direction control is provided by 2 I/O pins. The H-Bridge motor driving/control chip takes these signals and translates it into current direction entering the motor armature. The motors require separate supply for operation.

    The differential steering system is used to turn the robot. In this system, each back wheel has a dedicated motor while the front wheels are free to rotate. To move in a straight line, both the motors are given the same voltage (same polarity). To manage a turn of different sharpness, the motor on the side of the turn required is given lesser voltage. To take a sharp turn, its polarity is reversed.

    The robot uses IR sensors to sense the line. An array of 8 IR LEDs (Tx) and sensors (Rx), facing the ground has been used in this setup. The output of the sensors is an analog signal which depends on the amount of light reflected back, this analog signal is given to the comparator to produce 0s and 1s which are then fed to the microcontroller.

    The control has 6 modes of operation, turn left/right, move left/right, and drift left/right. The actual action is caused by controlling the direction/speed of the two motors (the two back wheels), thus causing a turn. The actual implementation is a behavior based (neural) control with the sensors providing the inputs. The robot can also be programmed to find the line by pseudo-random

  • movement in case no line is

    Figure 1.1: Block Diagram of the Line Following Robot

    movement in case no line is detected by the optical sensor.

    Figure 1.1: Block Diagram of the Line Following Robot

  • 2. PREAMBLE

    2.1. INTRODUCTION

    The robots of the movies, such as C-3PO and the Terminator are portrayed as fantastic, intelligent, even dangerous forms of artificial life. However, robots of today are not exactly the walking, talking intelligent machines of movies, stories and our dreams.

    In the 1970s scientists proposed that in the year 2000 we would have created artificial life forms, almost perfect in terms of intelligence and capabilities. The dream of free and efficient labor made the researchers of the time go on day and night to bring the dream to existence. But the task was futile due to the lack of compact processors to carry out the calculations which were oh so necessary.

    Now in the year 2000, the micro-processor technology is thousands of times more advanced than what existed back then. But still the robots of today are no way close to what our movies portray them to be. This is not only due to drawbacks in processor technology, but also in various other fields such as vision, motor control so and so forth.

    Robots may never make it to our kitchens or living rooms as personal slaves, but they certainly have made their way to the manufacturing industry, aero-space industry, and yes to the work benches of robotic hobbyists. Robots are now working in dangerous places, such as nuclear disposal, space explorers, fire fighting and many more.

    The word "robot" originates from the Czech word for forced labor or serf. Robots are electronic devices intended to perform a desired function. Many refer to them as "machines", however, a drill press is a machine, yet it requires an operator to perform its function, where robots can be programmed to do it

  • themselves. Robots have the potential to change our economy, our health, our standard of living, our knowledge and the world in which we live. As the technology progresses, we are finding new ways to use robots. Each new use brings new hope and possibilities, but also potential dangers and risks. Robotics is not only a science, but it is also an art. The bots we build reflect the ideas and personalities we portray. There are many different versions of robots that can be made. From turtle bots to vehicles like the Mars rovers to rovers like R2-D2. From walkers that have anywhere from 1 to 10 legs to robotic arms to androids. Whatever you can dream, you can create. The level of expertise you want your robot to have and how much learning and research you want to do is up to you. For those who have relative experience in computer programming and electronics, this may come easier to you than anyone new to the hobby. Those who build models, RC vehicles, and other artwork will find it challenging to modify some of their previous projects.

    We have seen how ants always travel in a line, following an invisible route in search of food, or back home. How on roads we follow lanes to avoid accidents and traffic jams. Ever thought about a robot which follows line? A perfect or near perfect mimic of mother-nature? After all the purpose of robotics is to recreate in terms of machines what we see around to solve a problem or fulfill a requirement.

    Programming intelligence into a robot (or computer) is a difficult task and one that has not been very successful to date even when supercomputers are used. This is not to say that robots cannot be programmed to perform very useful, detailed, and difficult tasks; they are. Some tasks are impossible for humans to perform quickly and productively. For instance, imagine trying to solder 28 filament wires to a 1/4in square sliver of silicon in 2 s to make an integrated

  • circuit chip. Its not very likely that a human would be able to accomplish this task without a machine. But machine task performance, as impressive as it is,

    isnt intelligence.

    2.2. PROBLEM DEFINITION

    In the industry carriers are required to carry products from one manufacturing plant to another which are usually in different buildings or separate blocks. Conventionally, carts or trucks were used with human drivers. Unreliability and inefficiency in this part of the assembly line formed the weakest link. The project is to automate this sector, using carts to follow a line instead of laying railway tracks which are both costly and an inconvenience.

    2.3. OBJECTIVES OF THE STUDY

    The robot must be capable of following a line.

    It should be capable of taking various degrees of turns.

    It must be prepared of a situation that it runs into a territory which has no line to follow. (Barren land syndrome)

    The robot must also be capable of following a line even if it has breaks.

    The robot must be insensitive to environmental factors such as lighting and noise.

    It must allow calibration of the lines darkness threshold.

    The robot must be reliable.

    Scalability must be a primary concern in the design.

    The color of the line must not be a factor as long as it is darker than the surroundings.

    2.4. SCOPE OF STUDY

    The robot can be further enhanced to let the user decide whether it is a dark line

  • on a white background or a white line on a dark background. The robot can also be programmed to decide what kind of line it is, instead of a user interface. The motor control could be modified to steer a convectional vehicle, and not require a differential steering system. The robot could be modified to be a four wheel drive. Extra sensors could be attached to allow the robot to detect obstacles, and if possible bypass it and get back to the line. In other words, it must be capable predicting the line beyond the obstacle. Speed control could also be incorporated. Position and distance sensing devices could also be built in which can transmit information to a mother station, which would be useful in tracking a lost carrier.

    2.5. REVIEW OF LITERATURE

    First and foremost, no robot could have been built to completion without a strong hold on the microcontroller used. Most of the basic, intermediate, and advanced literature about the ATMEGA microcontroller was found in the book Programming and Customizing the AVR Microcontroller by Dhananjay V. Gadre. His detailed explanation of every topic made it possible to overcome many problems which were encountered during design and implementation. The book also provided a programmer for the ATMEGA microcontroller which was an indispensable tool helping me experiment with algorithms rather than blindly copy code from the NET.

    The next resource for the ATMEGA microcontroller was the ROBOGYAN by ROBOTICWARES PVT. LTD. which provides a detailed explanation of each and

    every hardware feature and the instruction set. The most helpful is the design

    tips section which answered most of the questions which were bogging my head down.

    Robotics by C. K. Kuo was another book I referred for this project. Even though

  • it was of no direct use to this project, it made me understand many aspects of robotics which Id have ignored otherwise. Hopefully, the knowledge I have gained by this book will come in handy in my next robotic endeavor.

    Last, but definitely not the least; the Internet. This is where I found websites giving detailed explanations on a few terminologies. Reference of similar projects created by others and badly needed tutorials. There is no other place to easily get the data sheets of the used components. I have listed out a few websites which were of most help for the project. And in the finale, a huge thanks to Google.com, no other search engine is even close! No I could not have done anything without the NET even if I had a million books. The NET is worth much more.

    2.6. APPLICATION

    Industrial automated equipment carriers

    Entertainment and small household applications.

    Automated cars.

    Tour guides in museums and other similar applications.

    Second wave robotic reconnaissance operations.

    2.7. LIMITATIONS

    Choice of line is made in the hardware abstraction and cannot be changed by software.

    Calibration is difficult, and it is not easy to set a perfect value. The steering mechanism is not easily implemented in huge vehicles

    and impossible for non-electric vehicles (petrol powered). Few curves are not made efficiently, and must be avoided. Lack of a four wheel drive, makes it not suitable for a rough terrain. Use of IR even though solves a lot of problems pertaining to

  • interference, makes it hard to debug a faulty sensor. Lack of speed control makes the robot unstable at times.

    2.8. METHODOLOGY

    The first idea was to use optical imaging (CCD cameras) to see the line. This was later given up due to various reasons including complexity and unavailability of components. Later a choice was made to use an array of sensors which solved most of the problems pertaining to complexity.

    The resistor values used in the sensor array were experimentally determined rather than theoretical mathematical design calculations. This was done as the data sheets of the proximity sensor was not available anywhere and most of the parameters had to be determined experimentally.

    The L298 chip is used as it was a much better option than forming an H-Bridge out of discrete transistors, which would make the design unstable and prone to risk of damage.

    The AVR microcontroller was used as it is the only device I have a full practical knowledge about, and most of all a RISC processor which are better suited for real-time operations. Thus the midrange devices were chosen. At PB3 pin pwm can be generated.

    The PCB is the only thing in the whole project for which I turned for outside help. By the time the design became successful, time had run out. I no longer had time or resources to create a PCM myself. This was done by JI Electronics.

    The project was entirely (other than PCB) designed, created, soldered, tested and coded by me. For which Im thankful for, as I have learnt much more in the processes and not to mention the fun had.

  • 3. THEORY 3.1. THE DIFFERENTIAL STEERING SYSTEM

    The differential steering system is familiar from ordinary life because it is the arrangement used in a wheelchair. Two wheels mounted on a single axis are independently powered and controlled, thus providing both drive and steering. Additional passive wheels (usually casters) are provided for support. Most of us have an intuitive grasp of the basic behavior of a differential steering system. If both drive wheels turn in tandem, the robot moves in a straight line. If one wheel turns faster than the other, the robot follows a curved path. If the wheels turn at equal speed, but in opposite directions, the robot pivots.

    Figure 3.1: The Differential steering model

    Where give the displacement (distance traveled) for the left and right wheels respectively, is the turn radius for the inner (left) wheel, is the distance between wheels (from center-to-center along the length of the axle), and is the angle of the turn in radian. In this discussion, we will treat the axle's center

  • point as the origin of the simulated robot's frame of reference.

    Once we've established the simple geometry for the differential steering system, it is easy to develop algorithms for controlling the robot's path. Note, though, that we did make an important simplifying assumption: the wheels maintain a steady velocity. We neglected the effects of acceleration. If the wheels are allowed to accelerate, the curve which describes the robot's trajectory can become much more complicated. When working with very light robots, where the mass (and inertia) of the platform is small, we can often get away with treating changes in speed as nearly instantaneous. The path that the robot follows will not be truly circular, but it will be close enough for many applications. For larger and heavier robots, of course mass is important and acceleration must be considered.

    If the right wheel is moving at a velocity of VR and the left wheel at a velocity of VL, then the following equation can be derived :-

    Where a positive implies counter-clockwise rotation; the above equation clearly shows that the angle of the turn can be increased by either,

    Increasing the difference in the wheels velocities (VR VL), or Keep the wheels at the different velocity for a longer time (t)

    All this while b remains constant; in the line following robot, both these parameters are dynamically changed by the sensors in order to keep the robot on the line.

    3.2. D.C. MOTORS

    DC motors are widely used, inexpensive, small and powerful for their size. Reduction gearboxes are often required to reduce the speed and increase the torque output of the motor. Unfortunately more sophisticated control algorithms

  • are required to achieve accurate control over the axial rotation of these motors. Although recent developments in stepper motor technologies have come a long way, the benefits offered by smooth control and high levels of acceleration with DC motors far outweigh any disadvantages.

    Several characteristics are important when selecting DC motors and these can be split into two specific categories. The first category is associated with the input ratings of the motor and specifies its electrical requirements, like operating voltage and current. The second category is related to the motor's output characteristics and specifies the physical limitations of the motor in terms of speed, torque and power.

    Example specifications of the motors used are given below:

    As noticed, the torque provided can hardly move 30gm of weight around with wheel diameter of about 2cm. This is a fairly a huge drawback as the robot could easily weigh about a kg. This is accomplished by gears which reduce the speed (2400 rpm is highly impractical) and effectively increase the torque. If the speed is reduced by using a gear system by a factor of then the torque is increased by the same factor. For example, if the speed is reduced from 2400 rpm, to 30 rpm, then the torque is increased by a factor of (2400/30 = 80) in other words the torque becomes 30 80 2400 gm-cm or 2.4 kg-cm which is more than sufficient.

  • 3.3. H-BRIDGE MOTOR CONTROL

    DC motors are generally bi-directional motors. That is, their direction of rotation can be changed by just reversing the polarity. But once the motors are fixed, control becomes tricky. This is done using the H-Bridge. The figure is given below.

    The Explanation is simple, If A & D are turned on, then the current flows in the direction shown in the figure below.

  • Figure 3.3: Clockwise rotation

    If B & C are turned on, then the motor rotates in counter clockwise direction.

    Figure 3.4: Counter-Clockwise rotation

    If you turn on the two upper circuits, the motor resists turning, so you

    effectively have a breaking mechanism. The same is true if you turn on both of the lower circuits. This is because the motor is a generator and when it turns it generates a voltage. If the terminals of the motor are connected (shorted), then the voltage generated counteracts the motors freedom to turn. It is as if you are applying a similar but opposite voltage to the one generated by the motor being

  • turned. In other words, it acts like a brake. Any other state like A & C = ON or B & D = ON will cause a direct path to ground causing a very high current to pass through the relays thus causing a burnt fuse (if it exists).

    The following figure shows an H-Bridge using only transistors. The same theory applies.

    Figure 3.5: H-Bridge using transistors.

    Usually, the above circuitry can be used only for direction control. The Existing H-Bridge is further modified to include another transistor, now making speed control possible too. This is shown in the figure below.

    Figure 3.6: Enhanced H-Bridge

  • The same direction rules apply, but now the motor will behave as per the direction control only when a 1 is given to the EN input. Speed control is usually done by giving a PWM signal, and the duty cycle is varied to vary the speed of the motor. Usually protection diodes are also incorporated across the transistors to catch the back voltage that is generated by the motor's coil when the power is switched on and off. This fly-back voltage can be many times higher than the supply voltage! If diodes are not used, the transistors have a good chance to get burnt.

    3.4. THE IR SENSORS

    The MOC7811 consists of an infrared emitting diode ( = 950nm) and an NPN silicon phototransistor mounted to face each other on a converging optical axis in a black plastic housing. The phototransistor responds to radiation from the emitting diode only when no object is present within its field of view. This sensor is physically modified so that the emitter and detector face the same direction and thus the modified sensor serves the purpose of an optical-reflective sensor. The sensor has a focal length of 8mm, thus the surface must be at an optimum distance of 1.6cm. The original and modified sensors are shown below.

    Figure 3.7: LEFT: Original sensor, RIGHT: modified sensor

  • Figure 3.8: Reflective sensor

    If a reflective (white) surface is present at the optimal distance (d = 1.6cm) then the reflected waves will strike the detector which on radiation will start to conduct. The circuit diagram is shown in the figure below.

    3.5. COMPARATOR

    A comparator is a circuit which compares a signal voltage applied at one input of an op-amp with a known reference voltage at the other input, and produces either a high or a low output voltage, depending on which input is higher. The input / output characteristics of a comparator is as shown.

    Figure 3.9: Comparator transfer characteristics.

  • 3.6. VOLTAGE REGULATOR

    It has been shown that practically all electronic devices need DC supply. A direct voltage of constant magnitude requires to be supplied, for the smooth and efficient functioning of these devices. A properly designed voltage regulator ensures that, irrespective of change in supply voltage, load impedance or temperature, the DC supply is maintained at a constant level. This is achieved by incorporating some type of feedback in the regulator circuit.

    An IC voltage regulator unit contains all the circuitry required in a single IC. Thus there are no discrete components and the circuitry needed for the reference source, the comparator and control elements are fabricated on a single chip. Even the over load and short-circuit protection mechanism is integrated into the IC. IC voltage regulators are designed to provide either a fixed positive or negative voltage, or an adjustable voltage which can be set for any value ranging between two voltage levels.

    3.7. BATTERY

    Motors on a robot consume most of the power. For most of them, each DC motor typically consumes 1.5W on the average. For differential steering, two DC motors consume up to 3W. By comparison, the logic components typically

    draw a total of about 80mA. Even at a supply voltage of 12V, the logic component only consumes 1W.

  • 3.8. INTELLIGENCE

    There are two schools of thought concerning the creation of intelligence in

    artificial systems. The first approach programs an expert system (top down); the second is a neural or behavior based system (bottom up). The expert system uses rules to guide the robot in task performance. Behavior based programs create an artificial behavior in the robot that causes it to reflectively (automatically) perform the task required. Behaviors may be programmed (software) or may be hardwired into the robot. Behavior based intelligence doesnt require a central processor, although such a system may have one.

    Lets look at a practical programming problem and see how each approach differs. Suppose you worked for a company that designed a new robotic vacuum cleaner. The purpose of the robot is to vacuum the floor of a customers home or apartment. Your job is to program the navigation system. The robot needs to move autonomously throughout the house. How would you go about programming the robot to accomplish navigation around the home so it could travel in and out of rooms without destroying the place?

    Lets assume you first decide to try an expert navigation system. This approach uses brute force programming and a lot of memory. You might begin by dividing the task of vacuuming the apartment or home into smaller tasks such as vacuuming individual rooms. You begin by programming into the robots memory an electronic map (floor plan) of the home or area where the robot needs to vacuum. Then you map out each individual room and its contents. The robot must have the ability to measure its movement as it moves as well as compass direction to maintain its location integrity. Once this is accomplished, the robot must have an exact start location on the floor plan.

    The robots movement from the start position is measured and plotted on its

  • internal floor plan map. Problems occur if an object is positioned differently or is out of place, such as a trash receptacle or chair that has been moved. In this situation the real world does not match the robots internal map. Similar problems occur if new objects are left on the floor such as a bag, toy, or pet.

    Even so, these obstacles would not present too much of a problem for an expert system. To compensate, a secondary collision detection subprogram could be written to detect, map, and go around an obstacle not existing on the internal map. The robot continues to move and vacuum the floor. Keep in mind that as the robot navigates around new obstacles, its continually updating its internal map as it travels, to maintain its location integrity. These tasks are gobbling up computer time and memory.

    The robot vacuum accomplished its task. Now suppose you w ant to share this robot or rent it. Now you have a problem. Each new house and every room in the new house would require its own electronic map. Although expert programming does work, it tends to be inflexible and not adaptive toward new or innovative situations.

    Now lets try the other approach that uses behavior based or bottom-up programming. Instead of programming internal maps, we program sensor responses and behavior based algorithms (feed-forward and feedback loops) for sensing and traveling around obstacles and avoiding getting stuck underneath furniture or trapped in corners. Without any internal map we allow the robot to travel and move around the house in a random manner. The idea is that while traveling in a haphazard manner, it will eventually make its way throughout the rooms, cleaning the floor as it goes. Because the robot travels randomly, it will take longer for the robot to vacuum the entire floor, and it may miss a spot here and there, but it gets the job done. Since this behavior based type of robot vacuum isnt programmed for a particular house or room, it may be used in any

  • house in any room at any time.

    While our example is simple, it does illustrate the main differences between expert and behavior based (neural) programming. But lets look at just one more example before we move on.

    Expert systems typically have all the answers that the designers believe will be required by the system programmed into the system before it begins. It may store and categorize new information, but based on previously determined categories and existing knowledge. An example of this system could be a rock identification system. The robot examines unknown rocks based on known characteristics of rocks, such as color, hardness, scratch ability, acid reaction tests, mass, etc. The expert system fails if it inadvertently picks up a piece of ice that melts to water during the tests. Well, it fails as long as the designer(s) never anticipated the robot picking up a piece of ice by mistake and made allowances for it.

    Neural (behavior based) systems are not programmed and are more adaptive, as shown in the previous example. But is a neural system suitable for this task of rock identification? Probably not! There are instances in which expert systems are the method of choice. One shouldnt blindly assume one system is better than the other in all cases.

    To date, behavior based robots are more successful at task accomplishments such as traveling over unfamiliar and rough terrain than are programmed robots. (Other neural based intelligence includes speech recognition, artificial vision, speech generation, complex analysis of stock market data, and life insurance policies.)

    The line following robot uses behavior based programming, to accomplish the task at hand. For one, the system may not be a neural system pre say. But this

  • is simulated in software.

    3.9. THE AVR ATMEGA 16 MICROCONTROLLER

  • 4. DESIGN AND IMPLEMENTATION

    4.1. SCHEMATIC

    The schematic of the Line following robot is shown in the figure. The main component is the ATMEGA 16 microcontroller. Due to page limitations, the schematic is divided into two sections; one the Sensor Array Board, and the other the motor-control or main board.

    The main features incorporated into the hardware are given below:

    The AVR ATMEGA 16 microcontroller

    The voltage regulator [IC 7805] Electrolytic Capacitor (100uf) IN 4004 [DIODES] Crystal oscillator (16MHz) The H-bridge motor control IC (L298) Motors (6V), with coupled reduction gears. 4*1.5V, R6 Zinc Chloride battery.

    LTH-1550-1 IR interrupt sensor

    The LM324 comparator IC

    INDUCTOR [10uH] Connectors to join the different boards to form one functional device.

    Each of the hardware is dissected and was designed/implemented separately for their functional and later incorporated as one whole application. This helped in the debugging processes. In similar fashion the separate modules forming the ensemble will be explained separately.

  • 4.1.1. Sensor Circuit Research and Development

    The research done on the line sensors showed that there are two main

    methods used:

    A Light dependant resistor picking up light reflected off the floor from an

    LED.

    A Phototransistor picking up light reflected from an infra red LED.

    The Infra Red option has 2 major benefits over the visual spectrum solution.

    Firstly that the Infra Red Spectrum is a lot cleaner than the visual spectrum,

    there is a lot less potential for interference. The other advantage is that

    phototransistors will react much quicker than Light dependant resistors.

    However, what appears white and black to the naked eye, may not be

    distinguishable in the Infra red spectrum.

    The resistance of the sensor decreases when IR light falls on it. A good sensor will have near zero resistance in presence of light and a very large resistance in absence of light. We have used this property of the sensor to form a potential divider. The potential at point 2 is

    Rsensor / (Rsensor + R1).

    Again, a good sensor circuit should give maximum change in potential at point 2 for no-light and bright-light conditions. This is especially important if you plan to use an ADC in place of the comparator.

    To get a good voltage swing, the value of R1 must be carefully chosen. If Rsensor = a when no Light falls on it and Rsensor = b when light falls on it. The difference in the two potentials is: Vcc * { a/(a+R1) - b/(b+R1) }

  • Relative voltage swing = Actual Voltage Swing / Vcc = Vcc * { a/(a+R1) - b/(b+R1) } / Vcc = a/(a+R1) - b/(b+R1)

  • 4.1.2. THE MICROCONTROLLER

    Atmel's AVR microcontrollers have a RISC core running single cycle

    instructions and a well-defined I/O structure that limits the need for external components. Internal oscillators, timers, UART, SPI, pull-up resistors, pulse width modulation, ADC, analog comparator and watch-dog timers are some of the features you will find in AVR devices.

    AVR instructions are tuned to decrease the size of the program whether the code is written in C or Assembly. With on-chip in-system programmable Flash and EEPROM, the AVR is a perfect choice in order to optimize cost and get product to the market quickly.

    -http://www.atmel.com/products/avr/

    Apart form this almost all AVRs support In System Programming (ISP) i.e. you can reprogram it without removing it from the circuit. This comes very handy when prototyping a design or upgrading a built-up system. Also the programmer used for ISP is easier to build compared to the parallel programmer required for many old uCs. Most AVR chips also support Boot Loaders which take the idea of In System Programming to a new level. Features like I2C bus interface make adding external devices a cakewalk. While most popular uCs require at least a few external components like crystal, caps and pull-up resistors, with AVR the number can be as low as zero!

    Cost: AVR = PIC > 8051 (by 8051 I mean the 8051 family)

    Availability: AVR = PIC PIC > 8051

    Built-in Peripherals: This one is difficult to answer since all uC families offer comparable features in their different chips. For a just comparison, I would rather say that for a given price AVR = PIC > 8051.

    Tools and Resources: 8051 has been around from many years now, consequently there are more tools available for working with it. Being a part of many engineering courses, there is a huge community of people that can help you out with 8051; same with books and online resources. In spite of being new the AVR has a neat tool chain (See References and Resources). Availability of online resources and books is fast increasing.

    Here, 8051 > AVR = PIC

  • 4.1.3 CRYSTAL OSCILLATOR

    The clock frequency is provided by one 16 Mhz crystal which is connected across the OSC1 & OSC2 pins as shown above. This provides an instruction execution time of 1 s.

    Fig 4.1

    4.1.4. BATTERY

    If we assume the whole robot consume 5W, it requires 4500J of energy to last 15minutes. If we use a 6V battery, it must have a capacity of 4500J/6V=750Asec or 104mAH. This may imply that getting a battery of 150mAH is sufficient. Unfortunately, the discharge curve of a 150mAH will not sustain the required voltage for 15 minutes.

    Thus a Zinc Chloride battery was used of rating of 1.2mA for the robot to last longer than 15min and also to take practical situations into considerations.

    4.1.5. VOLTAGE REGULATOR

    The circuit requires two voltage sources; one for the digital ICs (+5V) and a +12V to the motors. The motor is supplied 12V unregulated supply directly from the battery as regulation would be difficult and unnecessary; whereas the digital ICs and the microcontroller require a perfect ripple free +5V to function properly. The L7805C is a 5V voltage regulator IC. The capacitors added to the input of the voltage regulator are to isolate the spikes generated by the motor

  • from the input and to reduce noise. The 10 F capacitor at the output is to maintain stability and improve regulation. These are standard values. The 0.1 F capacitor is used at the input because of the fact that high value capacitors have poor high frequency response.

    4.1.6. D.C. MOTORS

    Geared D.C. motors were used which can operate in the range from 0V to 12V

    .The D.C. motors have a speed of 2400rpm and a torque of 15gm-cm. The gears decrease the speed to 30rpm at 6V and thus considerably increasing the torque so that the robot can carry the load of its frame and the lead-acid battery. Two such motors are used in the rear of the robot, and a dummy castor is fixed to the front to stabilize the robot.

    4.1.7. THE H-BRIDGE CONTROL HARDWARE

    The entire motor control circuitry is shown in the above figure along with the internal circuitry of the L293D motor control IC. The table below clearly indicated the operation of the IC.

  • The total number of directional control signals required is 4; but as it can be observed in the above table, IN1 & IN2 are complimentary (and so is IN3 & IN4) that is, both the inputs have to take the opposite states for a safe operation. This is done by connecting DL to IN1 and DL to IN2. The same is done to IN3 & IN4. Now we have 1 directional control per motor. The ENABLE of each motor section is given PWM inputs to further improve on the control. Now,

    each motor has a direction control and a speed control. The clamping diodes are built into the chip which prevent the back EMF generated by the motors to harm the H-bridge. The inversion was achieved using the 74HCT04 HEX inverter IC

  • having a slew rate of about 6ns which is negligible compared to the reaction time of the H-bridge itself.

    4.1.8 COMPARATOR

    The reference voltage is generated by the 20k POT and given to all the comparators to the non-inverting input. When the respective sensor is on the

    line, the emitted light is absorbed by the line and the transistor is the cut-off mode, thus a potential of 4.6V is given to the inverting input which is greater than Vref (which is chosen to be 2.5V), thus the output of the comparator goes low. When the sensor is not on the line (reflective white surface) the potential across the detector is usually 0.6V. Thus the output of the comparator goes high (the non-inverting input has a greater potential). Thus the output of the comparator goes low only when the sensor is over the line. The comparator is

    open collector, and hence a pull-up resistor of 10 k is required at the output.

    4.2 Chassis Research and Development

    The size of the buggy was determined by the circuitry which is to go inside it.

    Once we had got a basic idea of the electronics side of the project we could

    then start to construct the chassis. This determined the positioning of the

    sensors, motors and the front skid. We decided to position the line follower

    sensor in such a way to enable it to handle the tightest corners.

    The boards are mounted to the chassis using M4 50mm bolts these bolts hold

    the circuits a safe distance from each other. There are 4 lugs in the chassis, and

    4 holes in the body, to hold the two together.

  • 4.3. PROCESS EXPLANATION

    As shown in the figure above, is a typical situation involved. At every sampled

  • time the commands executed by the microcontroller is also shown. From the above figure, it should be clear about the software requirements.

    Spiral movement during line find mode.

    The surface is sampled every 2.1ms using the timer 0 interrupt routine. This implies that the line is sampled 476 times in a second. From observations, the robot travels at a maximum speed of around 10cm/sec. In other words, 47.6 samples are taken per cm, or 4.76 samples per mm. This is more than ever required! Due to the fact that the robot can remember and follow the previous task when its sensors do not see a line, enables the robot to trace a sharp turn, even if in case the robot runs off the line while making the turn.

    Robots line approximation

  • The 8 sensors are connected to PORTA.

    You need not connect anything to AVCC and AREF, it is required only if ADC is used. The L298 Motor Driver has 4 inputs to control the motion of the motors and two enable inputs which are used for switching the motors on and off. To control the speed of the motors a PWM waveform with variable duty cycle is applied to the enable pins. Rapidly switching the voltage between Vs and GND gives an effective voltage between Vs and GND whose value depends on the duty cycle of PWM. 100% duty cycle corresponds to voltage equal to Vs, 50 % corresponds to 0.5Vs and so on. The 1N4004 diodes are used to prevent back EMF of the motors from disturbing the remaining circuit. Many circuits use L293D for motor control, I chose L298 as it has current capacity of 2A per channel @ 45V compared to 0.6 A @ 36 V of a L293D. L293Ds package is not suitable for attaching a good heat sink; practically you cant use it above 16V without frying it. L298 on the other hand works happily at 16V without a heat sink, though it is always better to use one.

    4.4 ALGORITHM

  • 4.5 FLOW CHART

  • 4.6 SOURCE CODE

    /*****************************************************

    Project: Line Follower

    Date : 7/12/2009

    Author: Pallav Kumar Nayak

  • Company: BRM IIT

    Compiler: CodeVision AVR

    Chip type : ATmega16

    Program type : Application

    Clock frequency : 7.372800 MHz

    Memory model : Small

    External SRAM size : 0

    Data Stack size : 256

    *****************************************************/

    //#define debug 1 #include #include #ifdef debug #include #endif

    #define FWD 0xAA #define REV 0x55 #define R 0x22 #define L 0x88 #define CW 0x99 #define CCW 0x66 #define STOP 0x00 #define B 0xFF #define RSPEED OCR1AL #define LSPEED OCR1BL #define SPEED0 255 #define SPEED1 0 #define SPEED2 0 #define SPEED3 0 #define MAX 3 #define HMAX 1

    void move (unsigned char dir, unsigned char delay, unsigned char power); unsigned char i, rdev, ldev, ip, delay, dir, power, dirl, unsigned char history[MAX],hcount=0,rotpow;

    #ifdef debug Unsigned char rep=0,prev=0; #endif

    void main(void) {

    // Input/Output Ports initialization // Port A initialization

  • // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

    // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x00;

    // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00;

    // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0xFF;

    // Port D initialization // Func7=In Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x30;

    // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected TCCR0=0x00; TCNT0=0x00; OCR0=0x00;

    // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 921.600 kHz // Mode: Fast PWM top=00FFh // OC1A output: Non-Inv. // OC1B output: Non-Inv. // Noise Canceler: Off // Input Capture on Falling Edge TCCR1A=0xA1; TCCR1B=0x0A; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0xFF; OCR1BH=0x00; OCR1BL=0xFF;

  • // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00;

    // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=0x00; MCUCSR=0x00;

    #ifdef debug // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous // USART Baud rate: 57600 UCSRA=0x00; UCSRB=0x18; UCSRC=0x86; UBRRH=0x00; UBRRL=0x07; #endif

    // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00;

    // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00;

    while (1){

    #ifdef debug if(repi)&0x01); rep=0; } #endif

    if(PINA!=255){ rotpow=255; ldev=rdev=0;

    if(PINA.3==0) rdev=1; if(PINA.2==0)

  • rdev=2; if(PINA.1==0) rdev=3; if(PINA.0==0) rdev=4;

    if(PINA.4==0) ldev=1; if(PINA.5==0) ldev=2; if(PINA.6==0) ldev=3; if(PINA.7==0) ldev=4;

    if(rdev>ldev) move(R,0,195+12*rdev); if(rdev

  • 5. RESULT AND CONCLUSION The Line following robot was finally completed. A lot of effort was put into the design, implementation and days of toil in front of the computer, writing and debugging the code. The robot was finally running with a few glitches here and there which were sorted in the later revisions of the firmware. The line following robot still has a few short-comings but achieves most of the objectives.

    I earned a lot of knowledge on micro-controllers, a deeper & clearer view of the architecture, ports & all other functional blocks was achieved. Did a lot of research on robotics and already have my next project planned. Had a peek look at all simple functional parts of the project like the crystal oscillator, logic gates and the works. Well, these were the topics that we have already dealt with, but I must be honest and admit that there were various practical issues which one would learn only during a project. Theres a lot of learning & yet not the end, learning is a continuous never ending process but is definitely fun.


Recommended