AVR Line Following Robot Tutorial

A D V E R T I S E M E N T

Image002 AVR Line Following Robot Tutorial

Block Diagram

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 µC.

L4L3L2L1R1R2R3R4

Left ———— Center ————- Right

Sensor Array

Starting from the center, the sensors on the left are named L1, L2, L3, L4 and those on the right are named R1, R2, R3, R4.
Let us assume that when a sensor is on the line it reads 0 and when it is off the line it reads 1

The µC decides the next move so as to position the robot such that L1 and R1 both read 0 and the rest read 1.

L4L3

L2

L1

R1

R2

R3

R4

Left ————– Center ————— Right

Desired State L1=R1=0, and Rest=1

Algorithm:

1. L= leftmost sensor which reads 0; R= rightmost sensor which reads 0.
If no sensor on Left (or Right) is 0 then L (or R) equals 0;
For example:

L4L3L2L1R1R2R3R4

Left ————– Center ————– Right

Here L=3 R=0

L4L3L2L1R1R2

R3

R4

Left ————— Center ————— Right
Here L=2 R=4

2. If all sensors read 1 go to step 3,

else,

If L>R Move Left

If L

If L=R Move Forward

Go to step 4

3. Move Clockwise if line was last seen on Right

Move Counter Clockwise if line was last seen on Left
Repeat step 3 till line is found.

4. Go to step 1.

Image007 AVR Line Following Robot Tutorial

Sensor Circuit

For a good voltage swing from the potential divider use
R1= Sqrt (Resistance of sensor when light falls on it * Resistance of sensor when light does not fall on it)

Motor Interface and Control Circuit:
Image004 AVR Line Following Robot Tutorial

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.

You may drop your feedback at priyank.patil@gmail.com

Download:
Source code: Lfsource.c
Complete Document: AVR Line Follwing Robot

Source: http://www.kmitl.ac.th/~kswichit%20/ROBOT/Robo5.html

Robotics is the branch of technology that deals with the design, construction, operation, structural disposition, manufacture and application of robots. Robotics is related to the sciences of electronics, engineering, mechanics mechatronics, and software
A D V E R T I S E M E N T

  Title :   AVR Line Following Robot Tutorial
  Category :   Electronics, Microcontroller, Programming, Robotics Tutorial, Sensors.
  Tags :   avr,  line follower,  robotics,  Robotics Tutorial,  tutorial, 
Robotics Short Story

The word robotics was derived from the word robot, which was introduced to the public by Czech writer Karel Čapek in his play R.U.R. (Rossum's Universal Robots), which premiered in 1921.

According to the Oxford English Dictionary, the word robotics was first used in print by Isaac Asimov, in his science fiction short story "Liar!", published in May 1941 in Astounding Science Fiction. Asimov was unaware that he was coining the term; since the science and technology of electrical devices is electronics, he assumed robotics already referred to the science and technology of robots. In some of Asimov's other works, he states that the first use of the word robotics was in his short story Runaround (Astounding Science Fiction, March 1942). However, the word robotics appears in "Liar!"

Posts related to AVR Line Following Robot Tutorial:


Comments

3 Responses to “AVR Line Following Robot Tutorial”
  1. yosief says:

    pls who can get me out of my trouble,i am using ATMEGA16.i am using ADC 8ch,the problem is not with the program,i am facing a probelm with the circuit connections for the atmega16,any one who can help me!i am left with 3 days

  2. nexsys says:

    Hi, I’m making this robot for my school project and I’we got a long way through it.
    Now I have trouble with the hex file for my ATmega16 chip.To be exact a problem is with building the hex file with Avr studio 4, I get errors and I don’t know how to fix it.So If anyone can help me with this by giving me a link to download the hex (and EEPROM file’s if there are any) I will appreciate it.
    Thank’s anyway. Cheers

  3. jimit shah says:

    simple,put single coma in if brackets..like if(‘PINA.2==0′)
    i am sure..this will run..thnks
    jimit shah


Do you have any comments on AVR Line Following Robot Tutorial ?