left motor right motor forward forward stop · pdf file5.3 obstacle avoiding robocar: obstacle...

7
Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846 Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 1 International Islamic University Chittagong (IIUC) Department of Electrical and Electronic Engineering (EEE) Course Code: EEE 4846 Course Title: Embedded System Sessional EXPERIMENT NO. 5 Name of the Experiment: Line follower robocar and obstacle avoiding robocar 5.1 Objective: The objective of this experiment is to design a robocar which can run following a line and another robocar which can run avoiding obstacle in front of it. 5.2 Required Component: 1. Microcontroller: PIC16F887 2. IR sensor module. 3. Motor driver module. 4. RoboCar 5. Ultrasonic sensor 6. Connecting wire. 7. Black track in white surface. 5.2 Line Follower RoboCar: A line follower robocar can identify particular line in a surface and can run following the line. 5.2.1 Controlling movements of robocar by two DC motors: Front Right Motor Left Motor Robot Base Forward Forward Robot Moves Forward Fig 5.1(a): Robocar moves forward direction Front Right Motor Left Motor Robot Base Forward Stop Robot turns right Fig 5.1(b): Robocar turns towards right

Upload: leduong

Post on 22-Mar-2018

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 1

International Islamic University Chittagong (IIUC)

Department of Electrical and Electronic Engineering (EEE)

Course Code: EEE 4846 Course Title: Embedded System Sessional

EXPERIMENT NO. 5

Name of the Experiment: Line follower robocar and obstacle avoiding robocar

5.1 Objective: The objective of this experiment is to design a robocar which can run following a

line and another robocar which can run avoiding obstacle in front of it.

5.2 Required Component:

1. Microcontroller: PIC16F887

2. IR sensor module.

3. Motor driver module.

4. RoboCar

5. Ultrasonic sensor

6. Connecting wire.

7. Black track in white surface.

5.2 Line Follower RoboCar: A line follower robocar can identify particular line in a surface

and can run following the line.

5.2.1 Controlling movements of robocar by two DC motors:

Front

Right MotorLeft Motor

Robot Base

Forward Forward

Robot Moves Forward

Fig 5.1(a): Robocar moves forward direction

Front

Right MotorLeft Motor

Robot Base

Forward Stop

Robot turns right

Fig 5.1(b): Robocar turns towards right

Page 2: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 2

Front

Right MotorLeft Motor

Robot Base

Robot turns left

ForwardStop

Fig 5.1(c): Robocar turns towards left

Front

Right MotorLeft Motor

Robot Base

Robot stops moving

Stop Stop

Fig 5.1(d): Robocar stops moving

Front

Right MotorLeft Motor

Robot Base

Robot moves backward direction

Reverse Reverse

Fig 5.1(e): Robocar moves backward

direction

Front

Right MotorLeft Motor

Robot Base

Quick turn to left

ForwardReverse

Fig 5.1(f): Quick turn to left

Page 3: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 3

Front

Right MotorLeft Motor

Robot Base

Reverse

Quick turn to right

Forward

Fig 5.1(g): Quick turn to right

5.2.2 Sensing the track by IR

1 KΩ

10 KΩ

1.8 KΩ

IC 741+

-

5 V

1 KΩ

2.2

IR-T

x

470 Ω

5 V

IR-R

x

IR Reflects in white surface

To

microcontroller

I/O

HIGH

Fig 5.2(a) : Sensors are in white surface

Page 4: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 4

1 KΩ

10 KΩ

1.8 KΩ

IC 741+

-

5 V

1 KΩ

2.2

IR-T

x

470 Ω

5 V

IR-R

x

IR absorbs (don’t reflect) in black surface

To

microcontroller

I/O

LOW

Fig 5.2(b) : Sensors are in black surface

5.2.3 Tracking Algorithm (Principle of line tracking):

Fig. 5.3 (a) : Tracking algorithm of line follower robocar

Page 5: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 5

Start

Left_Sensor==LOW and

right_sensor==LOW

Read left_sensor

and right_sensor

Rotate both

motor in

forward

YES

A

Left_Sensor==LOW and

right_sensor==HIGH

Stop left motor

and rotate right

motor in forward

A

YES

NO

Left_Sensor==HIGH and

right_sensor==LOW

Stop right motor

and rotate left

motor in forward

A

YES

NO

Stop both motors

NO

A

END

Fig. 5.3 (b): Tracking algorithm of line follower robocar

5.2.4 Circuit Diagram:

Fig. 5.3: Circuit diagram of line follower robocar

Page 6: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 6

5.2.5 Program:

bit left_sensor;

bit right_sensor;

void main()

ANSEL=0;

ANSELH=0;

TRISB=0x03;

PORTB=0x00;

while(1)

left_sensor=PORTB.F0;

right_sensor=PORTB.F1;

if(left_sensor==1 && right_sensor==1)

PORTB.F1=1; //right motor forward

PORTB.F2=0;

PORTB.F3=1; //left motor forward

PORTB.F4=0;

else if(left_sensor==0 && right_sensor==1)

PORTB.F1=0;

PORTB.F2=0;

PORTB.F3=1; // turn right

PORTB.F4=0;

else if(left_sensor==1 && right_sensor==0)

PORTB.F1=1; //turn left

PORTB.F2=0;

PORTB.F3=0;

PORTB.F4=0;

else

PORTB.F1=0;

PORTB.F2=1;

PORTB.F3=0;

PORTB.F4=1;

delay_ms(100);

5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and

can run avoiding the obstacle.

5.3.1 Detecting obstacle by Ultrasonic Sensor

Fig. 5.4: Pin diagram of ultrasonic sensor

Page 7: Left Motor Right Motor Forward Forward Stop · PDF file5.3 Obstacle Avoiding RoboCar: Obstacle avoiding car can detect obstacle in front of it and can run avoiding the obstacle

Lab Manual Course Title: Embedded System Sessional Course Code: EEE 4846

Prepared By: Mohammed Abdul Kader, Assistant Professor, Dept. of EEE, IIUC Page 7

5.3.2 Circuit Diagram:

Fig. 5.3: Circuit diagram of obstacle avoiding robocar

5.3.3 Program:

bit sensor;

void main()

ANSEL=0;

ANSELH=0;

TRISB.F0=1;

TRISB.F1=0;

TRISB.F2=0;

TRISB.F3=0;

TRISB.F4=0;

PORTB=0x00;

while(1)

sensor=PORTB.F0;

if(sensor==0)

PORTB.F1=1;

PORTB.F2=0;

PORTB.F3=1;

PORTB.F4=0;

else

PORTB.F1=0;

PORTB.F2=0;

PORTB.F3=0;

PORTB.F4=0;

delay_ms(100);

PORTB.F1=0;

PORTB.F2=1;

PORTB.F3=0;

PORTB.F4=1;

delay_ms(500);

PORTB.F1=1;

PORTB.F2=0;

PORTB.F3=0;

PORTB.F4=1;

delay_ms(1000);