You are on page 1of 27



This Report is Submitted Partial Fulfillment of Requirements for the Bachelor Degree in Electronic Engineering (Computer Engineering)

Fakulti Kejumteraan Elektronik ( K e j ~ ~ t e n I a n Komputer) Kolej Universiti Teknikal Kebangsaan Malaysia


Obstacle avoidance is one of the most critical factors in the design of autonomous vehicles such as mobile robots. One of the major challenges in designing intelligent vehicles capable of autonomous travel on highways is reliable obstacle avoidance system. Obstacle avoidance system may be divided into two parts, obstacle detection (mechanism, hardware, sensors) and avoidance contrd (algorithm, software, code). Vector field histogram (VHF), vector field histogram with look verification (VHF*) and virtual force field (W) a few methods currently used in are obstacle avoidance algorithm. This project aims to improve the current obstacle avoidance system using combinational of VHF* and coordination method. The algorithm is programmed into PIC 16F84A and tested on a prototype. The prototype is build using infra red sensor with comparator circuit and DC motor. The project has been tested on several parametbs; target distance obstacle distance and size of an obstacle. The result shows that the prototype works at 60% of successfid rate.


Sistem pengelak halangan adalah bahagian yang amat penting di dalam rekabentuk sesebuah robot bergerak. Bahgian yang agak mencabar di dalam rekabentuk robot bergerak adalah adalah bagaimana memastikan keblehpercayaan sesebuah sistem pengelak halangan. Sistem pengelak halangan yang ingin diangunkan did alam projek ini boleh dibahagikan kepada dua bahagian penting. Bahagian pertama adalah perkakasan iaitu perkara berkenaan motor, pemproses mikro dan pengesan halangan. Bahagian kedua pula adalah berkaitan perisian iaitu pengaturcaraan untuk sistem pengelak halangan. Jenis pengesan yang biasa digunakan untuk mengesan halangan ialah pengesan gelombang buyi, pengesan infia merah dan pengesan sonar. Manakala jenis jenis algoritma yang telah digunakan utuk sistem pengelak halangan ialah VHF, VHF* dan VFF. Projek ini bertujuan untuk memperbaiki sistem yang sedia ada. Prototaip yang dibina untuk projek ini menggunakan PIC16F844 motor arus terus dan pengesan infia merah. Prototaip yang dibina telah diuji dalam beberapa keadaan. Didapati kebolehan prototaip ini untuk sampai ke kawasan sasaran adalah 60%.





The project is about the development an obstacle avoidance algorithm. There are two main parts in this project which are hardware and software development. Hardware consists of micro controller, motor controller, sensor, and motor circuits. While the software development part involves of algorithm programming and microcontroller programming.

Many types of controller that can be used such as Intel 8085 microprocessor, Motorola 68k microprocessor, Atmel microcontroller, Peripheral Interface Controller (PIC) microcontroller and Programmable Logic Controller (PLC). Controller that has been chose for this project is PIC 16F84A microcontroller. This PIC is manufactured by Microchip Technology.

The most suitable motor for this project is stepper motor. But due to budget constrain, dc motor is been chosen for this project. Timer and delay concept is applied in the controller program to control motor movement.



The objectives of this project are: Develop a prototype for obstacle avoidance robot. This obstacle avoidance robot should be able to find their original track after avoiding an obstacle. The prototype should not have any line tracking sensor in order to achieve the second objective.



Nowadays there is a lot of obstacle avoidance robot has been developed. After avoiding an obstacle, these robots cannot find their original direction. Therefore, this project's main objective is to overcome this problem.

For example, if the robot is to reach a target at 10 meter to the north, but there is an obstacle between the robot and the target; a normal obstacle avoidance robot will

never reach the target. This is because when the robot detects an obstacle, the robot will change their direction but does not return to its original track. This example can be illustrated as shown in Figure 1.1 below.





Figure 1 . 1 : Robot movement



Obstacle that can be detected by the sensor: Distance (max): High (min) Wide (min) Type Shape
: :

100 cm
8 cm

2 cm

any material that can reflect wave like paper, glass and metal any shape that can make the reflected wave reach IR detector



