TITLE 2-Way Sound Sensitive Line Follower

Made under the supervision of Mr. Tarique Aziz Research Engineer Robosapiens Technologies Pvt. Ltd

Made by Abhishek Das SIP/10/2096 June, 2011

Tarique Aziz for his help throughout the term of this project.Acknowledgements I would like to thank Mr. My family and friends have also made this an enjoyable task as a result of both their personal support and the comments that only friends can make. I am indebted to him. 2 . for his thoughtful supervision and clear advice.

2.2.2. DC Geared Motors 2. Introduction 1. Objectives 1.1. Working 4.2. AVR Microcontroller (ATmega8) 3. Motor driver IC (L293D) 2.2. Photodiode 2.1. Algorithm 5. References and Resources 2 3 4 5 11 11 12 13 3 .1. IR LED 2.3.Table of Contents Acknowledgements Table of Contents 1. Operational Amplifier 2. IR Sensors 2. Components Used 2. Source Code 6.3. Project Overview 2.2.4.

Basically IR sensor takes input by detecting the reflection of the IR rays from the surface and accordingly gives its output to the motors.1.1.2. and stops at the end. As a programmer you get an opportunity to ‘teach’ the robot how to follow the line thus giving it a human-like property of responding to stimuli. 2. Practical applications of a line follower: Automated cars running on roads with embedded magnets. Sensing a line and manoeuvring the robot to stay on course. 1. while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. The principle of the line follower is based on sensing the background surface making use of IR sensor. 4 . guidance system for industrial robots moving on shop floor etc. 1. To develop a line following robot that follows a black path on white background. unaffected by any stray sounds. INTRODUCTION 1. Project Overview Line follower is a machine that can follow a path. Objectives Following were the main objectives of the project. The path can be visible like a black line on a white surface (or vice-versa) or it can be invisible like a magnetic field. To make the robot turn around and return back as a line follower when a sound is produced.

heat etc. • WHY DC MOTOR?  Easy to control  Require only two signals  To change the direction of rotation. IR sensors consist of emitter and detector.2. Emitter emits the IR rays and detector detects it. just reverse the polarity  Speed can be controlled by the voltage • USE OF GEARS  To provide enough torque  Increases the torque at the expense of speed 2. temperature. sound. The change may be in colour.1. IR Sensors Sensors are basically electronic devices which are used to sense the changes that occur in their surroundings. They sense the change and work accordingly. moisture. The IR sensor basically consists of three components:  IR LED (emitter)  Photodiode (detector)  Operational Amplifier (LM358) 5 . DC Geared Motors In our line follower DC geared motors are used. COMPONENTS USED 2.2.

The basic function of the emitter is to convert electricity into light.2. Photodiode The photodiode is a p-n junction diode which is connected in reverse bias. So when an electron from a conduction band recombines with a hole of valance band. As in the conduction band of a diode. When no light is falling on the photodiode it has infinite resistance and acts 6 . The IR Led has two legs. electrons are the majority carrier and in the valence band.2.1. IR LED IR LED is a light emitting diode which emits IR radiations. It works on the principle of recombination of the electron-hole pair. holes are majority carrier. it works effectively only when a certain number of photons or certain amount of light falls on it. As its name implies.2. 2. the leg which is longer is positive and other leg is negative.2. The basic function of the detector is to convert light into electricity. some amount of energy is released and this energy is in the form of light. The amount of energy released depends upon the forbidden energy gap.

as an open switch but as the light starts falling on the photodiode. it is named as operational amplifier. multiplication. It has two inputs. The signal which is applied to the inverted input gives output 180 degree out of phase with input whereas in the non-inverted input gives output in phase with that of input. the reference voltage is set at the inverted input pin and then it is compared with the input at non inverted pin. In the comparator mode. subtraction. as the voltage at Pin 3 exceeds the reference voltage at Pin 2 the output of the comparator becomes high (5 V) otherwise it becomes low (0 V). Due to the fact that it performs several operations like addition. Operational Amplifier It is a DC-coupled high gain amplifier with differential inputs and single output. Typically the output of the op-amp is controlled by either negative feedback or positive feedback.2. As the voltages at two input pins of op-amp is compared. In the line follower it is used in the comparator mode. integration etc. Op-amp has a variety of uses in different electronics devices.3. 7 . The reference voltage at Pin 2 is set with the help of variable resistor. inverted (Pin 2) and non-inverted input (Pin3). which is an 8-pin IC having two inbuilt op-amps. the resistance decreases and when full intensity of light is incident on the photodiode then its resistance becomes zero and it starts acting like a closed switch. 2. The op-amp IC which is used here is LM358.

