You are on page 1of 17

MICRO-CONTROLLER BASED INTELLIGENT OBSTACLE AVOIDER ROBOT AND DISPLAY OF BLINKING LEDS AND BUZZER

Class Project Report


Subject: Advanced Microcontroller and microprocessor systems

Submitted To:

Dr. Veena Sharma, EED NIT-H


Submitted By: Mirza Abdul Waris Beigh, Roll No: 10289

Department of Electrical Engineering National Institute Of Technology, Hamirpur

CONTENTS: Introduction Basic Principle Logic Followed Block Diagram Components used 89V51RD2 Kit by Provotech IR Sensors 3 USB-Serial Programmer By SILABS 2 line LCD Display. Program Code Used

A view of the Robot

Introduction:
The design and implementation of obstacle avoider robot using 8051 Microcontroller is being done. It is programmed to avoid running into obstacles and detects the presence of different objects around it and modifies the motion of the motors appropriately. The objects are sensed by the IR (Infra Red) sensors. The microcontroller controls two DC motors of robot to navigate.

Basic Principle:
The basic principle involved in this is it captures the obstacle presence with IR sensors mounted at the three sides of the robot. When the sensor senses an object, analog signal is given to the op-amp to produce 0s and 1s which are then fed to the microcontroller, then the microcontroller decides the next move according to the program. Microcontroller and driver circuit are used for the control of motors.

SENSOR B

SENSOR A

SENSOR C

Logic Followed:
Sensor A 0 0 0 0 1 1 1 1 Sensor B 0 0 1 1 0 0 1 1 Sensor C 0 1 0 1 0 1 0 1 Action FORWARD LEFT RIGHT_DIFF LEFT_DIFF RIGHT FORWARD RIGHT_DIFF BACK

Kit Used:

Mechanical parts:
Chassis Castor Wheel L-Clamp Motor Wheel

Input and Output devices


Battery Source Sensor Driver IC Microcontroller unit USB-Serial programmer

Source:
An ideal voltage source is a voltage source that maintains the same voltage across the source's terminals no matter what current is drawn from the terminals of the source or what current flows into the terminals.

DC source:
Direct current (DC) is the unidirectional flow of electric charge. Direct current is produced by sources such as batteries, solar cells, and commutator-type electric machines of the dynamo type, etc.

Sensor
IR reflective sensors have one emitter (IR LED) and one receiver (Phototransistor or photo diode. If we have white surface it reflects the light and it will sensed by the receiver, similarly if we have black surface it absorbs the light and receiver can not sense light. Photo diode has property that if IR light fall on it its electrical resistance comes down (i.e. it comes down from 150k to 10k if no noise present).

Sample Calculation:
Say Receiver has resistance Rs=150k without light (on black surface) Rs=10k with light (on white surface) The voltage that goes to comparator Without light: (on black surface) Vp=(Rs(Rs+R))Vcc=150(150+10))*5=4.6875V With light: (on white surface) Vp=(Rs(Rs+R))Vcc=10(10+10))*5=2.5000V Thus we get variation of voltage that is sensed by comparator IC (LM324). This gives logical high or low according to input.

Comparator
Comparator is a device which compares two input voltages and gives output high/low. In circuit diagram it is normally represented by a triangle having- Inverting (negative) Input (-),Non Inverting (positive) Input(+), Vcc, Ground, Output.

Use of comparator in IR sensor

As above we see that two inputs are required for comparator. One input is from photo-receiver (like photo-diode), other is generated by us using potentiometer. The second voltage is also called as reference voltage for that sensor.

LM358
The LM358 is a great, easy-to-use dual-channel opamp. LM358 applications include transducer amplifiers, DC gain blocks and all the conventional opamp circuits.

Driver IC:
L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors. L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation, two DC motors can be driven simultaneously, both in forward and reverse direction. The motor operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and anticlockwise directions, respectively. Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start operating. When an enable input is high, the associated driver gets enabled. Similarly, when the enable input is low, that driver is disabled, and their outputs are off and in the high-impedance state.

Microcontroller:
Microcontroller acts as the Brain of robot, which generates desired output for corresponding inputs. In present days, there are several companies that manufacture microcontrollers, for example ATMEL, Microchip, Intel, Motorola, Philips etc. We are using P89V51RD2 microcontroller in our robot. It is a PHILIPS product. The NXP (founded by Philips) P89V51RD2 DIP is a 40MHz, 5 Volt 8051-based Microcontroller with 32 I/O lines is an extremely popular 8051 family of microcontroller available in standard 40-pin DIP package. The microcontroller comes with an on-chip boot loader which makes it easy to program using the USB-serial Programmer.

LCD Display:
LCD display is used to display different strings while program is running and information regarding buttons to be pressed.

Decription Of Micro-controller board used

Keil uvision:
Keil C51 is the industry-standard tool chain for all 8051-compatible devices, it supports classic 8051, Dallas 390, NXP MX, extended 8051 variants, and C251 devices. The Vision IDE/Debugger integrates complete device simulation, interfaces too many target debug adapters, and provides various monitor debug solutions.

Usb-Serial Programmer:
The programmer used is designed by SILABS and is very easy to use. We just need to connect the USB cable to a PC and using Flash Magic we can easily burn the program into the micro controller.

C Program Written:
#include<stdio.h> #include<reg51.h> #include"LCD.h"

sbit p1=P2^0; sbit p2=P2^1; sbit p3=P2^2; sbit sbit sbit sbit LED1=P3^0; LED2=P3^1; LED3=P3^4; LED4=P3^5; //LED DEFINITIONS

