“Obstacle Avoiding Robot”
Submitted in fulfillment of PROJECT required for the
Bachelor of Engineering (B.E)
Sachin Narang(ue6858),Shikhar Misra(ue6878)
IT 8th Semester
Under the Supervision
Ms. Inderdeep Aulakh
Associate Professor, UIET
Obstacle Avoidance Robot Page 1
In any project that calls for study of particular aspects in any field or subject,
one needs support from number of persons who directly or indirectly
contribute by way of discussion, interaction and response. It is not possible to
thank all those who have helped in this project, but we must express heartily
gratitude to few of them.
We would like to thank Mrs. INDERDEEP AULAKH who earmarked us her
precious time and guidance without which this would have been an extremely
Last but not least I express my gratitude to our Institution for all kind of
opportunities help and support.
Obstacle Avoidance Robot Page 3
We hereby declare that the work which is being presented in this
report on ‘Obstacle Avoiding Robot’ submitted at U.I.E.T., Panjab
University is an authentic work presented by Mr. Sachin Narang
(UE6858) and Shikhar Misra (UE6878) of B.E. (I.T.) 8th semester
under the supervision of Ms. Inderdeep Aulakh.
Shikhar Misra (UE6878)
Obstacle Avoidance Robot Page 4
This is to certify that Mr. Sachin Narang(UE6858) and Mr. Shikhar
Misra(UE6878) B.E. (I.T.) 8th Semester have completed Major
Project , in accordance with the requirement for qualifying 8th
semester, on Obstacle Avoiding Robot under the guidance of Ms.
Obstacle Avoidance Robot Page 5
We have undertaken a project of making a microcontroller based electronic
equipment that is able to detect the distance of an object placed in its line of
sight (i.e. within its range of perception). It uses Infrared Rays to detect the
obstacle, in which an infrared wave is sent and the reflected wave from the
object is received and on the basis of infrared sensor which senses the
reflected infrared ray the presence of obstacle is verified.
After the verification of the object our equipment changes its path according to
the programming of microcontroller.
Obstacle Avoidance Robot Page 6
1. Project Description
Obstacle Avoidance Robot using 8051 is built using infrared sensor
module. The Right module and the left module are used to detect the obstacle
on the right and the left side of the device respectively. The Right and left
module are connected at approximately 45 degree to the board so as to
detect the obstacle on either side.
Very often obstacles avoidance tasks rely on infrared sensors where the
measuring data of the sensors are first used to gain a local representation of
the environment in order to afterwards control the robot accordingly. IR
sensors are simple, commonly employed, and relatively low-cost sensing
modalities to perform the obstacle avoidance task. Sometimes, IR sensors
may be preferable to ultrasonic sensors due to their faster response time,
narrower beam width, and lower cost. The intensity of the light detected
depends on several parameters including the surface reflectance properties,
the distance to the surface, and the relative orientation of the emitter, the
detector, and the surface. These devices are inexpensive, practical, and
widely available; their use has been mostly limited to detect the presence or
absence of objects in the environment (proximity detection) for applications
such as obstacle avoidance or counting.
1.2 MAJOR COMPONENTS USED
• Philips 89V51RD2 Microcontroller with 64kB flash memory working at
• Regulated power supply: 7-15V
• Power indicator LED.
• 2 DC motors
• Separate ON/OFF switches for power.
• UART communication circuit.
• 2 Infrared sensors.
Obstacle Avoidance Robot Page 7
2. Component Description Details
2.1 P89V51RD2(Philips) Features
The P89V51RB2/RC2/RD2 is 80C51 microcontrollers with 16/32/64 kB
Flash and1024 bytes of data RAM.
A key feature of the P89V51RB2/RC2/RD2 is its X2 mode option. The
design engineer can choose to run the application with the
conventional 80C51 clock rate (12 clocks per machine cycle) or select
the X2 mode (6 clocks per machine cycle) to achieve twice the
throughput at the same clock frequency. Another way to benefit from
this feature is to keep the same performance by reducing the clock
frequency by half, thus dramatically reducing the EMI.
The Flash program memory supports both parallel programming and in
serial In-System Programming (ISP). Parallel programming mode
offers gang-programming at high speed, reducing programming costs
and time to market. ISP allows a device to be reprogrammed in the end
product under software control. The capability to field/update the
application firmware makes a wide range of applications possible.
The P89V51RB2/RC2/RD2 is also In-Application Programmable (IAP),
allowing the Flash program memory to be reconfigured even while the
application is running.
1. 80C51 Central Processing Unit.
2. 5 V Operating voltage from 0 MHz to 40 MHz
3. 16/32/64 kB of on-chip Flash user code memory with ISP (In-
Programming) and IAP (In-Application Programming).
4. Supports 12-clock (default) or 6-clock mode selection via software
5. PCA (Programmable Counter Array) with PWM and
6. Four 8-bit I/O ports with three high-current Port 1 pins (16 mA
7. Three 16-bit timers/counters.
8. Eight interrupt sources with four priority levels
Obstacle Avoidance Robot Page 8
POWER-ON RESET CIRCUIT
When power is applied to the device, the RST pin must be held high
long enough for the oscillator to start up (usually several milliseconds
for a low frequency crystal), in addition to two machine cycles for a
valid power-on reset.
An example of a method to extend the RST signal is to implement a
RC circuit by connecting the RST pin to VDD through a 10 F capacitor
and to VSS through an 8.2KW resistor as shown in FIGURE Note that
if an RC circuit is being used, provisions should be made to ensure the
VDD rise time does not exceed 1 millisecond and the oscillator start-up
time does not exceed 10 milliseconds.
Obstacle Avoidance Robot Page 10
2.3 INFRARED SENSOR
TSOP based obstacle detector / proximity sensing module
• Typical Maximum Range :10cm
• Modulated IR transmitter
• Ambient light protected IR receiver
• Calibration preset for range adjustment
• 3 pin easy interface connectors
• Bus powered module
• Indicator LED
Obstacle Avoidance Robot Page 11
LM7805: 3-TERMINAL 1A POSITIVE VOLTAGE REGULATORS
The LM7805 is a three-terminal positive regulator available in the TO-220/D-
PAK package. It is useful in a wide range of applications. Each type employs
internal current limiting, thermal shut-down and safe area protection, making it
essentially indestructible. If adequate heat sinking is provided, it can deliver
over 1A output current. Although designed primarily as fixed voltage
Regulators, these devices can be used with external components to obtain
adjustable voltages and currents.
2.5 MOTOR DRIVER IC L293D
Obstacle Avoidance Robot Page 13
The Device is a monolithic integrated high voltage, high current four channel
driver designed to accept standard DTL or TTL logic levels and drive inductive
loads (such as relays solenoids, DC and stepping motors) and switching
power transistors. To simplify use as two bridges each pair of channels is
equipped with an enable input. A separate supply input is provided for the
logic, allowing operation at a lower voltage and internal clamp diodes are
included. This device is suitable for use in switching applications at
frequencies up to 5 kHz. The L293D is assembled in a 16 lead plastic
package which has 4 center pins connected together and used for heat
The motor supply voltage can go up to 24Volts safely. But the IC supports a
maximum of only 600mA current/channel; which is more than enough to drive
small DC geared motors. We use 0.22uF capacitors across both the motors to
reduce the effect of noise on the circuitry. It is also recommended to add
100uF capacitor between the motor supply pin and the Gnd. Connections M1-
A and M2-B correspond to Motor 1 while connections M2-A and M2-B
correspond to Motor 2.
MOTOR DRIVER INTERFACING WITH MICROCONTROLLER
Obstacle Avoidance Robot Page 14
CONTROLLING DC MOTOR USING IC LD293D
Controlling a DC motor is nothing but controlling the direction and speed of a
motor. It is very necessary to go through motor controlling concept, if you are
designing an autonomous robot.
How DC Motor works ???
Let’s start with how actually DC motor runs. Direction control of a DC motor is
very simple, just reverse the polarity, means every DC motor has two
terminals out. When we apply DC voltage with proper current to a motor, it
rotates in a particular direction but when we reverse the connection of voltage
between two terminals, motor rotates in another direction.
Obstacle Avoidance Robot Page 15
Now let us consider how to control motor using Microcontroller provided:
1. Microcontroller provides us only digital logic (1 or a 0).
2. We can’t provide polarity from microcontroller.
3. We can’t connect motors to Controller as mostly motors runs on voltage
higher that +5V, and motors demands high current (depends).
Now the solution to above limitations is use of an “H Bridge”.
It is a circuit which allows motor rotation in both directions. From four
terminals of H Bridge you can control a DC motor.
It is a circuit which allows motor rotation in both directions. From four terminals of H
Bridge you can control a DC motor.
Motors can be driven in clockwise direction or anti-clockwise direction according to
our requirements. To do so we first need to connect motors and find out the
commands we need to give to our microcontroller to perform the specific rotation.
3. Circuit Basic Block Diagram & Circuit Diagram
Obstacle Avoidance Robot Page 16
4. Software Used
A) TRIC: FOR PROGRAMMING MICROCONTROLLER USING C.
B) FLASH MAGIC: FOR BURNING PROGRAM.
Obstacle Avoidance Robot Page 17
Library files used:
1 DC MOTORS:
A. RUNMOTOR(motor number, direction, speed)
This is the prototype of function RUNMOTOR used to move
the motor in a specified direction, with desired speed. Once you make
a call to this function it keeps running the motor unless you call
another function STOPMOTOR discussed next.
• motor_num:-As we know that to the iBOT we can connect four dc
motors at a time, the first thing we need to mention is the motor which
we want to know the motor_num accepts the values to specify the
motor number to be moved which are motor1 (PORT P2_0 and
P2_1), motor2 (PORT P2_2 and P2_3), motor3 (PORT P2_4 and
P2_5), and motor4 (PORT P2_6 and P2_7). Any other values apart
from this will not give the desired results.
• Direction:-Next is the direction in which we want to rotate the motor
either clockwise or anticlockwise, note this direction is with respect to
the shaft of the motor while looking into the shaft. Thus if you want to
rotate the motor clockwise for a while you have to input the direction
as cw and ccw, if in case you want it to rotate in anticlockwise
A point to ponder is that when you rotate a wheel clockwise it
tries to move the vehicle forward whereas the other side-wheel will
tend to move the vehicle backward and as such the vehicle will
revolve around at its position. Thus you have to run the other motor in
anticlockwise direction, so that the vehicle moves forward as such.
This seems a bit confusing is it? And also a tedious thing to do. Hence
to make things simpler what you can do is that connect the motors
one side of vehicle in reverse order the way you connect the other.
Thus clockwise may be the direction to move the vehicle forward and
anticlockwise to both to move the vehicle back.
• Speed: - Generally, the rotational speed of a DC motor is proportional
to the voltage applied to it. So the parameter is percentage of the
maximum speed with which the motor can be rotated. Thus the speed
value varies from 0 to 100.
B. STOPMOTOR (motor_num)
This is the prototype of the function called STOPMOTOR used
to stop the respective motor passed as parameter to this
function. There is one and only parameter motor_num which
mention the motor number to be stopped.
Obstacle Avoidance Robot Page 18
DELAY (unsigned int time)
This function is used to generate the real time delay in
milliseconds it has only one parameter time which accepts the integer values
in the range of 0 to 65535 thus it can generate a time delay of 0 milliseconds
to 65535 milliseconds. If the user has a need of higher delays then he has to
call the function DELAY multiple times to meet his requirements.
void main ()
In the above program the function DELAY (100) generates a delay of 100
milliseconds and thus toggles the pin1 of port 3 every 100 milliseconds infact
in other ways it generates a square wave of 20 Hz frequency.
Obstacle Avoidance Robot Page 19
4.2 FLASH MAGIC
Flash Magic is Windows software from the Embedded Systems Academy that
Access to all the ISP features provided by the devices. These features
• Erasing the Flash memory (individual blocks or the whole device)
• Programming the Flash memory
• Modifying the Boot Vector and Status Byte
• Reading Flash memory
The window is divided up into five sections. Work your way from section 1 to
section 5 to program a device using the most common functions. Each section
is described in detail in the following sections.
At the very bottom left of the window is an area where progress messages will
be displayed and at the very bottom right is where the progress bar is
displayed. In between the messages and the progress bar is a count of the
number of times the currently selected hex file has been programmed since it
was last modified or selected.
Obstacle Avoidance Robot Page 20
5. Algorithms for Coding
If Obstacle not Present on either side (RS=FS=LS=0)
Else if Obstacle Present in Front but not on either side (FS=1, RS=LS=0)
Turn 45O left
Else if Obstacle Present on Right but not on front and left side (FS=0, RS=1,
Turn 45O left
Else if Obstacle Present in Left but not on front and right side (FS=0, RS=0,
Turn 45O right
Else if Obstacle Present in Front and Right side but not on left side (FS=1,
Turn 90O left
Else if Obstacle Present in Front and Left side but not on right side (FS=1,
Turn 90O right
Else if Obstacle Present in Front and Left side but not on right side (FS=1,
Turn 135O left
Obstacle Avoidance Robot Page 21
Left Sensor Right Sensor Action
1 0 45o turn right
0 1 45o turn left
1 1 90o turn left
0 0 Move forward
#define fwd 0x05
#define right 0x04
#define left 0x01
if(P1_0==0 && P1_1==0)
if(P1_0==1 && P1_1==0)
Obstacle Avoidance Robot Page 22
TOTAL COST 2700
As during driving there is a chance of human error which may lead to
accidents. Keeping this in mind automatic systems are employed to avoid
human errors and for ease of work.
Hence, we conclude that use of sensors & microcontroller in our project
proves to be very helpful as these can provide better and faster results.
Innovativeness and Usefulness
1. The project promises immense benefit in engineering and design of
more efficient automated control for vehicles.
2. Improved safety and better control for vehicle and robotic automation.
Obstacle Avoidance Robot Page 25
1. www.avrfreaks.net : A website with resources for AVR
2. www.PHILLIPS.com: The official website of PHILLIPS Corp.
3. www.avagotech.com: The official website Avago Technologies
4. www.vishay.com: The official website of vishay Corp.
5. www.national.com: The official website of National Semiconductors
6. www.roboticsindia.com: For Indian Robotics and electronics
7. www.wikipedia.com: A website for free encyclopedia
8. www.winavr.sourceforge.net : The official website of WinAVR
9. www.datasheetsforyou.com: Website for datasheets
Obstacle Avoidance Robot Page 26