This project covers: Suitable devices that can be used in this project. Development of a suitable algorithm for the robot in order to fulfill the objective of this project. PIC programming Circuit developments Build a prototype for obstacle avoidance robot.



Chapter I is introduction of this project. It explains the objective of this project, problem statement, limitations and scope of work.

Chapter II is about the literature review. Literature review is important in order to understand previous work done in the same field. Literature review covers previous algorithm, microcontroller PIC16F84q motor controller L293D, power supply and rechargeable battery.

Chapter II is about the project methodology. This chapter explains the I procedures that have made in order to complete this project. It is include circuit design and construct the prototype.

Chapter IV is about result and discussion for this project. Prototypes that have been constructed at the previous chapter used to figure out the result of this project.

Chapter V is about summary and future recommendation. Summary have been made due to overall project. Future recommendation is upgrade that can be made to this project to make it more reliable.




There are many types of devices and components can be use for constructing an obstacle avoidance robot. This chapter will explain briefly about the device and component that have been used in this project. The devices that have been chose for this project is main controller, obstacle avoidance sensor, motor controller and power source.

PIC16F84A is chosen as the main controller, quadruple half H-bridge drive L293D as a motor microcontroller, IR transmitter and IR detector as an obstacle

avoidance sensor and nickel-metal hydride (NiMH) rechargeable battery as a power source. Motor type that has been used in this project is DC motor.



There is a lot types of controller that can be use to control a system. Tree main controller type have been commonly used today is programmable logic controller (PLC), microprocessor and microcontroller.

PLC applications are widely used in electrical device control system. PLC usually used in factory as production line control system. This type of controller infrequently used for electronic control system. To implement this PIC for a robotic system is not efficient due to the price of PLC. Currently the price for one unit PLC controller is more then RM500. This price is really high compare to the price of one microprocessor or microcontroller.

Microprocessor is usually implemented in electronic control system. It is widely used in mobile phone, personal digital assistance (PDA), VCD player and robotic control system. One chip microprocessor cannot stand alone. It has to be implemented with memory chip, input output (IO) controller chip, clock and peripheral device. This feature provides flexibility to microprocessor. The memory and I 0 port can be easily expand by adding additional memory chip or I 0 controller chip. Example of

05 microprocessor is Intel 8 8 ,Atmel and Motorola 68K.

Microcontroller is a single chip that contains controller processing unit, memory and I 0 controller. It can operate alone without additional peripheral chip like microprocessor. The advantages of microcontroller compare to microprocessor are cheaper and easy to implement. Disadvantage of microcontroller is lest flexibility due

to integrated memory and I 0 controller. Microcontroller widely used in digital camera, television, robot, electronic device and vehicle control system. In this project used PIC Microchip microcontroller as a main controller. This decision has been make due to the low price and simplicity of the microcontroller. Microcontroller is also easier to find in the market compare to microprocessor and PLC.



There is a lot type of sensor available in the market now a day. In example infia red (IR) sensor, limit switch, LDR, red green blue (RGB) sensor, digital compass, ultra sonic sensor and sonar sensor. A few type of this sensors cannot find easily like sonar sensor and digital compass.

There is a few type of sensor that can be use for obstacle detection. The most common used is ultra sonic sensor, sonar sensor and infia red (IR) sensor. The operation method apply in sonar and ultra sonic sensor is quite same. The difference between sonar and ultra sonic sensor is the sonar sensor can be rotate 360 degree. All of this sensor use wave reflection method to detect an obstacle.

Usually these obstacle avoidance sensors have two parts which is wave generator and wave detector. For ultra sonic, sonar and IR it is used 38 kHz to 40 kHz frequency to be operated.


IR sensor and IR LED

There are two main types of IR sensor. The first one is IR activated transistor.

Even the name is transistor, but this sensor only has two pin. This pin represent for emitter and collector. This sensor will activate when there is a IR wave detected. Figure 2.9 shows the symbol of this sensor.

Figure 2.1: IR sensor symbol The second type of IR sensor is IR sensor that have tree pin. Two pin for supply and the other one pin for output signal. The arrangement of the pin is not the same for all this kind of sensor. Figure 2.10 shows a few type of pin arrangement for IR sensor. Without datasheet, try and error analysis have to use to figure out the pin arrangement.



