You are on page 1of 23


Mini project Submitted in partial fulfilment of the requirements for the award of the degree of Bachelor of technology In Electrical and Electronics Engineering By
NAME Anusree Nagendran K. Neetusha Radhika Krishnan Tara Elizabeth Thomas ROLL NO B090121EE B090027EE B090229EE B090189EE

Under the guidance of Dr.JEEVAMMA JACOB

Department of Electrical and Electronics Engineering NATIONAL INSTITUTE OF TECHNOLGY,CALICUT

This is to certify that the report entitled OBSTACLE DETECTION ROBOT is a bona fide record of the mini-project done by ANUSREE NAGENDRAN (B090121EE), K. NEETUSHA (B090027EE), RADHIKA KRISHNAN (B090229EE) and TARA

ELIZABETH THOMAS (B090189EE) in partial fulfilment of the requirements for the award of Degree of Bachelor of Technology in Electrical & Electronics Engineering from National Institute of Technology Calicut for the year 2012.

Dr.Jeevamma Jacob
(Project Guide) EED

Dr. Sreeram Kumar

Professor & Head EED

Place: NIT CALICUT Date: 3.5.2012


At the very outset, we give all thanks to God almighty, who blessed us with the strength to do this project. We express our sincere gratitude to our guide, Dr.Jeevamma Jacob, Professor, Department of Electrical and Electronics Engineering, for her guidance and support throughout this endeavour. We thank Dr. Sreeram Kumar, Head of the Department, for providing all the facilities required for the project in the Department. We would like to extend our sincere thanks to Ananthakrishnan Sir, miniproject co-ordinator for giving us an opportunity to work in this project area. We also express our gratitude to Mr. Anand K.R (Lab Staff) and Mr. Somanath for their dedication and sincere interest in our work without which this project would not have been successful.

This project aims at building a basic model of an obstacle detection robot using 8051 microcontroller and infra red proximity sensors. The model uses a three wheeled differential drive configuration, with castor wheel and is powered by a DC voltage source of 12 Volts. The robot is designed so that as soon as it detects an obstacle directly in front of it, it goes in the reverse direction and then turns and proceeds along a path with no immediate obstacles. IR leds whose frequencies are modulated to 38 KHz with the help of an astable multivibrator circuit using 555 timer IC emit the IR rays, which get reflected and comes back if an obstacle is present in its path. TSOP 1738 senses these rays changes its output voltage level from high to low. This is given as an external hardware interrupt to the microcontroller, which decides the action to be taken as per the source code.

1. Introduction 2. Objective 3. System Model 3.1 AT89C51 3.1.1 General Description 3.1.2 Features 3.1.3 Pin Description of AT89C51 3.2 Infra Red Sensor Module 3.2.1 TSOP 1738 3.2.2 Astable Multivibrator Circuit for frequency modulation. 3.3 The Movement Control System 3.3.1 L293D 3.3.2 Two wheeled Differential Drive with Castor Wheel 4. Source Code 5. Circuit Diagram 6. Results 7. Future Enhancements 8. Conclusion 9. References


With the increasing importance and popularity of autonomous machines in the global scenario, robotics is a field that captures much attention and interest. This vast topic is built upon the basics of electrical, electronics and mechanical engineering. The ability of to move smoothly, avoiding the obstacle in its path is an essential need of any autonomous robot, irrespective of its specific purpose. One of the most economical ways to implement obstacle avoidance is by using IR radiations and corresponding sensors. In this mini project, we tried to develop a miniature robot that has this quality, so that this basic model can be the foundation for variety of specific purpose robots in future by incorporating additional sensors and by adding to the code of the program.

2. OBJECTIVE This project aims to design and build a basic robot, which moves in a straight line till it detects an obstacle. On detecting an obstacle in its path, using its IR proximity sensor, the robot automatically turns and finds a path without an immediate obstacle and continues its motion till the next obstacle is encountered.

3.1 AT89C51 3.1.1 General Description The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.

Figure 1: 89C51 Microcontroller 3.1.2 Features: 4K bytes of Flash 128 bytes of RAM 32 I/O lines Two 16-bit timer/counters A five vector two-level interrupt architecture 80C51 Central Processing Unit Speed up to 33 MHz Full static operation 4 level priority interrupt 6 interrupt sources Four 8-bit I/O ports Automatic address recognition Programmable clock out

Second DPTR register Asynchronous port reset Low EMI (inhibit ALE) 3 16-bit timers A full duplex serial port, on-chip oscillator and clock circuitry. Wake up from power down by an external interrupt In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes Pin Description.

Figure 2: AT89C51 Pinout

3.1.3 Pin Description Of AT89C51 Port 0: Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory . In this mode P0 has internal pullups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification.

Port 1: It is an 8-bit bi-directional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 2: It is an 8-bit bi-directional I/O port with internal pullups.The Port 2 output buffers can sink/source four TTL inputs.When 1s are written to Port 2 pins they are pulled high bythe internal pullups and can be used as inputs. As inputs,Port 2 pins that are externally being pulled low will sourcecurrent (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @DPTR). In this application, it uses strong internal pullupswhen emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits thecontents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3: It is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups.Port 3 also serves the functions of various special featuresof the AT89C51 as listed below: Port 3 also receives some control signals for Flash programming and verification. RST: A high on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. PSEN: Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP: External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. If lock bit1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions.This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP. .XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2: Output from the inverting oscillator amplifier.

