Professional Documents
Culture Documents
Supervisor
Dr. Lanka Udawatta
Co- Supervisor
Dr. Chathura De Silva
Coordinator
Mr.Shantha Fernando
This report is submitted in partial fulfillment of the requirements for the award of the
degree of Bachelor of Science of Engineering at
University of Moratuwa Sri Lanka.
Project Report
Abstract
There are several categories of robot navigation. Sensor based and vision based systems are
the two major categories of them.
Sensor based approach uses various kinds of sensors such as IR sensors and ultrasonic
sensors. IR sensors are generally used for measuring the difference in reflectivity of surfaces
depending on the properties like color, roughness. Ultrasonic sensors are used to measure
the distance to an object. Robots are built to navigate using these out puts according to the
application. In vision based approach, it uses a vision system to extract the features it needs
in order to navigate. The vision system is mostly a video or snapshot camera which can be
chosen from the various kinds of cameras available in the market. The vision based
approach can be customized in to various kinds of applications while the sensor based
approach has a low processing overhead.
Line follower is a machine that can follow a path. The path can be visible like a black line on
a white surface (or vice-versa) or it can be invisible like a magnetic field. Sensing a line and
maneuvering the robot to stay on course, while constantly correcting wrong moves using
feedback mechanism forms a simple yet effective closed loop system. As a programmer you
get an opportunity to teach the robot how to follow the line thus giving it a human-like
property of responding to stimuli.
i-Android was developed based on a vision based system to navigate the robot through a
white line marked in the black surface. It also extracted some features in the sensor based
systems as well.
This document is intended to describe the information regarding the project i-Android. It
explains literature survey, requirements, the techniques and technologies used, design and
implementation details, problems faced, and future improvements of the project.
Project Report
Acknowledgement
The completion of the line follower was not an easy task for us. The project was bit different
from other software based projects and a huge hardware and electronic knowledge were
required. In accomplishing this goal many personals gave the helping hand for us. We would
like to appreciate their guidance and encouragement since without their support the project
would not have been a success.
First of all we would like to thank Mrs. Vishaka Nanayakkara, Head of the Department of
Computer Science and Engineering who gave us tremendous help by providing necessary
guidance for our final year projects. It is a pleasure to mention Dr. Lanka Udawatta, Senior
Lecturer of Department of Electrical Engineering who was the supervisor of the project,
gave us a fabulous help and guidance in the whole period of the project. And as the Cosupervisor Dr Chathura De Silva gave us an enormous support specially giving us some
required electronic measuring equipment and precious advices when we were stuck with
technical problems. Initially we used some wrong approaches in the design process of
control circuits because of the lack of experience but with the guidance of him we could
move to the right path.
Then we would like to thank our project coordinator Mr. Shantha Fernando and all the staff
members of the Department of Computer Science and Engineering, University of Moratuwa,
for the friendly support and encouragement given by them. Its quite happy to announce
that each dead line that was there helped us to urge the development and complete this on
time.
And we would like to thank Mr. Nishantha and Mr. Kosala from Department of Electronic
and telecommunication for their great support given for this project. Mr Nimesh from
Millennium IT Technologies Ltd and Mr Thusitha Samarasekara from Dialog Telekom Ltd
gave us a helping hand in microcontroller based problems. We could get some important
design decisions using their practical experiences. And even they allowed us to use their
Project Report
workshops in some urgent situations. We would like to appreciate the support given by Mr.
Udaya Sampath Karunathillake, Ms. Banie Abeywickrama and Mr. Asanka Wikramasinghe in
the process of electronic designing.
Our team was together as a family, sharing all the happiness, hardships and even the
personal matters, during the last several months. Each member contributed maximum to
make this a success. We would like to thank all other colleagues that were not mentioned
here for their great support provided.
Project Report
Table of Contents
1. Introduction...................................................................................................................... 9
1.1SampleScenarios................................................................ ....................... 9
1.1.1Automated Production Processes.................... ............................. 9
1.1.2Baggage Carrier Systems.............................. ................................. 10
2. Background and Literature Review.................... .............................................................. 12
2.1 Background............................................................................................. 12
2.1.1 Available controlling systems......................... ...................... 12
2.1.2 Vision Systems................................................................................13
2.1.3 Existing platform....................................................................... .. 15
2.2 Literature Survey................................................................................ .... 16
2.2.1 Line detection techniques........................................................ .... 16
2.2.1.1 Edge detection...................................................................... 16
2.2.1.2 Hough transformation............................................... ........... 17
2.2.1.3 Sensor based technique............................................. .......... 18
2.2.2 C++ ................................................................................................ 21
2.2.3 Open source computer vision library......... .................................. 21
2.2.4 C++ threading using windows threading API.... ............................ 22
3. Design and Implementation...................................... ....................................................... 23
3.1 Software System....................................... .............................................. 24
3.1.1 Overall Design............................................................................... 24
Project Report
Project Report
5. Discussion ........................................................................................... 64
6. Conclusion... ................................................................................................ 66
7. Future Enhancements ................................................................................................. 67
8. Abbreviations.. ................................................................................................. 69
9. References.. ................................................................................................ 70
Project Report
Table of Figures
The Basic Structure of i-Android...........................................................................................23
Overall Design24
Server Application24
Client Application.28
User Interface-i-Android Client Application..30
Automatic Traversing Module.31
Model Image32
Steering Mechanism..35
Linear Movement Forward Direction.36
Movement along a curved path.37
Sudden Rotation39
Changing the rotation speed41
Circuit Design.42
The implemented Circuit..44
Test Console in Visual Basic.45
Pin Diagram-16F877 PIC.46
The Oscillator for clocking the Micro Controller47
Built-in Pulse Width Modulators48
Block Diagram50
Absolute Maximum Ratings.50
ULN 2803 Pin diagram.53
RS 232 Communication module.54
Test Console in C#.................................................................................................................56
Ultrasonic Sensors58
SRF 04 Connections.59
Project Report
1. Introduction
Robotics has become a very common application in most of the developed countries. High
performance, high accuracy, lower labor cost and the ability to work in hazardous places
have put robotics in an advantageous position over many other such technologies. Third
world countries like Sri Lanka however, are still not very familiar with the use of robots.
There are two reasons behind this. Firstly, the high initial costs in importing robots and
associated software and secondly the misconceptions of the capabilities of robots as day to
day essential applications.
i- Android can be considered as a mobile robot or a mobile platform that can follow a line
ideally a white line that is marked on the ground. The line may consist of bends, turns and
dead ends etc and the improved version of i-Android would deal with all types of path
characteristics with a high precision.
The basic objective of i-Android is to provide cost effective solutions for industrial
applications, commercial applications and security applications, but not restricted to them.
Slightly modified version of i-Android may be creatively used even for home applications
too.
Here we have selected some sample scenarios to highlight the useful occasions.
1.1 Sample Scenarios
1.1.1 Automated Production Processes
Industrial automation can be considered as a new arena of modern technology. Most of
the production associations now tend to automate their production processes replacing
the humans by contraptions. The major reasons for this trend are the lower operating
cost, precision and accuracy, safety and health hazard reasons, higher trustworthiness
etc.
I-Android provides a good solution for some parts of the automation such as handling
raw material and stocks. Generally those raw materials and processing units or
Project Report
conveyers are located in fixed positions, so a path between them can be easily marked
permanently. Hence the technology of i- Android can be easily used with suitable
machinery. As an example, a need of a forklift that carries raw material from stockpile to
conveyer belt can be eliminated easily, by setting up a white line between the stockpiles
and conveyer belt. This doesnt mean that i-Android can do it, but in addition to robotic
arms and object detection techniques it is not an intricate task. In that way a properly
planned organization structure can reduce the labour cost effectively. In this sample
scenario it eliminates the need of having a separate operator for each and every forklift
reducing the operation cost of the production process drastically.
In most countries including Sri Lanka, there are some regulations related with health
hazards and the safety of the employees. Especially in the countries with Industrial
economies they are really essential. In those applications that have unsafe environments
for humans this technology may be really useful. A properly designed machine can work
properly in the environments with radioactive rays or chemical particles.
1.1.2 Baggage Carrier Systems
For this purpose baggage carriers similar to the conventional trolleys were used. A
human should push the trolley to its destination.
i-Android can make this whole process easy and safe. It will carry the bags from the
aircraft to the security check points without the aid of a human avoiding the potential
risks of bombs and similar explosions.
The passengers bags will be carried to a vehicle without the interaction of passenger,
providing a more comfortable journey to the passenger.
10
Project Report
These are only a few scenarios where the application of i-Android system may come in very
useful. If the system is further enhanced to provide improved functionalities, it would clear
the path for this product, to contribute in many practical applications.
11
Project Report
Microcontroller
Microcontrollers are the preferred method for endowing a robot with smarts. The
reasons for this include their low costs, simple power requirements (usually 2.5 to 5 V),
and ability of most, to be programmed using software and a simple hardware interface
on the PC. Once programmed, the microcontroller is disconnected from the PC and
operates on its own. These are programmed either in an assembly language or in a highlevel language such as BASIC or C. There are literally hundreds of different
microcontrollers with an excess of different interfacing capabilities that you can choose
from, to control the robot.
PDA provides a lot of processing power in a fairly small space with a number of features
that make it very attractive for use as a robot controller. Personal digital assistants can
be used as a small robot controller that combines many of the advantages of
microcontrollers, larger single-board computers, and PC motherboards and laptops. The
built-in power supply and graphic LCD display (with Graffiti stylus input) are further
advantages, eliminating the need for supplying power to the PDA and providing a
method of entering in parameter data or even modifying the application code without a
12
Project Report
separate computer. The most significant issue that will be encountered using a PDA as a
robot controller is deciding how to interface it to the robots electronics. PDAs are
becoming increasingly popular as robot controllers and there are a variety of products
and resources that will make the effort easier.
Single-board computer
A few years ago, complete computer systems built on a PCB were the preferred method
of controlling robots. These systems are still used but are much less popular due to the
availability of low-cost PC motherboards and more powerful, easy to use
microcontrollers. There are a number of robots that are controlled by single-board
computers or SBCs. Like microcontrollers, an SBC can be programmed in either assembly
language or in a high-level language such as BASIC or C and contain not only the
processor and the memory but also the I/O interfaces necessary to control a robot. SBCs
avoid the programming issues of microcontrollers due to the built-in RS-232 or Ethernet
interfaces, which allow simple application transfers.
Very small form factor PC motherboards and laptops are common controllers for larger
robots. Having your personal computer control your robot is a good use of available
resources, because you already have the computer to do the job. Just because the
average PC is deskbound it doesnt mean it cant mount it on the robot and use it in a
portable environment. These controllers can be programmed using standard
development tools and commercial, digital I/O add-ons, for the interfaces needed for
the different robot functions.
This is the most widely used method in robot construction. Because it is portable, low
cost, fast to process and has a variety of forms that can be chosen from. Basically in
13
Project Report
robotics sensors are used in many implementations as object detection, path detection
(line detection using colour variation.), etc. also it can be easily integrated to
microcontroller based controlling systems which are also widely used.
Video vision:
Single- and multicell-vision systems are useful for detecting the absence or presence of
light, but they cannot make out the shapes of objects. This greatly limits the
environment into which such a robot can be placed. By detecting the shape of an object,
a robot may be able to make intelligent assumptions about its surroundings and
perhaps, be able to navigate those surroundings.
A video system for robot vision need not be overly sophisticated. The resolution of the
image can be as low as about 100 by 100 pixels (10,000 pixels total), though a resolution
of no less than 300 by 200 pixels (60,000 pixels total) is preferred [1]. The higher the
resolution is, the better the image and therefore the greater the robots ability to
discern shapes. Video systems that provide a digital output are generally easier to work
with than those that provide only an analog video output. You can connect digital video
systems directly to a PC, such as through a serial, parallel, or USB port. Analog video
systems require that a video capture card, a fast analog to digital converter, or some
similar device to be attached to the robots computer.
While the hardware for video vision is now affordable to most robot builder, the job of
translating a visual image a robot can use, requires high-speed processing and
complicated computer programming. Giving robots the ability to recognize shapes has
proved to be a difficult task. Consider the static image of a doorway. Our brains easily
comprehend the image, adapting to the angle at which we are viewing the doorway; the
amount, direction, and contrast of the light falling on it; the size and kind of frame used
in the doorway; whether the door is open or closed; and hundreds or even thousands of
other variations. Robot vision requires that each of these variables be analyzed, a job
that requires computer power and programming complexity beyond the means of most
robot experimenters.
14
Project Report
So at the beginning we examined how we can customize the existing platform to suit our
requirement of line following. But we learned that most parts (modules) integrated were
not working due to improper maintenance. So we had to remove those parts under the
guidance of Dr.Chathra De Silva. And we had to rebuild the modules that were needed to do
our task, which also made our work more complex.
15
Project Report
relate the edge direction to the four directions that can be traced in an image
How
different
parameters
of
Canny
algorithm
can
be
varied
under
different conditions:
Smaller filters cause less blurring, and allow detection of small sharp lines.
o A larger filter causes more blurring and the localization error in the detected
edges also increases slightly.
Thresholds
16
Project Report
The upper tracking threshold can be set quite high and the lower threshold
quite low for good results. Setting the lower threshold too high will cause
noisy edges to break up. Setting the upper threshold too low increases the
number of spurious and undesirable edge fragments appearing in the output.
And setting the upper threshold too high and lower threshold too low will
miss important information.
Operators like (Roberts, Sobel, and Prewitt) can be applied to get the gradient of the
image.
o Sobel operator can be used to highlight horizontal and vertical lines
o Roberts operator can be used to identify 45 degree lines.
If the image is in low contrast some additional processing should be done before applying
this method for better results. As the images is captured using a webcam which is also
moving along with the robot, the images are in low contrast as well as having some blurring
effect due to the motion. Considering the processing overhead and the accuracy in low
contrast images, this methodology is ignored.
17
...(1)
Project Report
The Hough method transforms this line into the parameter space generated by m and y0.
For each pixel (x, y) in the original image there is obviously a corresponding "line" in
parameter space:
y0 = y - x*m
...(2)
L2
L1
R1 R2 R3 R4
Center
Sensor Array
18
Right
Project Report
Starting from the center, the sensors on the left are named L1, L2, L3, L4 and those on the
right are named R1, R2, R3, R4.
Let us assume that when a sensor is on the line it reads 0 and when it is off the line it reads
1
The next move is decided as to the position of the robot such that, L1 and R1 both read 0
and the rest read 1.
L4
L3
L2
L1
R1 R2 R3 R4
Left
Center
Right
L3
L2
L1
R1
R2
R3
R4
Left
Center
Right
Left
19
L4
L3
L2
L1 R1 R2 R3 R4
Center
0
Right
Project Report
Here L=2 R=4
2.
3.
4.
Go to step 1.
After analyzing all these techniques we decided to model the method used in the sensor
based system, in our vision system, because it is less computationally expensive, less
complex and flexible.
20
Project Report
2.2.2 C++
When we started the project we did not have much understanding in which language we
were going to do the project. We had several options such as C#, C++ and java. But after
considering the relative performances of the languages we decided to go with C++.
Hence we had to study the language as none of us had used the language before, especially
the pointers, references and memory allocation and freeing. This had taken us some time to
adapt to the language.
Image and video I/O (file and camera based input, image/video file output).
Matrix and vector manipulation and linear algebra routines (products, solvers,
eigenvalues).
Basic image processing (filtering, edge detection, corner detection, sampling and
interpolation, color conversion, morphological operations, histograms, image
pyramids).
21
Project Report
22
Project Report
I-Android is a project that is slightly different from many other Computer Engineering
related projects. There are two major components.
1. Hardware Prototype
2. Software System
The robot performs its movements with the collaboration of both sub components. Both
components are equally responsible for proper operation of the system.
23
Project Report
Camera
Server
application
Remote
application
Automatic
traversing module
Server Application
Image Capturing
Module
Port Communication
Core module
Module
(Server)
24
Message Send/Rec
Video Streaming
Communication Module
Module
Project Report
i-Android Server application is the core application that is run when the robot is operated in
the manual control mode. This application basically provides the user to operate the robot
in the direction that is desired by him/her. The manual user can use a remote computer to
connect to the robot through the network. Then he or she can give commands using the
keyboard or the control pad provided in the client application. Details of the client
application will be stated later.
Web Cam
Main objective of this system is to enable the robot to traverse itself by following a white
line. Images are captured by a normal Webcam. The system should be able to detect the
camera that has been plugged to the built-in computer, in the robot platform. In this server
application the web cam is detected and live video is sent to the remote computer on which
the user is able to operate the robot manually.
25
Project Report
More detailed descriptions of these functionalities will be provided later in the hardware
design and implementation. This module is responsible for providing the interface to the
server application to easily access the hardware system and give instructions/receive
information.
26
Project Report
manual controlling mode of the robot. The remote user is provided with the facility of
getting the live video of the front view of the robot.
Therefore the core module is responsible for managing all the major tasks that are to be
carried out by the i-Android server application. This can be considered as one of the most
important modules of this system.
27
Project Report
Client Application
Message Send/Rec
Video Streaming
Communication Module
Module
Core module
(Client)
Keyboard
Input Handler
i-Android client application is the basic interface for the remote user (administrator) to
control the robot manually. Under this application no automation is provided and the user is
totally responsible for the traversal of the robot. User is given the live video captured by the
web cam on the robot platform. Client application is run on a remote computer and the
communication is done through a wireless network. User is able to control as far as the
network connection is active.
28
Project Report
Receive video stream from the server application and display video to the user
Get key board input from the user (traversal directions of the robot)
Several modules are provided for these tasks to be achieved. Details of those will follow.
29
Project Report
30
Project Report
This is the basic view of the i-Android Client Application. It provides the user with the front
view of the path. This is done by using a real time video streaming module that is running in
the Server application.
Client application provides several functionalities.
Manual traversal of the robot using arrow keys (Manual Control Mode)
Port
controller
31
Image
processor
Line traversing
module
Project Report
Video Preprocessor
This is the one that is responsible for interacting with the camera. It captures the video
output given by the camera and separates the frames. Then the frames are transferred to
the image processing module.
Image processor
This one is responsible for identifying the line and transfers those details to the line
traversing module. The basic logic behind this module is as follows,
As we are using the model that is used by the sensor based systems we scan a few points in
the image as shown above. The distance between two points should be 75% of the width of
the line, so that at any time, one or two points of them are in the line. According to that, the
decision of speed and rotation can be predicted.
32
Project Report
LEFT
MIDDLE
RIGHT
Do
IF (Left = 0) then
IF (Middle = 0) then
IF (Right = 0) then
LeftMotor = 0
RightMotor = 0
ELSE
LeftMotor = 75
RightMotor = 100
ENDIF
ELSE // Only Left Sensor on Line
LeftMotor = 50
RightMotor = 100
ENDIF
ELSE
IF (Right = 0) THEN
IF (Middle = 0) then
LeftMotor = 100
RightMotor = 75
ELSE
LeftMotor = 100
33
Project Report
RightMotor = 50
ENDIF
ELSE
RightMotor = 100
ELSE
LeftMotor = 0
RightMotor = 0
ENDIF
ENDIF
ENDIF
PAUSE
LOOP
// Repeat
Here we gave the basic algorithm which we are using. Actually when a decision cannot be
made (like all 3 points are detected as a line) and in stop condition we use the backup IR
sensor based system to verify the line is there or not. And also we use ultrasonic sensors to
detect obstacles and when an obstacle is found the automatic mode stops the motors and
give the control to the manual mode.
Port controller
This is the one that is responsible for calling the serial port interface and send the necessary
control signals which were generated from the line traversing module. And also it gets the
sensor inputs requested by the traversing module. This is capable of doing all the
functionalities done by the port communication module in the server application.
34
Project Report
Driven Wheels
Direction of
Movement
Free Wheel
The wheels were driven using two geared DC Motors. According to the information the
motors were originally used with a toy vehicle. Because of that reason, there was no
specification marked on the motors and no datasheet was available for the motors. So we
needed to rely on practical values obtained from the motors and do a design.
The movement operations of the above configuration are done in the following way.
35
Project Report
Right Wheel
Left Wheel
Free Wheel
Both the Left wheel and the Right wheel should be rotated with the same angular
velocity. So the movement of the robot will be along a path parallel to AB axis.
A
Right Wheel
Left Wheel
Free Wheel
B
Suppose a path is curved in the anticlockwise direction. Now the robot is needed to
navigate over the curved line.
B
36
Project Report
To achieve this, the wheels of the robot should be rotated differentially. In the above
scenario the left wheel of the robot should be rotated at a lower angular velocity relative to
the right wheel, so that the resultant path will be a curve similar to the AB. To traverse over
a curve in clockwise direction the angular velocity of the left wheel should be greater than
the angular velocity of the right wheel. Those velocities should be calculated appropriately.
Suppose,
The radius of the wheel = r
Angle rotated =
Length of the Arc = L
The equation,
[1]
By dividing both sides by T (The time taken for the rotation in Radians); we get,
Here
wheel. Since the radii of wheels are equal and constant the linear velocity is directly
proportional to the angular velocity. So by changing the rotation speeds we can easily
obtain a curved motion.
37
Project Report
Right Wheel
Left Wheel
(Higher Angular
Velocity)
(Lower Angular
Velocity)
Free Wheel
38
Project Report
When dealing with turns like B and C, the platform should perform sudden rotations. This
can be performed by setting the angular velocity of one wheel to zero. So this can be
considered as a special case of above scenario.
But mechanically this should be handled by using a different mechanism. Even if the power
to a single motor is cutoff the motor may rotate freely i.e the angular velocity of the wheel
is greater than zero. So a locking mechanism should be employed to obtain an accurate
result.
Left Wheel
(Locked)
Axis of
Rotation
Right Wheel
(Higher Angular
Velocity)
Free Wheel
Other than the machineries used some other mechanisms was used to obtain the desired
motion. By rotating the motors in different directions, the system would give more quick
rotation.
39
Left Wheel
Project Report
Right Wheel
Free Wheel
By concerning all the possible scenarios the following movements can be identified. So the
ideal design should be able to perform the following operations.
1. Changing the rotation speed.
2. Changing the rotation direction.
3. Locking the motors.
The motors employed in the given prototype are Permanent magnet DC motors. So the best
mechanism that can be used with the given motors is Pulse Width Modulation (PWM).
So a Circuit based on common Digital and Analog electronic Techniques was designed and
implemented for this purpose.
In this case eight levels of speed were defined. The basic functionality of the circuit is
demonstrated below.
40
Project Report
Speed Level
000
Stopped
001
Speed Level 1
010
Speed Level 2
011
Speed Level 3
100
Speed Level 4
101
Speed Level 5
110
Speed Level 6
111
Maximum Speed
The parallel ports can basically handle 8 bits. But in this design, only 3 bits were used
because of the following reasons.
41
Project Report
Other bits can keep reserved for maintain the other functionalities such as
rotation direction changing etc.
A small current of a few milli-Amperes can be drawn from the parallel port.
But we need some higher current to perform the activities of the next stages.
So we need to use some device, preferably an IC, to overcome this problem.
So its more effective to use the same IC to increase the current as well as
save the bits from the parallel port.
A 3:8 decoder is employed in next stage. It will decode the 3 bit input into 8
outputs.
The currents along each output link are adjusted using an array of variable
resistors.
The pulse generator changes the duty ratio of the PWM according to the
voltage applied on a reference pin of PWM module.
The power control module facilitates the system to drive the high current
motors avoiding the hardware damage.
According to the above flow diagram the following circuit was designed.
42
Project Report
Motor 1
Motor 2
00
Forward
Forward
01
Forward
Backward
10
Backward
Forward
11
Backward
Backward
43
Project Report
Generally there are several ways to lock a motor. (In this case a Permanent Magnet DC
motor)
1. By short circuiting the power input pins of the motor.
2. By adding an additional mechanism preferably a solenoid to lock the wheel
mechanically.
A design using the first method was developed but the implementations were postponed
until the first two steps get 100% success.
44
Project Report
After a successful integration the prototype was tested by giving the inputs manually from
the keyboard. But we observed the following problems with that design.
1) The motors of the prototype were not 100% identical. They were quite different
when considering the number of revolutions per second. So the path of the
prototype was not a straight line. And I realized the need of having separate PWM
modules and a feedback mechanism for each motor.
2) The stability of the circuit was not sufficient. Some changes in rotation speeds could
be observed without any change of external factors.
3) The MOSFET dissipated a lot of energy in the form heat. So there was a risk of device
damage.
45
Project Report
Because of all the above factors I decided to do a major change in hardware design. The
new design consisted of Microcontrollers.
The System consists of a Hardware component with semi decision making capability. A PIC
Microcontroller would be used to grant this capability.
While concerned about the modifiability, Cost and performance factors a 16F877
Microcontroller is used in this design phase.
46
Project Report
The basic design can be sub divided into several sub categories concerning the functionality
of each component.
1) The oscillator for clocking of the microcontroller
2) I/O Port D for additional sensors
3) Two built in Pulse Width Modulators
4) RS 232 Communication Module
22pF
4 MHz
22pF
47
Project Report
The alternate design consisting of a resonator can be proposed. It eliminates the need of
capacitors and provides more stability. The availability of the electronic components in the
local market would be the major factor in component selection.
4 MHz
48
Project Report
Power Control
Circuit
Power Control
Circuit
PWM Output
PWM Output
The output of the Microcontroller would be a low current output that can have no capability
of driving the DC Motors. So an additional Power Control Circuit is designed for this
purpose. L 298 [6], A Dual Full Bridge driver IC is employed to handle this situation. The IC
can provide polarity inversion and breaking capabilities, which can be considered as
additional advantages.
49
Project Report
According to the practical readings we get, the average current rating of a single DC motor
lies between 3 4 Amperes. But according to the data-sheet of L298 Dual Full Bridge Driver,
it exceeds the maximum allowable limits per channel.
50
Project Report
So the power circuit was designed using parallel outputs. It doubles the logical absolute
maximum current ratings.
The bi-directional motor control mechanism was used with parallel channels. 1N4001 diodes
were used to avoid the equipment damage due to back electromotive forces. The basic
configuration is presented in the following figure.
51
Project Report
52
Project Report
Because of this Open Collector configuration the there is no power requirement for the IC.
But the original waveform gets inverted. So we inverted our speed specifying protocol to
deal with this matter.
53
Project Report
Video
Input
Software Vision
System
Microcontroller
Motor Controller
Circuit
Additional Sensor
Inputs
The communication between the software vision system and the Microcontroller (Marked in
Red color in diagram) would be handled using the RS 232 communication module.
In designing this stage we have considered some important factors such as communication
mode etc. The protocol used for the communication is RS 232 using the COM port of the
attached mother board. Since the communication should be full duplex for maximum
throughput there should be two parallel paths for transmission and reception. Other than
that a protocol conversion mechanism is required to convert the protocols from RS 232.
54
Project Report
According to the specifications provided by Maxim semi-conductors, a design using pins 11,
12, 13 and 14 would be suggested.
Pins 13 and 12 provide RS 232 to TTL conversion and Pins 11 to 14 provide the reverse. So
the COM port to MAX 232 communication is done in RS 232 protocol (13 V peak to peak)
and the protocol will be converted to TTL (5V peak to peak) in MAX232. The hardware
USART module in 16F877 is employed in this case.
We used a vero board for initial construction and testing purposes but we realized that the
troubleshooting capability of the constructed circuit is extremely lower. So we developed an
OrCAD design for the designed circuit and developed a Printed circuit board.
55
Project Report
To test the functionality of the parallel port and for the calibration purposes a Test console
was developed. It contained the basic control functions that to be operated on the
prototype. The test console was developed in C#.
In order to facilitate the strategic developments an API was developed with some useful
methods. The APIs were developed in C# and C++. To interact with prototype the following
methods were implemented.
void acknoledge(void);
void SendIRReading(void);
void SendLeftEncoderCount(void);
void SendRightEncoderCount(void);
void SetLeftPWMValue(void);
void SetRightPWMValue(void);
56
Project Report
void SetRotationDefaults(void);
void InvertLeftMotor(void);
void InvertRightMotor(void);
void LockLeftMotor(void);
void LockRightMotor(void);
void StopMotors(void);
void getUltrasonicOutPut(void)
3.2.4 Infrared Support Sensor System
There may be some cases that the computer vision based navigation system fails. As an example in
the positions where the light intensity is high, the camera may produce the images with a glowing
effect and the software system will not recognize an intensity change properly. In order to dealing
with this we decided to add an additional IR sensor array.
In a general case the weight for the IR sensor array was set to lower in the process of decision
making. But in a case that the vision system failure the core algorithm uses the IR array reading to
navigation increasing the probability of accurate traversal.
Each sensor element consists of an Infra red Emitter, Infrared Receiver and a Comparator. The
Infrared transmitter unit transmits a beam of Infrared light and the receiver is installed parallel to
the transmitter. When the Infrared beam is fallen on a surface with a light color the beam reflects
back. If the color of the surface is black the reflection would be extremely low. The receiver and the
comparator detect this difference and generate a digital output.
57
Project Report
gets pressed making the circuit a closed circuit. A well designed array of bumper
switches can identify the direction and the shape of the obstacle roughly and the
microcontroller can get the decision according to that. Since there is a prior collision
before the detection, this method would be useful for light weight prototypes with
lower momentum. Otherwise the switches or the collision surface may get damaged.
2. Infra Red Rangers An Infrared beam is transmitted from the robot and the
reflection is captured. The intensity of the reflection determines the availability of an
obstacle on robots path. The availability of the Infrared rangers is low and
interference from the daylight and other light sources is extremely high.
So by concerning the availability, cost, applicability and the accuracy of the each
methodology we decided to use SRF 04 Ultrasonic Rangers.
58
Project Report
5V
30mA
50mA
Frequency
40kHz
Range
3cm to 3m
Input Trigger
Weight
0.4 oz
Size
According to the Datasheet the Pin diagram of the SRF 04 Module is as follows.
59
Project Report
The transceiver module should be powered by using 5V supply pin and 0V ground pin.
A trigger pulse with 10uS width should be input to the Trigger Pulse input in order to
activate the Ranger.
After the Trigger pulse the ultrasonic transmitter sends a sonic burst consists of eight 40 kHz
pulses. Just after sending the burst it makes Echo Pulse Output logic state up.
When the receiver gets the echo pulse it lowers the logic level of Echo pulse output. So the
time taken by the sonic burst is equal to the time duration of the echo pulse.
We can assume that the velocity of the prototype is negligible with respect to the velocity of
the sound in free air. So the Distance to the obstacle can be found by dividing the total
distance by two.
60
Project Report
So the basic requirement of the hardware implementation was measuring the width of the Echo
Pulse. So we used a separate Microcontroller for this purpose due to the following reasons.
The microcontroller unit that controls the encoders and the pulse width modulation units
has occupies all three hardware timers available in the 16F877 PIC. The microcontrollers
need some timers to measure the pulse width.
The Ultrasonic sensor does not directly affect the line following functionality so it should not
affect the core functionality.
The core system was deployed and under testing. So it is more necessary to develop a
separate component and attach with the core module other than modifying the core
module.
61
void main() {
data = 0xFFFF;
TRISB = 0xA0;
PORTB = 0;
Soft_Uart_Init(PORTB, 7, 6, 2400, 0);
PORTB.F4 = 1;
Soft_Uart_Write(hi(data));
while(1){
if (PORTB.F5){
Soft_Uart_Write(lo(data));
PORTB.F4 = 0;
break;
}
}
}
void main() {
TRISD =0;
TRISB = 0x90;
PORTB=0;
TRISC = 0;
PORTC = 0;
PORTD =0;
62
Project Report
while(1){
if(PORTB.F4){
do{
hi(data) = Soft_Uart_Read(recOK);
}while (*recOK);
PORTD = hi(data);
Soft_UART_Write(data);
PORTB.F5 = 1;
do {
lo(data)= Soft_Uart_Read(recOK);
}while (*recOK);
PORTC = lo(data);
}
}
}
63
Project Report
Project Report
5. Discussion
The ultimate goal of the I-Android is to develop an efficient navigation mechanism using
computer vision. But we tried to use some hybrid mechanism to gain higher accuracy and
flexibility other than using either software approach or hardware approach.
64
Project Report
ratings we obtained were bit higher than expected. So we had to use some high current
devices for control the motors. We used L 298 in single channel mode and got some
integrated circuits burnt. Then we moved to L 298 parallel channel mode with large heat
sinks and it solved the problem in an acceptable manner.
Advantages of i-Android
Higher accuracy
Since i-Android uses some backup mechanisms for computer vision based systems, a higher
reliability can be expected.
65
Project Report
66
Project Report
6. Conclusion
Robotics and Automation based systems and technologies are vastly advancing in the field
of computer engineering. Mostly in developed countries which are exposed to modern high
end technologies, many researches are carried out in this field. These kinds of systems have
proved to be highly advantageous in many areas like educational, military and industrial
applications.
But unfortunately in developing countries like Sri Lanka, advancement of robotics systems is
relatively slow in progress. It is due to many factors such as, low exposure to modern
technologies, unaffordable cost etc. Actually robotics based systems are limited to research
work carried out in universities. Undergraduate students possess sufficient skills to carryout
research work in these areas. Those skills can even be used to develop robot systems in
large scale as commercial products. But still, sufficient support and technical expertise is not
provided.
Main target of i-Android-Line Following Robot is to provide the basis for improvement in
robotics based systems for usage in various application scenarios mentioned above.
Although this is carried out as a research project in line following robots, results of this
project will be vastly advantageous in future researches as well as industry related
applications. Especially engineering undergraduates in the field of computer technology
should pay more attention to this field. Sufficient support and motivation should be
provided to them from the universities.
Line Following Robots can be used in many practical applications such as baggage carriers,
shopping carts etc. This i-Android platform can be used as a learning platform for researches
in traversal of robot systems. This can be considered as an important usage of this system.
The Calibration Console provides users to study about controlling of motors in the traversing
mechanism.
As a conclusion it is to be emphasized the fact that i-Android-Line Following Robot platform
can be very useful in research work as well as in industrial applications.
67
Project Report
7. Future Enhancements
In the process of development of the line follower, we identified some useful features. But
according to the time limitations and the human resource limitations we could not go for
such a big goal, but we would like to include them as future enhancements.
Adding some side sensors
This can be considered as a good feature that can be implemented. There is a possibility of
getting the sides collided with walls etc. The computer vision system pays attention only on
the path in forward direction. Since the safety requirements for the proposed devices are
high its really useful to avoid the collisions of all the types including side collisions.
The most suitable methodology to achieve this is the use of ultrasonic sensors because they
produce sufficiently accurate results with any sort of reflecting surfaces in low distance. But
the system should use a suitable multiplexing mechanism to avid false alarms.
Adding Tilt sensors
With our mechanism there is no protection mechanism to deal with slopes. But with heavy
devices with a higher centre of gravity the tilts may cause some problems and safety issues.
So an addition of tilt sensors with appropriate modifications to the core algorithm can be
suggested.
Adding a Path Recording Mechanism
The basic idea of our prototype is to follow a given white line. If there is a clear path from a
certain origin to a given destination clearly there is a path in reverse also. So if it can
memorize the path it followed then it can derivate the reverse path without much effort. In
order to add this functionality there should be a proper mechanism to record the path. An
efficient dynamic data structure may solve this problem.
68
Project Report
69
8. Abbreviations
USART - Universal asynchronous receiver/transmitter
PIC Programmable Interface Controller
PWM Pulse Width Modulation
IR Infra Red
API Application Programmer Interface
TTL Transistor Transistor Logic
MOSFET - Metal Oxide Semiconductor Field Effect Transistor
70
Project Report
Project Report
9. References
[1] Gordon McComb, Myke Predko
Robot Builders Bonanza Third Edition
Intel Corporation
71
[7]16F877 Datasheet
http://www.cs.indiana.edu/csg/hardware/B442_inv_pend/30292b.pdf
[Accessed Date: 15th October 2007]
[8] Randy Charles Morin
72
Project Report