You are on page 1of 30

Line follower with arm lifter

PROJECT REPORT

Line Follower With Arm Lifter

Submitted To :
Sir Azhar Zaidi

Submitted By :
Nida Afaq

08-EE-128

Qurat ul-ain

08-EE-137

Mohsin Majeed

08-EE-17

Hamza Shahid

08-EE-116

Abstract:
1

Line follower with arm lifter


This project is an implementation of a line following robot, with modification of metal rods
connected to it. It senses and follows a path of white color and lifts any box that comes in its
way.PIC18F458 is the microcontroller used .Sensors are used to detect the right color and
let the robot follow it. Sensors are also placed at the right side of robot, which detects a
junction. This robot gives basis for any type of robot which is not remote controlled. So it
can be used in any advanced robot with increased complexity and larger size.

Acknowledgement:

Line follower with arm lifter

Table Of Contents:

Project description:
The project mainly comprises of three sections.
microController section
Mechanical section
Sensors
3

Line follower with arm lifter


Micro-Controller Section:
This section comprises of all the coding that is done to make the robot follow the line and lift
box.PIC 18F458, is the microcontroller used. MikroC is used for programming in C
language.

Microcontroller:
Different microcontrollers are available like Motorola,Intels 8052,Atmels AVR,Zilogs Z8 and
PIC.PIC is chosen for this project as
It is cost effective.
Software and hardware development tools like compilers, assemblers,
debuggers and emulators are easily available.
It meets our computing needs more efficiently.

PIC:
PIC has different families 10xxx,12xxx,14xxx,16xxx,17xxx and 18xxx.they all are 8 bit
processors .data larger than 8 bit is broken into 8-bit pieces to be processed.PIC 18xxx
family is used as it has the highest performance of all the families of 8-bit PIC
microcontrollers and it is available in 18- tpo 80- pin packages with easy migration to more
powerful version of chip without losing software compatibility.

PIC18F458:
PIC 18 has a RISC architecture that comes with some standard features such as on-chip
program(code) ROM, data RAM, data EEPROM, timers ,ADC and USART and I/O
ports.PIC 18 deals with 16 bit instructions and PIC family having letter F in part no indicates
that on-chip ROM is flash.
PIC 18F458 is used for this project because it has easy bidirectional motion .
It is a 40 pin IC that comes in different packages such as DIP(dual in-line
packages),QFP( quad flat package) and LLC (leadless chip carrier).a total of 33 pins are set
aside for the five port A,B,C,D,E with their alternative functions. The rest of the pins are
4

Line follower with arm lifter


designated as Vdd ,GND (Vss),OSC1,OSC2 and MCLR(master clear).in this project we are
using PIC 18F458 in DIP packaging.

Mechanical section:
The mechanical sector comprises of motors, wheels, and aluminum sheet and arm lifter.
The figure below shows the full mechanic al structure

Motors:
5

Line follower with arm lifter

The motors used are the motors of power window of car .three motors are used in total ,two
for moving the line follower and one is used for raising and lowering the arm lifter. The
speed of motor is more than our requirement so it is coupled with the gear to increase the
torque and consequently reduce the speed to our required level.the output of the gear is
connected to the shaft which is passing through the wheels.

Ratings:
The motor is of 12V and 1.5 A.

Wheels:
6

Line follower with arm lifter


The wheels are made up of nylon material having a grooved surface. The wheels are
wrapped with rubber to reduce the friction and move the robot easily.

Arm lifter:
It is made up of aluminium sheets and with the help of nut it is connected to shaft of motor.
The arm moves up and down by the clockwise and anticlockwise rotation of motor.
specifications of motor are same (12V & 1.5 A)

Line follower with arm lifter

Line follower with arm lifter

Aluminum sheets :
The sheets used are of 19 guage.the sheet which is used to place motors and batteries is of
width 16 inches and of length 19 inches. The aluminum rods which connect the base sheet
with top sheet are of 10 inches. The top sheet is used to place PCB s.The aluminum sheets
are bended to increase the mechanical strength.

Batteries:
In this project two batteries are used to power the circuit and these are of 12 V ,5A/20H.
9

Line follower with arm lifter

Sensors:
Seven sensors are used in total. Five of them are used to keep the robot in line and two of
them are used to detect junction. The sensing utilizes the properties of LDRs
Five sensors used are labeled as Sc, Sl , Sl , Sr , Sr. If Sc and one of Sr is active it means
robot is turning right so speed of left motor is increased to bring it back onto center line and
if Sc and one of Sl is active it means it is turning towards left so speed of right motor is
increased to bring it back onto centre line.