Figure 2.2: Several type of IR sensor. Source: http://

IR LED is an electronic component that can transmit IR wave. This IR LED is

R the same as a normal LED. I wave is not a visible light. R detector need to use to
check the hnctionality of this LED. Figure 2.11 shows the symbol of IR LED

Figure 2.3: I LED symbol R



Motor controller is an interface circuit between the main controller and motor. Common method used for robotic system is the H-bridge circuit. This method is suitable for DC motor, and servo motor. Additional controller is needed for driving stepper motor. This is because, stepper motor need certain input to make it rotate forward or backward. One example that can be use to controller stepper motor is by using IC L297 and ICL298.

2.4.1 H-Bridge motor controller

H-bridge motor controller is a motor driver that allows us to control the motor either rotate forward, backward or stop (brake). Basic idea for H-bridge has 4 switches to control the motor movement. Each motor movement required to turn ON two switches at the same time. Figure below represent the basic idea for H-bridge motor controller. Table below show the switch sequence how to control the motor movement.


Figure 2.4: Basic design for H-bridge motor controller. Switch to be ON A1 and A2 B1 and B2 A1 and B1 none

I 1

I Polarity I Effect I Forward I Motor spin forward


Reverse Brake Free

1 Motor act as a brake


Motor spin reverse


Motor floats freely


Table 2.1 : Switch to control motor movement.

The explanation above just to present the basic idea for motor controller. But in practical electronic circuit there is only two input switch. Which is one switch used to control forward movement and the other one for backward movement. Usually 4 or 6 power transistor need to perform H-bridge circuit. This circuit needs combination of n-

type and p-type transistor. Power transistor commonly used in constructing motor controller because of this circuit consume high power due to high operating current. Figure 2.13 (a) below shows the combination of 6 to construct H-bridge circuit. And Figure 2.13 (b) and (c) show us how to control the motor movement. While Figure 2.14 shows 4 transistor to construct H-bridge circuit.


input 2

input 1


Figure 2.5 (a): 6 transistors H-bridge

(b) Forward movement

(c) backward movement

Figure 2.5: 6 transistors H-bridge

inpm 1

input 2


(b) Forward movement

(c) backward movement

Figure 2.6: 4 transistors H-bridge

Currently there is already has a few integrated circuit (IC) that can perform the operation of H-bridge circuit. This type of IC may perform better then the normal Hbridge circuit. For example IC L293D; this IC contain 4 half H-bridge circuit, so this IC can construct two H-bridge circuit. More over this IC support voltage operation from
4.5V to 36V with output current 1A. This IC also consumes less power compared to

normal H-bridge circuit.

Table below show us few type of IC that can perform as H-bridge circuit.

TTL and CMOS input compatible Separate input-logic supply Thermal shutdown High noise immunity

Low pqwer dissipation

Internal clamp diode

TTL and CMOS input compatible

P o w a Gnd A

NO 'shoot through' current Thermal shutdown at 1710 "C Internal clamp diode

power Gnd B


Table 2.2: H-bridge motor controller IC.



Power supply is use for supplying voltage to the circuit. There are 2 types of power supply which are ac (alternating current) power supply and dc (direct current) power supply. Robotic systems usually use dc power supply.

Dc power supply at least contains a regulator, filter and load resistor. Regulator is use to regulate the output of the power supply and the filter use to stabilize the output voltage. And load resistor will act as a short circuit protection. Commonly use component for regulator is LM7805 which will provide positive 5V output and
LM7808 which will provide positive 8V output. Sometime diode zener can also be use

as regulator. Commonly use filter is low pass filter which is constructed by resistor and capacitor. Figure 2.15 below show us the basic power supply circuit with 5V output.

Figure 2.7: Power supply circuit.



Commonly used battery for robotic application is rechargeable battery. There are many types of rechargeable battery with difference characteristic. The decision to use which type of battery for robotic system depends on the requirement of the robot. For small and low power consumption robotic system NiCd (nickel cadmium) or N H i M (nickel metal hydride) rechargeable battery are commonly used. But for large and high power consumption robotic system, lead acid rechargeable battery is commonly used.


Nickel cadmium (NiCd)

COP l+! Insulation Gasket

SaLIy Valve

, Plate Saltng

