Project Report: Title
Project Report: Title
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.
2d=speed x time
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
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;
void main()
{
float a;
char b[7]; //string array
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);