3.1.4 Modes of Operation Idle Mode: In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory. Power-down Mode: In the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power - down mode is terminated. The only exit from power-down is a hardware reset.

Figure 3: Block Diagram of AT89C51


3.2 3.2.1 TSOP 1738 General Description

The TSOP17.. series are miniaturized receivers for infrared remote control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a microprocessor. TSOP17.. is the standard IR remote control receiver series, supporting all major transmission codes. TSOP 1738 responds only to IR radiations modulated at 38KHz frequency.

Figure 3.1: TSOP 1738 Features

Photo detector and preamplifier in one package Internal filter for PCM frequency Improved shielding against electrical field disturbance TTL and CMOS compatibility Output active low Low power consumption High immunity against ambient light Continuous data transmission possible (up to 2400 bps)

Figure 4: Block Diagram


3.2.2 Astable Multivibrator using 555 Timer IC

The NE555 monolithic timing circuit is a highly stable controller capable of producing accurate time delays or oscillation. For astable operation as an oscillator, the free running frequency and the duty cycle are both accurately controlled with two external resistors and one capacitor.

Figure 5: Block Diagram of 555 Timer IC

IR transmitter should be tuned to send signals of frequency of the range 38KHz. This frequency is generated by IC 555 operating in astable mode. Two such IR proximity sensors are used in the circuit in order to detect obstacles.

Figure 6: Astable Multivibrator using IC555


3.3 3.3.1 L293D

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 load 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 packaage which has 4 center pins connected together and used for heatsinking. The L293DD is assembled in a 20 lead surface mount which has 8 center pins connected together and used for heatsinking.

Figure 7: Block Diagram of L293D

3.3.2 Two Wheeled Differential Drive using Castor Wheels

In the differential drive left and right wheel are powered independently. Hence it is called as differential drive.

Zero turning radius is the most important advantage of the differential drive. In the differential drive as left and right wheel are independent if left wheel is rotated in anticlockwise and right wheel is turned clockwise robot will take turn in the left direction with zero turning radius.

Easy to move when path to be followed is contoured and zigzag in nature. If we want to move along curved path we have to control left and right motors velocity independently. Hence precision velocity control becomes difficult as actual velocity of the robot will be average of the both wheels.

Figure 8: Three Wheeled Differential Drive

Table 3.1 The pin voltages of L293D for various movements



#include<REGx51.h> #define motor_lp P2_4 #define motor_ln P2_5 #define motor_rp P2_6 #define motor_rn P2_7 #define irsensorl P3_2 #define irsensorr P3_3 void delay(unsigned int value) { unsigned int x,y,z; for(z=0;z<1200;z++) for(x=0;x<1275;x++) for(y=0;y<value;y++); }

void move_forward() { motor_lp=1; motor_ln=0; motor_rp=1; motor_rn=0; } void move_backward() { motor_lp=0;


motor_ln=1; motor_rp=0; motor_rn=1; }

void turn_left() { motor_lp=0; motor_ln=0; motor_rp=1; motor_ln=0; }

void turn_right() { motor_lp=1; motor_ln=0; motor_rp=0; motor_rn=0; } void left_obstacle() interrupt 0 { P2_0=0; move_backward(); delay(1000); turn_right(); delay(1000);

P2_0=1; } void right_obstacle() interrupt 2 { P2_1=0; move_backward(); delay(1000); turn_left(); delay(1000); P2_1=1; } void main() { motor_lp=0; motor_ln=0; motor_rp=0; motor_lp=0; EA=1; EX1=1; EX0=1; IT0=1; IT1=1; while(1) { move_forward(); } }

//setting all in output mode


Figure 9: The Circuit consisting of AT89C51 and LD293D


The infrared transmittter was the first circuit to be designed. It was designed using IC 555 timer.The resistors and capacitors connected in the timer circuit were chosen so as to generate 38khz frequency. The frequency was verified using digital CRO. Next the circuit for TSOP1738 an infrared sensor was assembled. A capacitor was connected across the ground and VCC pin to filter out any noise in the input. And the output pin was connected to CRO for verification. It was observed that as soon as infrared light of 38khz frequency fell on the TSOP1738 the output became instantaneously low. So the code to be burned in the microcontroller was written to be based on edge triggering interrupts. It was intended that the motors connected to the microcontroller through LM324 would rotate in a manner such that the robot moves forward. And on detecting an interrupt the robot would first move backward and then using differential drive would change direction. The code was successfully compiled.


As this project implements only a very basic model of obstacle detection and avoidance, many more modifications can be made to it, depending on the need. A few important possible enhancements are:

A position encoder can be used to measure the speed of the robot, and we can display this speed and direction of motion on an LCD screen. The robot can be equipped with a serial port so as to facilitate data transfer to a separate computer. By using pulse width modulation, it is possible to have a speed control for the robot. A mechanism to calibrate the approximate distance of the obstacle from the robot, by measuring the intensity of the reflected IR rays can be implemented.


The project can be used as the basic model for all autonomous systems that require obstacle avoidance.


1.The 8051 microcontroller and embedded Systems using Assembly and C, Muhammed Ali Mazidi et al. 2. 3. 4. 5. Spark 3 Manual 6. Datasheets of AT89C51, IC 555, TSOP 1738, LD293D 7. Pulse, Digital and Switching Waveforms, Jacob Millman and Herbert Taub