egsfive Electrode

Positlvr Eiectode

Figure 2.8: NiCd rechargeable battery structure. (Source: Panasonic NiCd rechargeable battery datasheet) Nickel cadmium rechargeable battery is the first commonly used in electronic device. Currently the capacity of one AA size battery is 1000mAh. This rechargeable battery can be recharge up to 1000 times. The advantages of this battery are low self discharge rate, long life time and lower cost. While disadvantages of this battery type are lower capacity, have memory effect (battery capacity decreases when shallow charge and discharge cycles are repeated) and contain toxic material (Cadmium).

The advantages of this battery is, it have long life cycle. Under normal conditions, the lithium ion battery has a life of more than 500 charge/discharge cycles. This battery types also free from the memory effect, a phenomenon seen in nickelcadmium in which the apparent battery capacity decreases when shallow charge and discharge cycles are repeated. Li-ion batteries have a faster recharging time by using normal charger. The li-ion battery can be fully charged in 1 to 2 hours, using a constant-current / constant-voltage (CCICV) type dedicated charger with a rated voltage of 4.2V per cell.

The disadvantages for this type of battery are needs safety circuit while using this battery and the cost is higher then using NiMH battery. Li-ion battery without safety circuit can cause explosion. Normally Li-ion batteries available in the market are provided with safety circuit.

Li-ion rechargeable batteries are commonly used for note book, personal digital assistance (PDA) and hand phone.

Equation of chemical reaction inside the battery:

Positive Eketrodfa

Negative Electrode

C + r ~ i + xe-

Battery as a Whote

LiCoOz + C

. . .

Lii-x C002 + xLif + x e




Lic-x CoO2 + CLix


Figure 2.13: Reaction inside the Li-ion battery. (Source: Panasonic Li-ion rechargeable battery datasheet)

Sotiflue terminal

cell connectors

~lecrrolya rolurlon d i l m lulturicacld)

rmniue caring
POIMUC I e m ~ d e ~ (lead dioxide)

Figure 2.14: Lead-acid rechargeable battery structure. (Source: Lead-acid batteries are not usually used for electronic application. This type of battery commonly used in car, motorcycle and uninterrupted power supply (UPS). The advantage of this battery is higher energy density per unit price compare to the others rechargeable battery. While disadvantages is it is contain toxic material and the weight is heaviest compare to the others battery. Equation of chemical reaction inside the battery:

me anode
1. "-

At the cathode:

The overall reaction (during discharge) is therefore

Figure 2.15: Reaction inside the lead-acid battery. (Source:

2.6.5 Battery arrangement

Battery arrangement is important aspect to be considered in building an electronic system. There are two type battery arrangements that can be used; parallel arrangement and serial arrangement.

Parallel arrangement is used to multiply the current source. Figure below show the parallel arrangement.

Figure 2.16: Parallel arrangement.

Serial arrangement is used to gain the voltage source. Figure below show the serial arrangement.


Figure 2.17: Serial arrangement.

Both of this arrangement can be combine together in order to gain both current and voltage source. Figure bellow shows the combination of serial and parallel arrangement.

Figure 2.18: Combination of serial and parallel arrangement.



Literature review is an important part to understand each component and device that have been chose in this project. After doing literature review all the specification and characteristic of the devices and components have been figure out. This understanding will help a lot while doing circuit design.

* .w s TLk



, g



- g - 0 A

-3 6 6 ,2 : g o w w * 2 % .2

s & e

,.8 3

m 5 SP %6 e ' e !

T h Z 0



0 - 0


s o

e 0 s 2 $ a *

w 8 .-a 2

w 9.-

5 K $ 2 3 2 -2 f , 0 * + j * .8 - e 5 s 2 & .a 2 g

S K .E

p -.- , .g


Literature review: .Algorithm .PIC .Software development *Related hardware



Study the data sheet for each component. Searching the interface Develop the algorithm
by using MPLAB IDE

Study about algorithm that have been used and collect all related information.

Chose suitable device and components that can be use in this project.

circuit for each devices


Design and simulate the circuit.



Construct and test.

Integrate the algorithm (programlsoftware) and circuit (hardware) together

Test the project.

Figure 3.1: Flowchart for project methodology.