sbit SW1=P3^2; sbit SW2=P3^3; sbit SW3=P3^6; sbit SW4=P3^7; sbit BUZZER=P0^7;

//SWITCH DEFINITIONS //SWITCHES ARE ACTIVE LOW (WHEN PRESSED GIVE LOGIC LOW AT PIN)

// MOTOR PORT = PORT1 #define FORWARD 0x55 #define BACK 0XAA #define LEFT 0x44 #define RIGHT 0x11 #define LEFT_DIFF 0x66 #define RIGHT_DIFF 0x99 #define STOP 0x00

void dot(void) { BUZZER=0; // delay_ms(100); BUZZER=1;

TURN ON THE BUZZER //WAIT //TURN OFF THE BUZZER

delay_ms(100); } void dash(void) { BUZZER=0; delay_ms(300); BUZZER=1; delay_ms(90); }

//WAIT

void main(void) { unsigned char sqnc; P2=0xFF; //INTIALISE PORT 2 AS INPUT PORT FOR Sensors P1=0x00; //INTIALISE PORT 1 AS OUTPUT PORT FOR MOTOR LCD_INIT(); delay_ms(100); LCD_CMD(0X01); LCD_STRING("Welcome"); delay_ms(2000); LCD_CMD(0x80); LCD_STRING("SW1 SW2 SW3"); LCD_CMD(0xC0); LCD_STRING("LED BUZ Wall-Avoid");

while(1) { if (SW1==0) //IF SWITCH1 IS PRESSED EXECUTE RUNNING LED PROGRAM { LCD_CMD(0x01); LCD_CMD(0x80); LCD_STRING("Running LED Disp"); while(1) { for(sqnc=0;sqnc<=5;sqnc++) { LED1=0;LED2=1;LED3=1;LED4=1; delay_ms(100); LED1=1;LED2=0;LED3=1;LED4=1;

delay_ms(100); LED1=1;LED2=1;LED3=0;LED4=1; delay_ms(100); LED1=1;LED2=1;LED3=1;LED4=0; delay_ms(100); } for(sqnc=0;sqnc<=5;sqnc++) { LED1=1;LED2=1;LED3=1;LED4=0; delay_ms(100); LED1=1;LED2=1;LED3=0;LED4=1; delay_ms(100); LED1=1;LED2=0;LED3=1;LED4=1; delay_ms(100); LED1=0;LED2=1;LED3=1;LED4=1; delay_ms(100); } for(sqnc=0;sqnc<=5;sqnc++) { LED1=1;LED2=0;LED3=0;LED4=1; delay_ms(100); LED1=0;LED2=1;LED3=1;LED4=0; delay_ms(100); LED1=0;LED2=1;LED3=1;LED4=0; delay_ms(100); LED1=1;LED2=0;LED3=0;LED4=1; delay_ms(100); }

for(sqnc=0;sqnc<=5;sqnc++) { LED1=0;LED2=0;LED3=0;LED4=0; delay_ms(100); LED1=1;LED2=1;LED3=1;LED4=1; delay_ms(100); LED1=0;LED2=0;LED3=0;LED4=0; delay_ms(100); LED1=1;LED2=1;LED3=1;LED4=1; delay_ms(100); } for(sqnc=0;sqnc<=3;sqnc++)

{ LED1=0;LED2=1;LED3=1;LED4=1; delay_ms(200); LED1=0;LED2=0;LED3=1;LED4=1; delay_ms(200); LED1=0;LED2=0;LED3=0;LED4=1; delay_ms(200); LED1=0;LED2=0;LED3=0;LED4=0; delay_ms(200); LED1=1;LED2=1;LED3=1;LED4=1; delay_ms(200); } for(sqnc=0;sqnc<=3;sqnc++) { LED1=1;LED2=1;LED3=1;LED4=0; delay_ms(200); LED1=1;LED2=1;LED3=0;LED4=0; delay_ms(200); LED1=1;LED2=0;LED3=0;LED4=0; delay_ms(200); LED1=0;LED2=0;LED3=0;LED4=0; delay_ms(200); LED1=1;LED2=1;LED3=1;LED4=1; delay_ms(200); } } }

if (SW2==0) PROGRAM {

//IF SWITCH2 IS PRESSED EXECUTE BUZZER

LCD_CMD(0x01); LCD_CMD(0x80); LCD_STRING("Buzzer"); while(1) { dot();dot();dot();dash();dash();dot();dot();dot();delay_ms(1 000);delay_ms(1000); //MORSE CODE SEQUENCE } }

if (SW3==0) //IF SWITCH3 IS PRESSED TEXECUTE MOTOR PROGRAM { LCD_CMD(0x01); LCD_CMD(0x80); LCD_STRING("Wall Avoider"); while(1) { here: { P1=FORWARD; goto here0; } here0: { P1=RIGHT; goto here1; } here1: if (p1==0 && p2==1 && p3==0) { P1= LEFT_DIFF; goto here2; } here2: if (p1==0 && p2==1 && p3==1) { P1= RIGHT_DIFF; goto here3; } here3: if (p1==1 && p2==0 && p3==0) { P1= LEFT; goto here4; } here4: { if (p1==1 && p2==0 && p3==1) if (p1==0 && p2==0 && p3==1) if (p1==0 && p2==0 && p3==0)

P1= FORWARD; goto here5; } here5: if (p1==1 && p2==1 && p3==0) { P1= LEFT_DIFF; goto here6; } here6: if (p1==1 && p2==1 && p3==1) { P1= BACK; goto here; } }

} } }

You might also like