0% found this document useful (0 votes)
20 views9 pages

Project Report: Title

The project aims to automatically control a robot using an ultrasonic sensor. The ultrasonic sensor measures the distance to obstacles and sends the information to a PIC18F452 microcontroller. The microcontroller controls two DC motors to brake or change the robot's direction when an obstacle is detected within 15cm. It uses an ultrasonic rangefinder sensor, microcontroller, motor driver, motors, and power supplies. When power is turned on, the motors move the robot forward while the sensor continuously measures distances. If an obstacle is near, one motor reverses to turn the robot away.

Uploaded by

jboluwade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views9 pages

Project Report: Title

The project aims to automatically control a robot using an ultrasonic sensor. The ultrasonic sensor measures the distance to obstacles and sends the information to a PIC18F452 microcontroller. The microcontroller controls two DC motors to brake or change the robot's direction when an obstacle is detected within 15cm. It uses an ultrasonic rangefinder sensor, microcontroller, motor driver, motors, and power supplies. When power is turned on, the motors move the robot forward while the sensor continuously measures distances. If an obstacle is near, one motor reverses to turn the robot away.

Uploaded by

jboluwade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

PROJECT REPORT

MICRO CONTROLLER II

TITLE:
Automatic robot control using ultrasonic sensor

GROUP MEMBER:
Ghulam Mustafa 140406
Syed Amjed Ali 140166
Uzair ul haq 140998
Section BEE-VI(A)
Automatic robot control using ultrasonic sensor
Introduction:
There are many method to control a robot but we use ultrasonic sensor
to control robot when a obstacle come in path of robot. Ultrasonic sensor includes
two waves, emitter and receiver wave. The ultrasonic wave emitter provided in
front portion of an automatic braking robot, producing and emitting ultrasonic
waves in a predetermined distance in front of the robot. Ultrasonic wave receiver is
also provided in front portion of the robot, receiving the reflected ultrasonic wave
signal from the obstacle. The reflected wave (detection pulse) is measured to get
the distance between robot and the obstacle. Then PIC18f452 microcontroller is
used to control the dc motors based on detection pulse information and the dc
motors in turn automatically controls the braking of the robot and change direction
when obstacle find.
Require components:
 Pic 18f452
 Robot base
 Motor driver IC-L293D
 Ultrasonic range finder sensor-HC-SR04
 Power supplies
 DC motors
 LCD

Block diagram:
Working Principle:
The automatic control robot uses ultrasonic sensors for its movements. A
microcontroller PIC18F452 is used to achieve the desired operation. The motors are
connected through motor driver IC to microcontroller. The ultrasonic sensor is attached
in front of the robot.
Whenever the robot is going on the desired path the ultrasonic sensor
transmits the ultrasonic waves continuously from its sensor head. Whenever an
obstacle comes ahead of it the ultrasonic waves are reflected back from an object and
that information is passed to the microcontroller. The microcontroller controls the motors
based on ultrasonic signals.
Ultrasonic range finder sensor-HC-SR04
The ultrasonic sensor is used for obstacle detection. Ultrasonic
sensor transmits the ultrasonic waves from its sensor head and again receives the
ultrasonic waves reflected from an object. The Working of HC-SR04 is that it uses an
external trigger signal, the Trig pin on ultrasonic sensor is made high for at least 10us.A
sonic burst from transmitter module is sent . This consist of 8 pulse of 40kHz. The
signals return back after hitting a material and receiver detects this signal. The Echo
pin is high from the time of sending signal and receiving it. This time can be converted
to distance using mathematical calculation.

When robot I power on both motors of robot will run normally and robot move forward.
During the time the ultrasonic sensor continuously calculate distance between robot
and material.
Distance Calculation:
Fosc is the oscillator frequency, here we are using 10MHz
crystal Fosc= 10MHz.

Time = (TMR1H:TMR1L)*(1/Internal Clock)*Prescaler

Internal Clock = Fosc/4 = 10MHz/4 = 2.5MHz

Time = (TMR1H:TMR1L)*2/(2.5MHz) = (TMR1H:TMR1L)/1250000


Distance = Speed * Time

Let d be the distance between Ultrasonic Sensor and Target

Total distance traveled by the ultrasonic burst : 2d (Tran and rec)

2d=speed x time

Speed of Sound in Air : 340 m/s = 34000 cm/s

2d=34000cm/s x time

d = (34000*Time)/2,

Time = (TMR1H:TMR1L)/(1250000)

d= 34000cm/s/2 x TMR1H:TMR1L/1250000

d= (TMR1H:TMR1L)/73.529cm

TMR1H:TMR1L = TMR1L | (TMR1H<<8)

L293D:
It is a motor driver which can provide bi-directional drive current for two
motors.
The 16th pin of L293D is Vcc1. This is connected to 5V Vcc.
The 8th pins is Vcc2. This is the motor supply voltage. This can be connected anywhere
between 4.7V and 36V.

Circuit diagram:
Programing:
Basic steps:
1. Initialize the inputs and outputs
2. Initialize the timer1 T1CON ,TMR1H and TMR1L values
3. Provide TRIGGER to ultrasonic module
4. Listen for Echo
5. Start timer when ECHO high is received
6. Stop timer when ECHO goes low
7. Read timer value
8. Convert it into distance
9. Display it on LCD
10. If distance is more then 15cm both motor move forwards
11. If distance is less then 15cm one motor reversed and one forwards

Project code:
// LCD module connections
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISD2_bit;


sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit; // End LCD module connections

void main()
{
float a;
char b[7]; //string array
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

TRISB = 0b00010000; //RB4 as Input PIN (ECHO)


TRISC.TRISC0=0; //as outputs
TRISC.TRISC1=0;
TRISC.TRISC2=0;
TRISC.TRISC3=0;
Lcd_Out(1,1,"welcome");
Lcd_Out(2,1,"project");

Delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);

T1CON = 0x10; //Initialize Timer Module


while(1)
{
TMR1H = 0; //Sets the Initial Value of Timer
TMR1L = 0; //Sets the Initial Value of Timer

PORTB.F0 = 1; //TRIGGER HIGH


Delay_us(10); //10uS Delay
PORTB.F0 = 0; //TRIGGER LOW

while(PORTB.F4==0); //Waiting for Echo


T1CON.F0 = 1; //Timer Starts
while(PORTB.F4==1); //Waiting for Echo goes LOW
T1CON.F0 = 0; //Timer Stops

a = (TMR1L | (TMR1H<<8)); //Reads Timer Value


a = a/73.529; //Converts Time to Distance
a = a + 1; //Distance Calibration
if(a>=2 && a<=400) //Check whether the result is valid or not
{
FloatToStr(a,b); // Float to string display
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Distance = "); // first row first column display distance
Lcd_Out(1,12,b); // at 12 column display value of distance
Lcd_Out(1,15,"cm"); // display cm
if(a<=15) // check if less then 15cm
{
PORTC.F0= 0; // reverse motor 1
PORTC.F1= 1;
PORTC.F2= 1; // forward motor 2
PORTC.F3= 0;
Delay_ms(400);
}
else
{
PORTC.F0= 1; // forward motor 1
PORTC.F1= 0;
PORTC.F2= 1; // forward motor 2
PORTC.F3= 0; }
}
else
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Out of Range"); // if range is greater then 400cm then display out of range
}
Delay_ms(400);
}
}

You might also like