Junction sensor:
Sensors at junction are labeled as Jl and Jr.if Jl gives 0 output followed by 0 output of j r it
means that robot have crossed some junction.

Schematic:
10

Line follower with arm lifter


For sensor circuit LM324 IC is used. It is a 14 pin IC, Out of which 3,5 ,10,12 are input pins.
So for seven sensors two such ICs are used. The figure below just showing one sensor
circuit. This IC needs 5Vs to function properly.

PCB Designing:
PCB designs of project is as follow

11

Line follower with arm lifter

Algorithm of project

Code:
12

Line follower with arm lifter


The following code is used to move the line follower and lift object placed at
junction.
//take f=125hz
// for left h bridge RE0, 1 n RD0, 1
//for right Rb0, 1 n RD2, 3
//H-Bridge
//LEFT
#define A PORTD.F0;
#define B PORTD.F1;
#define C PORTE.F0;
#define D PORTE.F1;
//RIGHT
#define A2 PORTD.F2;
#define B2 PORTD.F3;
#define C2 PORTB.F0;
#define D2 PORTB.F1;

//five sesors
#define sll PORTA.F0;
#define sl PORTA.F1;
#define sc PORTA.F2;
13

Line follower with arm lifter


#define sr PORTA.F3;
#define srr PORTA.F4;
#define jr PORTB.F4;
#define jl PORTB.F5;
unsigned char JR=0;
unsigned char JL=0;

void start();
void stop();
void linetr();
void arm(int);
void turnrght();
void turnlft();
void reverse();
void rght6();
void rght4();
void rght2();
void rght1();
void lft6();
void lft4();
14

Line follower with arm lifter


void lft2();
void lft1();