Internal block diagram of LM358 IC Circuit diagram of IR sensor 8 .

L293D is a 16 pin IC having two enable pins which should always high to enable both the H-bridges.3. One H-bridge is capable of driving a DC motor bidirectionally. As the output from the sensor is not able to drive motors by itself so L293D is used for this purpose. SPI. pull-up resistors. timers. AVR Microcontroller (ATmega8) “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. analog comparator and watch-dog timers are some of the features you will find in AVR devices. Pin Diagram of L293D 2. L293D IC is a current enhancing IC.4. pulse width modulation. UART. Motor Driver IC (L293D) L293D IC is a dual H-bridge motor driver IC. AVR instructions are tuned to decrease the size of the program whether the 9 . Internal oscillators. ADC.2.

the AVR is a perfect choice in order to optimize cost and get product to the market quickly. Also the programmer used for ISP is easier to build compared to the parallel programmer required for many old µCs. Most AVR chips also support Boot Loaders which take the idea of In System Programming to a new level. caps and pull-up resistors. This comes very handy when prototyping a design or upgrading a built-up Apart from this almost all AVRs support In System Programming (ISP) i.atmel. with AVR the number can be as low as zero! 10 .code is written in C or Assembly. you can reprogram it without removing it from the circuit. While most popular µCs require at least a few external components like crystal.e. With on-chip in-system programmable Flash and EEPROM. Features like I2C bus interface make adding external devices a cakewalk.” -http://www.

If motors are not running and sound is detected. If left sensor reads 0 and right sensor reads 1. stop and wait for sound. 5. turn left. If right sensor reads 0 and left sensor reads 1. If both sensors read 0. WORKING The robot uses IR sensors to sense the line. 6. go straight. turn right. The output of the sensors is an analog signal which depends on the amount of light reflected back. ALGORITHM 1. 4.3. 3. Go to step 1 11 . When a sensor is on the line it reads 0 because rays are not reflected back and when it is off the line it reads 1 because reflected rays are incident on the photodiode. 4. turn around. this analog signal is given to the comparator to produce 0s and 1s which are then fed to the µC. If both sensors read 1. 2.

5. _delay_ms(100000). _delay_ms(50). sound = PINC & 0b0000001. if (sound==0b0000001) { PORTB = 0b00001010. while (1) { left = PINC & 0b0100000. if (left==0b0100000 && right==0b0010000) { PORTB = 0b00001001. right.h> #include <util/delay. _delay_ms(100000).h> void main () { int left. right = PINC & 0b0010000. sound. } if (left==0b0000000 && right==0b0000000) { PORTB = 0b00000000. _delay_ms(100000). _delay_ms(50). _delay_ms(100000). DDRB = 0xff. SOURCE CODE #include <avr/io. _delay_ms(100000). } if (left==0b0000000 && right==0b0010000) { PORTB = 0b00000101. } } } } 12 . _delay_ms(50). } if (left==0b0100000 && right==0b0000000) { PORTB = 0b00001010. DDRC = 0x00.

roboticsindia.6.1 (GUI based on AVRDude) 13 .net/projects/winavr Robotics India An Indian site devoted to WinAVR An open source C compiler for AVR http://sourceforge. REFERENCES AND RESOURCES Books: Robotics with AVR – Toshendra K. Sharma Links: Atmel Tools: AVR Studio Compiler: WinAVR Programmer: AVR Loader v1. Makers of the AVR microcontroller One of the best sites AVR sites http://www.atmel. Must see http://www.avrfreaks.

Sign up to vote on this title
UsefulNot useful