Thursday, February 26, 2015

LINE FOLLOWER ROBOT 


What is a robot ?
It is a machine which performs a variety of tasks, either using manual external control or intelligent automation.

Types of robot :
  1. Stationary 
  2. Mobile 
Contents : 
  1. Introduction 
  2. Overview 
  3. Block Diagram
  4. Material Required
  5. Circuit Diagram
  6. Software Requirement
  7. Microcontroller
  8. Development board 
  9. Motor Drive
  10. IR Sensor
  11. USB AVR Programmer 
  12. Source Code 
  13. Reference  

Introduction

Line follower is a machine that can follow a path. The path can be visible like a black line on a white surface (or vice-versa). 
Sensing a line and maneuvering the robot to stay on course, while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. 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. 
Practical applications of a line follower: Automated cars running on roads with embedded magnets; guidance system for industrial robots moving on shop floor etc. 

Overview

In the line follower robot project we have used 2 pairs of IR (infra-red) emitter/sensor. The sensor on getting blocked or unblocked sends combination of high/low signals to ATMEGA32 microcontroller which are processed andappropriate signals are sent to L293D (motor driver chip) which switches on/off the motors so as to keep the robot moving in one direction.  

Block Diagram 



Material Reqiured

The component list making the robot is as follows :
  1. Microcontroller  - 1  (ATMEGA32)
  2. Development Board - 1 ( 40 Pin AVR  Intermediate Development Board )
  3. USB AVR Programmer - 1
  4. Motor Drive - 1   (L293D)
  5. DC Gear Motor -  2  (60 rpm)
  6. IR Sensor - 2  
  7. Chassis - 1 (light weight )
  8. Adapter -1 (12 V, 1 A)
  9. Connecting Wire / Jumper Wire - as per require 

Circuit Diagram

 




Software Requirement 

      The software for the robot was coded in C, because of compiler availability, our familiarity with the language, as well as the greater control of the system offered as compared to other high level languages. While our microcontroller supports assembly language, it was avoided because it’s a difficult  to maintain, and varies greatly from processor to processor.
  CodeVision AVR  has been used in this project.
  
  • eXtreme Burner - AVR 
The eXtreme Burner -AVR is a full graphical user interface (GUI) AVR series of MCU that supports several types of clock sources for various applications. It enables you to read and write a RC oscillator or a perfect high speed crystal oscillator.   


Microcontroller 

A Microcontroller can be defined as a “Computer-on-Chip”. AVR ATmega32 8-BIT Microcontroller, In-system Programmable with Flash code storage, re-programmble up to 1000 time.
  
Features
  •       32 K BYTES of In-System Programmable Flash
  •       1K BYTES of In-System Programmable EEPROM
  •       2 K Bytes SRAM
  •       Analog Comparator
  •       28-bit Timers plus prescale
  •       216-bit Timers with prescaler, capture etc.


Development Board 

       A general purpose 40 pin AVR development board with 16x2 LCD support, power supply circuit, RS232 port for serial interface with computer and other serial devices, reset switch, power status LED, a 6 pin ISP header and 4 x general purpose LEDs and Switches.
        The board is compatible with the Atmega16, Atmega32 and other compatible 40 pin AVR microcontrollers.


Motor Driver 

L239D is a typical Motor driver or Motor Driver IC which allows DC motor to drive on either direction. L293D is a 16-pin IC which can control a set of two DC motors simultaneously in any direction. It means that you can control two DC motor with a single L293D IC.



 IR Sensor

        IR sensor are also used to distinguish between and white surfaces.White surfaces reflect all types of light while black surfaces absorb them.Therefore,depending on the amount of light reflected back to the IR recevier, the IR sensor can also be used to distinguish between black and white surfaces. 



USB AVR Programmer 

Programmer is basically used for to burn program in microcontroller.



Source Code


/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.6 Evaluation
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : 
Version : 
Date    : 10-02-2015
Author  : Freeware, for evaluation and non-commercial use only
Company : 
Comments: 


Chip type               : ATmega32
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 512
*****************************************************/

#include <mega32.h>
#include <delay.h>
// Declare your global variables here

void main(void)
{
// Declare your local variables here

// 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=0x00;

// Port D 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 
PORTD=0x00;
DDRD=0x00;

// 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: Timer1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 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;

// 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;
DDRA=0;
DDRD=255;
while (1)
      {
      if((PINA.0==1)&&(PINA.1==1))
      PORTD=0b00001010;
      else if((PINA.0==0)&&(PINA.1==1))
      PORTD=0b00001001;
      else if((PINA.0==1)&&(PINA.1==0))
      PORTD=0b00000110;
      else
      PORTD=0;     
      delay_ms(20);       
      }
}


Reference

1) https://www.atmel.com
2) www.8051projects.info/proj.asp?ID=50
3) One of the best sites AVR site www.avrfreaks.net.
4) extremeelectronics.co.in