Komli

Tuesday, October 6, 2009

Simple Line Follower Tutorial

Hiii Everyone, I am sorry for all the people who have been logging onto my blog as I haven't been updating a lot.

I would be explaining about making a line follower, using 3 and 2 sensors. I would also be telling the advantage of using 3 sensors over two sensors.

Prerequisites :

1) Have a sensor circuit ready. You can check my post to know how to make a sensor ckt.

2) Have microcontroller (I would be using atmega8). and a motor driver ready.

Setup of sensors:

Have the sensors setup on the chassis in such a way that center sensor is atleast 2cm away from left and right sensor.( Why 2cm you will know later).

Now the LOGIC part: Assuming that arena is white in colour and line is black in colour.

L C R Direction
1 0 1 Forward [ both motors move in same direction]
0 0 1 Left [ only right motor moves]
1 0 0 right [only left motor moves]
0 0 0 Forward. ( we have encountered a junction over here)


Code to be written :

#include
int L; //left sensor connected to 1st pin of Portc, which is PINC.0
int R;// right sensor connected to 2nd pin of Portc, Pinc.1
int C;// center sensor connected to 3rd pin of Portc, Pinc.2
main()
{

if(L==1&&C==0&&R==1)
{
PORTD=0xAA;
}
if(L==0&&C==0&&R==1)
{
PORTD=0x02;
}

if(L==1&&C==0&&R==1)
{
PORTD=0x88;
}

if(L==1&&C==0&&R==1)
{
PORTD=0xAA;
}

Motors are connected to PORTD pins.

When PORTD=0xAA;

AA stands in hex as 10101010 [ Most significant bit to least significant bit]

So the motor pins are connected as follows: Consider only the first four bits/pins, bcz we wont be using the last four bits/pins.

PIND.0= R-;
PIND.1= R+;
PIND.2=L-;
PIND.3=L+;

When R+,L+ are high. Both the motors would rotate in one direction.

When R+ is high, rest ground. Only the right motor would rotate.

Same thing for rest all.

I hope you did understand the code . I will be posting the ckt of it shortly.
If any queries please ask me.

20 comments:

IEDig.com said...

I would like to invite you to join blogging Social Networking
IEDig.com
which helps you to get more visitors to your blogs and you get the chance
to meet other celebrity bloggers.

Join IEDig.com

少菁 said...

wonderful...................................................

志文志文 said...

thank for share, it is very important . ̄︿ ̄..................................................

函佩政松 said...

may the blessing be with you.........................................

1hose韻如ak09r_cruickshan said...

pleasure to find such a good artical! please keep update!! ........................................

FloyKnop said...

wonderful...................................................

素育如劭 said...

Better late than never. ........................................

雅俊芬凱陳許 said...

獲益不少,謝謝分享!............................................................

甄賴盈賴盈 said...

所有的資產,在不被諒解時,都成了負債..................................................................

建邱勳 said...

Judge not a book by its cover.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

王辛江淑萍康 said...

nice job! waiting for your new artical.............................................................

H S Consultants said...

This is not the first of your posts I've read, and you never cease to amaze me. Thank you, and I look forward to reading more.


Study in USA | Study in UK

H S Consultants said...

This is not the first of your posts I've read, and you never cease to amaze me. Thank you, and I look forward to reading more.


Education Consultants karachi

H S Consultants said...

It’s glad to see good information being convey. Its a very nice written, and i really like these blog. Thanks for the info.


UK Education Consultants

Boundless Technologies said...

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.



Web Design

Boundless Technologies said...

You have some interesting thoughts! Perhaps we should contemplate about attempting this myself.

Web Hosting

Black Smith said...

Valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!! Thumbs up

Ophthalmology | Surgical instruments

Black Smith said...

Valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!! Thumbs up

Ophthalmology | Surgical instruments

Beechers Josh said...

One worthwhile task carried to a successful conclusion is worth half-a-hundred
half-finished tasks.

Ground Coffee
Best Coffee
original coffee
American coffee
Retail Coffee
Coffee Aroma
special coffee
Coffee beans
Coffee wholesale
CSR activity in Coffee business

Beechers Josh said...

One worthwhile task carried to a successful conclusion is worth half-a-hundred
half-finished tasks.

Ground Coffee
Best Coffee
original coffee
American coffee
Retail Coffee
Coffee Aroma
special coffee
Coffee beans
Coffee wholesale
CSR activity in Coffee business