//#pragma code
//#pragma interrupt multi_chk_isr
void multi_chk_isr()
{
if(INTCON.F0==1)
{
JR++;
JL++;
}
if (JR==2 && JL==2)
{
stop();
arm(1);
start();
reverse();
INTCON.F0=0;
}
15

Line follower with arm lifter


if (JR==4 && JL==4)
{
stop();
start();
while(PORTA.F2!=0)
{turnrght();}

linetr();
INTCON.F0=0;

}
if (JR==6 && JL==6)

{
stop();
arm(2);
start();
reverse();
INTCON.F0=0;
}
16

Line follower with arm lifter


if(JR==8 && JL==8)
{
stop();
start();
while(PORTA.F2!=0)
{turnrght();}
linetr();
INTCON.F0=0;
}
}
void linetr(void) { start();
while(1)
{
if (PORTA.F0 == 1 && PORTA.F1==1 && PORTA.F2==0 && PORTA.F3==1 &&
PORTA.F4==1)
{
//straight
//for left motor
PORTD.F0=1;
PORTE.F0=0;
PORTD.F1=1;
17

Line follower with arm lifter


PORTE.F1=0;
//for right motor
PORTD.F2=1;
PORTB.F0=0;
PORTD.F1=1;
PORTB.F1=0; }

else if(PORTA.F0==1 && PORTA.F1==1 && PORTA.F2==0 &&


PORTA.F3==0 && PORTA.F4==1)
{
//slight right
rght6();
}
else if (PORTA.F0==1 && PORTA.F1==1 && PORTA.F2==1 &&
PORTA.F3==0 && PORTA.F4==1)
{
//medium right
rght4();
}
else if (PORTA.F0==1 && PORTA.F1==1 && PORTA.F2==1 &&
PORTA.F3==0&& PORTA.F4==0)
18

Line follower with arm lifter


{//mid extreme right
rght2();
}
else if (PORTA.F0==1 && PORTA.F1==1 && PORTA.F2==1 && PORTA.F3==1
&& PORTA.F4==0)
{
//extreme right
rght1();}
//END OF RIGHT TURNS
//BEGINING OF LEFT TURNS
else if (PORTA.F0==1 && PORTA.F1==0 && PORTA.F2==0 &&
PORTA.F3==1 && PORTA.F4==1)
{
//slight left
lft6();
}

else if (PORTA.F0==1 && PORTA.F1==0 && PORTA.F2==1 &&


PORTA.F3==1 && PORTA.F4==1)
{
//medium left
19

Line follower with arm lifter


lft4();
}
else if (PORTA.F0==0 && PORTA.F1==0 && PORTA.F2==1 &&
PORTA.F3==1 && PORTA.F4==1)
{
//med-extreme left
lft2();

else if (PORTA.F0==0 && PORTA.F1==1 && PORTA.F2==1 &&


PORTA.F3==1 && PORTA.F4==1)
{
//extreme left
lft1();
}
}
}

void rght6()
{
20

Line follower with arm lifter


//While(sr!=1)
PORTD.F0=1;
PORTE.F0=0 ;
PORTD.F1=1 ;
PORTE.F1=0;
delay_ms(6);
PORTD.F0=0;
//unsigned int e=2-d;
delay_ms(2);
}
void rght4()
{
//While(sr!=1)
PORTD.F0=1;
PORTE.F0=0 ;
PORTD.F1=1 ;
PORTE.F1=0;
delay_ms(4);
PORTD.F0=0;
//unsigned int e=2-d;
21

Line follower with arm lifter


delay_ms(4);
}
void rght2()
{
//While(sr!=1)
PORTD.F0=1;
PORTE.F0=0 ;
PORTD.F1=1 ;
PORTE.F1=0;
delay_ms(2);
PORTD.F0=0;
//unsigned int e=2-d;
delay_ms(6);
}
void rght1()
{
//While(sr!=1)
PORTD.F0=1;
PORTE.F0=0 ;
PORTD.F1=1 ;
22

Line follower with arm lifter


PORTE.F1=0;
delay_ms(1);
PORTD.F0=0;
//unsigned int e=2-d;
delay_ms(7);
}
void lft4()
{
//While(sl!=1)
{
PORTD.F2=1;
PORTB.F0=0;
PORTD.F3=1;
PORTB.F1=0;
delay_ms(4);
PORTD.F2=0;
delay_ms(4);}
}
void lft6()
{
23

Line follower with arm lifter


//While(sl!=1)
{
PORTD.F2=1;
PORTB.F0=0;
PORTD.F3=1;
PORTB.F1=0;
delay_ms(6);
PORTD.F2=0;
delay_ms(2);}
}
void lft2()
{
//While(sl!=1)
{
PORTD.F2=1;
PORTB.F0=0;
PORTD.F1=1;
PORTB.F1=0;
delay_ms(2);
PORTD.F2=0;
24

Line follower with arm lifter


delay_ms(6);}
}
void lft1()
{
//While(sl!=1)
{
PORTD.F2=1;
PORTB.F0=0;
PORTD.F1=1;
PORTB.F1=0;
delay_ms(1);
PORTD.F2=0;
delay_ms(7);}
}
void arm(int a)
{
PR2=1249;
ECCPR1L=1249;
TRISD=0x00;
T2CON=0x01;
25

Line follower with arm lifter


TMR2=0;
if(a==1)
{
ECCP1CON=0x4D;
T2CON.TMR2ON=1; }
if (a==2)
{ ECCP1CON=0xCE;
T2CON.TMR2ON=1; }
}
void turnrght(){
PORTD.F0=1; PORTE.F0=0;//LFT IN FULL SPEED
PORTD.F1=1;PORTE.F1=0;
PORTD.F2=1;PORTB.F0=0;PORTD.F1=1;PORTB.F1=0;
delay_ms(1);
PORTD.F2=0;//rght 12.5% duty cycle
}
void turnlft()
{
PORTD.F2=1;PORTB.F0=0;PORTD.F1=1;PORTB.F1=0;//rght IN FULL SPEED
PORTD.F0=1;PORTE.F0=0;PORTD.F1=1;PORTE.F1=0;
26

Line follower with arm lifter


delay_ms(1);
PORTD.F0=0;//lft 12.5% duty cycle
}
void reverse(){
PORTD.F0=0; PORTD.F2=0;
PORTE.F0=1;PORTB.F0=1;
delay_ms(250);
PORTE.F1=1;PORTD.F1=0;
PORTB.F1=1; PORTD.F1=0;}

void start()
{
PORTD.F0=1;
PORTE.F0=0;
PORTD.F1=1;PORTE.F1=0;
PORTD.F2=1;
PORTB.F0=0;
PORTD.F1=1;
PORTB.F1=0;
}
27

Line follower with arm lifter


void stop(){
PORTD.F0=0;
PORTE.F0=1;
PORTD.F1=0;PORTE.F1=1;
PORTD.F2=0;
PORTB.F0=1;
PORTD.F1=0;
PORTB.F1=1;
ECCP1CON=0x00;}

void main()
{
TRISD=0x00;
TRISE=0;
INTCON.F0=0;
INTCON.F3=1;
INTCON.F7=1;
//TMR2IE=1;
TRISA.F6=0;
TRISA.F7=0;
28

Line follower with arm lifter


TRISB.F0=0;
TRISB.F1=0;
TRISB.F4=1;
TRISB.F5=1;

TRISA.F4=1;
TRISA.F5=1;
TRISA.F4=1;
TRISA.F5=1;
TRISA.F4=1;
linetr();

Future advancements:
29

Line follower with arm lifter

30

You might also like