thesis report 2012
-
Upload
sharjeel-sarwar -
Category
Documents
-
view
49 -
download
1
Transcript of thesis report 2012
Line Following Using Maze Simulator
Final Year Project Report
Presented By
Sharjeel Sarwar
CIIT/SP08-BCE-077/ISB
Waqas Taqi Shah
CIIT/SP08-BCE-099/ISB
Zubair Rahat
CIIT/SP08-BCE-106/ISB
In Partial Fulfillment of the Requirement for the Degree of
Bachelor of Science in Computer Engineering
DEPARTMENT OF ELECTRICAL ENGINEERING
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, ISLAMABAD
FEBRUARY 2012
Line Following Using Maze Simulator
Final Year Project Report
Presented By
Sharjeel Sarwar
CIIT/SP08-BCE-077/ISB
Waqas Taqi Shah
CIIT/SP08-BCE-099/ISB
Zubair Rahat
CIIT/SP08-BCE-106/ISB
In Partial Fulfillment of the Requirement for the Degree of
Bachelor of Science in Computer Engineering
DEPARTMENT OF ELECTRICAL ENGINEERING
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, ISLAMABAD
FEBRUARY 2012
Declaration
We, hereby declare that this project neither as a whole nor as a part there of has been
copied out from any source. It is further declared that we have developed this project
and the accompanied report entirely on the basis of our personal efforts made under
the sincere guidance of our supervisor and related teachers. No portion of the work
presented in this report has been submitted in the support of any other degree of
qualification of this or any other University or Institute of learning, if found we shall
stand responsible.
Signature: ____________________ Sharjeel Sarwar
Signature: ____________________ Waqas Taqi Shah
Signature: ____________________ Zubair Rahat
COMSATS INSTITUTE OF INFORMATION TECHONOLOGY, ISLAMABAD
FEBRUARY 2012
Line Following Using Maze Simulator
An Undergraduate Final Year Project Report submitted to the
Department of ELECTRICAL ENGINEERING
As a partial Fulfillment for the award of Degree
Bachelor of Science in Computer Engineering
By
Name Registration Number
Sharjeel Sarwar CIIT/SP08-BCE-077/ISB
Waqas Taqi Shah CIIT/SP08-BCE-099/ISB
Zubair Rahat CIIT/SP08-BCE-106/ISB
Supervised by
Omair Inam
Assistant Professor,
Department of Electrical Engineering CIIT Islamabad
COMSATS INSTITUTE OF INFORMATION
TECHNOLOGY, ISLAMABAD
FEBRUARY 2012
Final Approval This Project Titled
Line Following Using Maze Simulator
Submitted for the Degree of Bachelor of Science in Computer Engineering
By
Name Registration Number
Sharjeel Sarwar CIIT/SP08-BCE-077/ISB
Waqas Taqi Shah CIIT/SP08-BCE-099/ISB
Zubair Rahat CIIT/SP08-BCE-106/ISB
has been approved for
COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, ISLAMABAD
____________________ ____________________
Supervisor Internal Examiner-1 Mr. Omair Inam Mr. Furqan Tahir Assistant Professor, Deptt of EE Lecturer, Deptt of EE
____________________
External Examiner Dr. Athar Khalid
____________________ Head of Deptt of Electrical Engineering
Dedication
We dedicate this thesis to our parents. With their patience, understanding, support and
most of all prayers, the completion of this work would not have been possible. Finally,
this thesis is dedicated to the people of Pakistan and to all those who believe in the
original development and adoption of latest state of the art technology.
Acknowledgements
An endeavor over long period can be successful only with advice and guidance of many
well wishers. I wish to express my profound and deep sense of gratitude to Sir Omair
Inam, Assistant professor in Department of Electrical Engineering to sparing his valuable
time and extend help in every step of our project work.
Our sincere thanks to Management and Lab-Attendants in COMSATS Institute of
Information and Technology, for providing us the opportunity to conduct our project
work.
Last but not the least we would like to thank our friends, especially Mr. Shakir Zareen
(MCS COMSATS Abbottabad) to help in developing the software section and family,
specially our parents for their prayers and motivation for the success of this project.
Sharjeel Sarwar
Waqas Taqi Shah
Zubair Rahat
Table of Contents
1. Introduction 1
1.1 Description…………………………………………………………………………………………...1
1.2 Description of Robot …………………………………………………………………………….1
1.2.1 Design ………………………………………………………………………………………………...1
1.3 Motors ………………………………………………………………………………………………..2
1.3.1 DC Motors ………………………………………………………………………………………...2
1.3.2 AC Motor …………………………………………………………………………………………..2
1.3.3 Servo Motors …………………………………………………………………………………….2
1.3.4 R/C Servo Motor ……………………………………………………………………………….3
1.3.5 Stepper Motor …………………………………………………………………………………..3
1.4 Power Supplies …………………………………………………………………………………….3
1.5 Electronic Control ………………………………………………………………………………..4
1.6 Microcontroller Systems ………………………………………………………………………4
2. Motor Driving Circuits 6
2.1 Introduction …………………………………………………………………………………………6
2.1.1 Purpose …………………………………………………………………………………………….6
2.2 Motor Driving Circuits ………………………………………………………………………….6
2.2.1 H-Bridge Circuits ………………………………………………………………………………..7
2.2.1.1 Working of H-Bridge …………………………………………………………7
2.2.1.2 Motor Driving Circuit through Darlington Transistors …… … 8
2.3 Important Features of Darlington Transistors …………………………………… 9
2.4 Major Components Used in H-Bridge ………………………………………………. 9
2.5 Advantages of Darlington Transistors ………………………………………………… 9
3. Printed Circuit Board 10
3.1 Introduction………………………………………………………………………………………10
3.2 Procedure ………………………………………………………………………………………… 12
3.2.1 Selecting Paper ……………………………………………………………………………… 12
3.2.2 Layout Printing ………………………………………………………………………………. 13
3.2.3 Fiber Sheet of Copper ……………………………………………………………………… 13
3.2.4 Etching ……………………………………………………………………………………………. 13
4. Software Section 14
4.1 Introduction …………………………………………………………………………………… 14
4.2 Brief Description ……………………………………………………………………………. 14
4.3 Bitmap Image ……………………………………………………………………………… 14
4.4 Function of Program ……………………………………………………………………… 15
4.5 Image Scaling …………………………………………………………………………………. 15
4.6 Purpose to Use Visual C# ……………………..………………………………………… 15
4.7 Image of Code ………………………………………………………………………………… 17
4.8 Image of Application ……………………………………………………………………… 18
4.9 Code ………………………………………………………………………………………………… 19
Bibliography 89
List of Acronyms
ADC …………………………………………………………………………………..… Analog to Digital Converter
MCU ……………………………………………………………………………………………… Microcontroller Unit
CPU …………………………………………………………………………………………… Central Processing Unit
BJT ……………………………………………………………………………………… Bipolar Junction Transistors
PCB ……………………………………………………………………………………………….. Printed Circuit Board
MHz …………………………………………………………………………………………….……..……..… Mega Hertz
KHz ……………………………………………………………………………………………….…..……………. Kilo Hertz
BMP ………………………………………………………………………………………………..………………….. Bitmap
R/C …………………………………………………………………………………………………... Remote Controlled
RF ……………………………………………………………………………………………………...… Radio Frequency
2D ………………………………………………………………………………………………………. Two Dimensional
3D …………………………………………………………………………………………………..… Three Dimensional
KB ……………………………………………………………………………………………………………………… Kilobyte
RAM ……………………………………………………………………………………….. Random Access Memory
ROM ………………………………………………………………………………………………… Read Only Memory
List of Figures
2.1 Working of H-Bridge …………………………………………………………………………………….. 9
2.2 Darlington Transistors ………………………………………………………………………………… 9
3.1 Printing Circuit Board …………………………………………………………………………………. 9
4.1 Picture of Code ………………………………………………………………………………………….. 33
4.2 Application Program ………………………………………………………………………………….. 33
Abstract
The goal of this project is to design a small autonomous robot which can track a black
line on a white background, while avoiding obstacles. It can avoid obstacles at both
distance and upon contact. This project is an autonomous robot that is capable of
obstacle avoidance, drive wheel synchronization and line tracking. The robot initializes
in seek mode, where it avoids obstacles and searches for a black line to track. Wheel
synchronization, during seek mode, allows the robot to travel in a straight line without
guidance. Once a black line is found, the robot tracks the line and reverses direction
when an obstacle is encountered on the line.
Chapter – 01
Introduction
1.1 Description
The main objective of our project is to run our robot on predefined path, whose
coordinates come from software. The coordinates of maze are used to make our
robot run on that path. The lines extracted from the image in monochromatic
format, becomes our maze. And the robot will follow those lines in that maze.
Robots can be defined as electromechanical instrument which can perform different
tasks on its own. Our Robot must start from point ‘A’ by following the line to
destination can be referred as point ‘B’.
1.2 Description of Robot
1.2.1 Design
Our robot is simple in design, it uses two rear wheels and roll-caster, the wheels at
the rear are used for driving and are powered (DC Motors) while the roll-caster at
front is used to support rear wheels and move in the required direction. The
powered DC motors are drive by the motor driving circuits.
The material used at the base of robot is aluminum. The upper portion consists of
acrylic sheet.
1.3 Motors
A variety of motors can be used in robots, which make the robot able to move. The
competent rating of motor describes the contribution power which is used to shift
electrical energy in to mechanical energy. Now let us overview the present motors
that can be used in robots.
1.3.1 DC Motors
These motors have magnets fixed inside them permanently. The power is supplied to
them by means of two leads (power & ground). The permanent magnet DC motor
comprises of stationary part and rotary part.
1.3.2 AC Motors
These motor works when potential difference is applied at their available leads.
1.3.3 Servo Motors
This is another type of DC Motor, who controls them self on input until they receive
signal. They are mostly used in R/F controlled toy cars and planes. It is the Dc motor
with gears and feedback system.
1.3.4 R/C Servo Motors
They are mostly found in Remote controlled devices for example toys i-e cars,
planes. They are accompanied in many robots, because they are very compressed
and available in low prices. They got built-in gear boxes, position loop back systems
and device to measure electronics. These motors work in forward and backward
motions besides revolving in circles. On signal applications they work on top of their
abilities.
1.3.5 Stepper Motor
These motors fall in the category similar to brushless AC or DC motors. The
movement of rotor is dependent on potential difference unlike magnets present in
the motor. These motors are used where extra control is needed and revolution on
command. It has specified number of step per second (maximum up to their capable
speed)
1.4 Power Supplies
We use battery to supply power; that is Nickel Cadmium Rechargeable battery; they
remain useful for longer period of time and can be recharged through a reversible
chemical effect when needed. It has the advantage that they can be recharged up to
thousands of time. And for the first time of use it gives more than four hours of
functionality. The cell’s chemistry inside the battery determines the voltage of
battery.
There are many types of batteries available in market they are classified by their
voltages, rating, capacity and size etc.
1.5 Electronic Control
There are two main portions in the hardware of our robot. One of those two is
Mechanical stage and the other is electronic control (source of undisturbed power).
Both of these stages had to be merged together for mechanical system to be
controlled by digital inputs.
1.6 Microcontroller Systems
They are inherent part of the robot they are similar to electronic control devices,
who control the function of connected devices. Mostly microprocessors are used in
the said system, they can be referred as central processing unit (CPU) in computers
but the micro word let us sense that they are small as they do not have enough
address space. Microcontrollers have small processing speeds but they are enough
to solve some real world electronic problems. The external components needed to
be coupled with MCU and CPU is the major difference between the two. MCU can
operate even without any external devices connected with them. They might need
crystal oscillator to operate them at higher frequencies.
The important prospects of microcontrollers are speed, memory, size and internal
subsystems. Speed is the no. of clocks per cycle and expressed in hertz.
Various models of microcontrollers are available in market they are 4, 8, 16 and 32
bits. The ROM and RAM are calculated in Bytes and KB.
Most of the time MCU uses Harvard Architecture, whose program is placed in
separate sections, which enables processor to access the memories efficiently. The
last but not the least aspect of MCU is “internal subsystem” includes ADC, interrupts,
serial communications and availability of timers.
MCU take input from different electronic devices and do the processing on them
where required. The program counter used to keep the track of instructions being
used and run by MCU.
Chapter-02
Motor Driving Circuit
2.1 Introduction
The most important task in our hardware portion is to drive our motors.
2.1.1 Purpose
In our main tasks, one is to make our robot follow the line. And for the said purpose we
need our motor to run according to our inputs. For example to move our robot left or
right we have to increase or decrease the speed of the motor accordingly. Therefore in
order to change the speed and direction of motors we have used some motors driving
circuits which are explained below.
2.2 Motor Driving Circuits
The circuits which can be used to drive the motors are
1. H-bridge circuit
2. L298 IC
But we opt for H-bridge circuit (manually designed)
2.2.1 H-Bridge Circuit
H-bridge is an electronic circuit which uses electrical energy in form of potential
difference across the load in different directions. For Example Assume the load is motor,
with the help of H-bridge we can move the motor according to our need and we can
also manage to vary its speed of motors.
Many types of H-bridge circuits are available such as L298 IC, but we built our own by
using Darlington Power transistors and BJTS. These Circuits are explained in this chapter.
2.2.1.1 Working of H-bridge
Mainly H-bridge consists of four transistors which perform as switches and load. When
input is applied at the base of S1 and S3 than collector and emitter of S1 and S3 are
short circuited and the current flow across the load in following manner
Figure 2.1
Similarly if the input is applied at S2 and S4 than the path of current which flows
through the load is shown in figure 2.1(b). Hence it can be seen that the direction of the
current is opposite to that in figure 2.1(a).
2.2.1.2 Motor Driving Circuit through Darlington Transistors
Darlington Transistors are powerful transistors having a high DC current gain, which is
used in H-bridge. H-bridge can operate on the following ratings (up to 24 volts, 10
ampere output current). It is designed for low frequency switching applications. We
used TIP 142 (NPN) and TIP 147 (PNP) in our H-bridge circuit.
Figure 2.2
2.3 Important Features of Darlington Transistors
1. Operating voltage range of Darlington transistor is 24 V
2. DC current output is 10 A
2.4 Major Components used in H-bridge
a. Darlington Transistors:
Darlington Transistors are designed for low frequency switching applications; they
are powerful transistors having a high DC current gain.
b. BJT(Bipolar Junction Transistors):
BJTs are used for fast switching in our H-bridge circuit.
2.5 Advantages of Darlington Transistors
1. They have high current gain
2. They are stable
3. Have a large heat sink
Chapter -03
Printed Circuit Board
3.1 Introduction
After the formation and successfully running of circuits, one of the important steps is to
design a proper PCB (printed circuit board) layout. There is so much software available
for this purpose in the market. All of them, Express PCB is the most popular and easiest
software. The property of this software is to allow to print level four PCB design. It has
the built-in characteristics of altering different parts. It also provides utilities to calculate
per board cost. These features make Express PCB is the right option for PCB layout
designing. This software comprises of two parts, one is Express PCB, and the other one is
Express SCH. The Express SCH is used for schematic design. Before making PCB, it is
good practice to design schematic first.
The circuit implemented over PCB, its working should be test over bread board, and
then according to that, its schematic will be designed. After checking the fine working
over breadboard, we should look over PCB design for our circuit.
Here are following steps which involve the making of PCB.
Glaze Paper or Sticker Back Sheet (Shiny Side).
Black Laser Printer
Fiber Copper PCB Board
Iron (to press the print over board)
Ferric Chloride (Etching Solution)
Scrubbing Material
Paper Cutter
Thinner (Petrol, alcohol or acetone)
Note that the printer should be laser; desk-jet printer cannot be used for printing
purposes of PCB. In laser printer, toner has the powder anti to the etching material used
for construction of PCBs. Toner dissolves with the rising temperature and yielding in
muggy glue just like paste. PCB layout should be printed on the shiny side of the glaze
paper and then it is allowed to dissolve on the fiber copper sheet by pressing through
iron to apply heat. After pressing neatly, it needs to remove off the paper from the fiber
sheet of copper, leaving behind the toner only. The only printing will stick on the toner,
and the rest of paper can be removed by washing gently with water.
After washing gently, now put the fiber sheet of copper into the etching solution ferric
chloride mixed with water for the chemical reaction. During this instance shake gently
and wait for the removal of extra copper on the sheet besides printing. It will be
removed, then wash the circuit board with water to clean out the board.
Next step after washing and cleaning of board is to drill where the components will be
placed. The drilling should be very precise, and keep in mind not to destroy any path of
the PCB. After drilling, the components will be placed over PCB by soldering on it. The
temperature of the solder should not be so high that it would couple off the traces from
the board.
Figure 3.1
3.2 Procedure
3.2.1 Selecting Paper
The optimum paper to be used for printing purpose should be shiny and thin. Shiny side
of sticker sheet should be perfect. After the selection of paper, cut the suitable size and
design of paper. Paper cutter is used for cutting purposes. Do some extra care while the
removals of transparent sheet, as it can rotten the printer drum and its functionality.
3.2.2 Layout Printing
Laser printers are not designed to put the sticker sheet, so it must be insert carefully to
avoid any mishap. If we don’t consider the tray of printer, it will reduce the chance of
paper backup. This work is totally on your own risk.
3.2.3 Fiber Sheet of Copper
Switch on the iron to highest temperature, and do not use steam iron for this purpose.
When the iron become hot enough, press gently the paper over copper sheet, and
continue press until it glue with fiber sheet completely. The following precautions
should be made, the table should insulate with paper, or some cloth to avoid damage.
Remove the excess paper from the board when the board cools to some low
temperature.
3.2.4 Etching
Put the fiber board into etching solution (ferric chloride) and stir continuously until most
of the copper is removed from the board. It is a total chemical reaction (exothermic).
Often we used non metallic container (plastic) for this task. The proper care should be
taken not to stir excessively, as it will thin down the tracks on the board. All the stuff
used for the purpose of etching should not be use for any other purpose and keep them
away from the reach of children.
For any undesired and unnecessary short connections, keep the plastic sheet on the
circuit board. It will also help to mount the board on any specific object. With the help
of plastic sheet, we can mount the circuit board onto our robot structure. When
mounting the board, the ports which have to used more frequently should be placed in
the direction i.e easy to access.
Chapter-04
Software Section
4.1 Introduction
In this project, the monochrome bitmap image is used to extract the coordinates of the
location. The coordinates then pass to the hardware for the practical implementation.
This task is completed using Visual C #.
4.2 Brief Description
The very first step of this project is to get the arena of some location. After getting arena
of some location, the program will automatically covert that image into monochrome
(only two colors). The next task of the program is to get the shortest path between start
and end positions. When the path is selected, it will extract the coordinates of that
location and save it into notepad file. The coordinates will be 2D. Now that coordinates
will pass to the microcontroller and which directs the hardware to drive accordingly.
4.3 BITMAP Image
The program is able to read only bitmap images. It can be changed to variety of formats
and tested successfully with bitmap. The bitmap image either is colored or
monochrome. The program will automatically convert it into monochrome (two colors
only). The two colors are black and white. The black color is considered as a path, and
white color will be neglected as obstacles. The program is made on Visual C #.
4.4 Function of Program
In the next step when the image is read by the program, now we need to select the path
between the starting and ending point of the arena. But there can be more than one
path available in that arena, but the program will select the shortest path using
differential method. Once the path is selected, the program extracts the coordinates
from the image/arena and saves it into the text file. The 2D coordinates will be stored in
the text file.
4.5 Image Scaling
After getting coordinates the program will scale that coordinates into some length. For
example one pixel represents 1 centimeter. The scaled coordinates then used to send as
instructions to the microcontroller to drive the robot according to the image. Note that
the image is not stored in the microcontrollers, only coordinates will be transferred to
the microcontroller.
4.6 Purpose to Use VISUAL C#
This task can be done with the variety of tools available in the market. We did this task
with Turbo C, Matlab and then Visual C#. We found Visual C# the most efficient tool for
this task.
The quality of Visual C# is to have maximum number of built in libraries, which means it
does not require number of lines of code, very specific piece of code can do the task
using built in libraries and functions.
By using language Turbo C, the same task done with more than 700 lines of code, and in
this Visual C#, the lines of code fall to just 100 rounds about. In Visual C#, the
implementation of GUI is also very simple and it applies efficiently into the program
without using external libraries.
4.7 Image of Code
Figure 4.1
4.8 Image of Application
Figure 4.2
4.9 Code
Here is the program code, which was previously explained.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace GridfFinder_Shakir
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "BMP Image|*.bmp";
if (dlg.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
{
textBox1.Text = dlg.FileName;
makeGridFromImage(dlg.FileName);
}
}
void makeGridFromImage(string fileName)
{
StreamWriter rtr = new
StreamWriter("d:\\coordinates.txt");
Bitmap bmp = (Bitmap)Image.FromFile(fileName);
Bitmap bmp2 = new Bitmap(bmp.Width, bmp.Height);
listView1.Items.Clear();
int count = 0;
for( int x = 0 ; x < bmp.Width ; x++ )
for (int y = 0; y < bmp.Height; y++)
{
Color c = bmp.GetPixel(x, y);
if (c.R == 0 && c.G == 0 && c.B == 0)
{
listView1.Items.Add(new ListViewItem("("
+ x.ToString() + "," + y.ToString() + ")"));
rtr.WriteLine( "(" + x.ToString() + "," +
y.ToString() + ")");
count++;
label2.Text = "Points found: " +
count.ToString();
//Application.DoEvents();
bmp2.SetPixel(x, y, Color.Black);
}
}
bmp.Dispose();
bmp2.Save("d:\\bmp1.bmp");
rtr.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs
e)
{
}
}
}
Bibliography
[01] Datasheet L298, Darlington TIP 142, TIP 147, PIC 16F877A
www.datasheetcatalog.com
[02] Robot building for beginners, by: David Cook.
[03] Building a Line Following Robot, by: Richard T. Vannoy II M.S.I.T, B.S.E.E.T.
[04] Absolute Beginner’s guide to Building Robots, By: Gareth Branwyn
[05] Autonomous Robot Thesis 621.3 (CIIT Library)