You are on page 1of 77

Autonomous Pothole filler Robot

CHAPTER 1

INTRODUCTION
The project aims towards providing an economical and reliable solution for pothole filling
process. The idea behind this project is to help the society with technology that will provide an
easy solution to the real life problem of monotonous task of filling the potholes. This project
builds a robot which autonomously does the whole job of detecting and filling the pothole at
regular periods to ensure the safety of the passengers on the road. Using real time and embedded
system we present a prototype of the design, later this can be fabricated into a real life model
with ease.

1.1

General Introduction

The aim of this project is to provide solution to the real life problem of fixing the potholes on the
road by using embedded and real time systems. The autonomous filler robot will detect the
potholes on the road and start filling them automatically and does the real time scanning for the
filled condition. Filling a pothole is a monotonous task, it should be done at a regular periods to
maintain the roads. Instead of manual filling of a pothole, automatic filling by a robot saves lot
of time and funds which were wasted on the labours who work for repairing these potholes.
In this project, Firebird V robot from NEX robotics is used as a platform for developing
the robot. The basic platform is further built to have a mechanical assembly and is coded in such
a way that it performs the pothole filling action by itself (without the aid of the user). The robot
is navigated by means of two 75RPM DC motors, it also has position encoder to move exactly to
a particular distance. It is fixed with four sharp sensors mounted on arm assembly to detect the
potholes on the road. The arm assembly is rotated with the aid of servo motor. To fill the pothole
the dispenser mechanism is activated by the stepper motor.
The design of the mechanical assemblies can be of various sizes depending on the needs
of the robot. The prototype design is limited with capabilities but real life model can be
fabricated with little modifications.

Dept. of TCE, JNNCE, Shimoga

Page 1

Autonomous Pothole filler Robot

1.2

Problem Statement

In India, roadways are one of the major kinds of transport. Potholes on the roads pose a serious
problem to the health and deeper potholes may even cause accident. Potholes should be regularly
fixed by the laborers, finding a pothole and filling it manually is a monotonous task. Keeping
these facts in mind, a robot is designed to eliminate the above problem.

1.3

Methodology

This project is applicable for fixing a pothole. This project is based on a microcontroller based
autonomous robot which will automatically detect and fill the potholes which are present on the
road. When all potholes are filled the robot indicates it with a buzzer sound.

1.4

Scope of the Project

The project aims to fix the potholes by an autonomous embedded system.

Firebird V used as a platform for building the robot, further improvements can be
made easily with this robot.

The project makes effective use of resource and saves lot of time.

1.5 Limitations

Some parameters during design were limited to the prototype design. Real life model
will be different.

Dept. of TCE, JNNCE, Shimoga

Page 2

Autonomous Pothole filler Robot

CHAPTER 2

THEORETICAL BACKGROUND
This chapter discusses about the basic functioning of the units that are employed in this project
and the theoretical background associated with them. Various components required to develop
this system are discussed here.

2.1 Basic Block diagram

Figure 2.1 Block diagram of the autonomous pothole filler robot

Dept. of TCE, JNNCE, Shimoga

Page 3

Autonomous Pothole filler Robot

1. Arm Mechanism: Robot is fitted with an arm mechanism which consists of four
arms, all these arms are dependent arms and they are rotated by the servo motor.
These arms help in scanning the entire road for potholes.
2. Distance sensors: These are the sensors which detects the distance from the sensors
to the object, these sensors are placed facing the ground so that they detect the
difference in between the ground and the pothole.
3. White Line sensors: These are the sensors which detects the white line on the road ,
this white line guides the robot to traverse along the arena.
4. Filler Mechanism: Filler Mechanism consists of the dispenser mechanism , the
dispenser is switched with the help of stepper motor which rotates a circular plate
which is below a source of the filler.
5. Robotic Vehicle : Firebird V is used as a robotic vehicle the block diagram of the
Firebird V is illustrated below

Dept. of TCE, JNNCE, Shimoga

Page 4

Autonomous Pothole filler Robot

Figure 2.2 Block diagram of FIRE BIRD V (Robotic Vehicle)

Dept. of TCE, JNNCE, Shimoga

Page 5

Autonomous Pothole filler Robot

2.2 Hardware Requirements


Fire Bird V Robot kit.

Atmega2560 microcontroller

Ni-MH battery pack, charger

Geared DC motor ( 75 RPM )

White line sensors

Sharp distance sensors

Motor drivers L293D

LCD (16*2)

External Motors

Servo Motor

Stepper Motor

USB ISP Programmer


Sun wood

2.3 Software requirements


USB ISP Programmers GUI
USB to Serial Drivers
AVR Studio

Dept. of TCE, JNNCE, Shimoga

Page 6

Autonomous Pothole filler Robot

2.4 ATMEGA 2560 Microcontroller


2.4.1 Pin description:

Dept. of TCE, JNNCE, Shimoga

Page 7

Autonomous Pothole filler Robot


2.4.2 Features of the ATMEGA 2560 Microcontroller
Advanced RISC Architecture, 8 bit microcontroller
135 Powerful Instructions
Most Single Clock Cycle Execution
32 x 8 General Purpose Working Registers
Fully Static Operation
Up to 16 MIPS Throughput at 16 MHz
On-Chip 2-cycle Multiplier
256K Bytes of In-System Self-Programmable Flash
4K Bytes EEPROM
8K Bytes Internal SRAM
Peripheral Features
Two 8-bit Timer/Counters with Separate Pre-scalar and Compare Mode
Four 16-bit Timer/Counter with Separate Pre-scalar, Compare- and Capture Mode
Real Time Counter with Separate Oscillator
Four 8-bit PWM Channels
Twelve PWM Channels with Programmable Resolution from 2 to 16 Bits
Output Compare Modulator
16-channel, 10-bit ADC
Four Programmable Serial USART
Master SPI Serial Interface
Byte oriented 2-wire Serial Interface
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator
Interrupt and Wake-up on Pin Change
I/O and Packages
86 Programmable I/O Lines

Dept. of TCE, JNNCE, Shimoga

Page 8

Autonomous Pothole filler Robot

2.5 Power supply unit:


Fire Bird V consisting of 9.6v, 2.1Ah Nickel Metal Hydride battery which can be used to power
robot for around 2 hours, in order to continue use for longer duration without worrying about the
battery getting low, robot can be powered by external power source which is nothing but
auxiliary power source. Auxiliary supply provides regulated 12V, 1Amp supply. When robot is
powered by battery, it can use maximum of 2Amp current while Auxiliary supply will provide
only 1Amp current. Robots power is divided in two separate power rails. V Mot Supply
provides power to all the noisy devices on the robot such as motors and other heavy loads. V
Batt Supply powers most of the electronics on the robot. Most of the systems on the robot are
powered by 3.3V and 5V via voltage regulators.

2.5.1 V Batt Supply


V Batt Supply stands for stabilized supply coming from the battery. This supply line is used to
power almost all the payload on the robot. When battery is almost discharged (about 30% power
remaining) and onboard payload draws current in excess of 2 amperes, then the battery voltage
can fall below 6.3V momentary. Voltage regulators will not be able to function properly below
6.3V and their output will fall below 5V. In this case the microcontroller can reset. To extend the
usable battery life and to reduce the probability of microcontroller getting reset when battery is
about to fully discharge, diodes D7 along with the capacitor C54 is used. When battery voltage
suddenly drops, diode D7 prevents the reverse flow of the current and capacitor C54 maintains
voltage within safe limits for about 100 milliseconds. For this duration capacitor C54 acts as
small battery. Similar arrangement is done in the V Mot Supply using diodes D9 and capacitor
C53. This scheme extends usable range of the fully charged battery.

2.5.2 V Mot Supply


V Mot Supply stands for motor supply. It is used to power DC motors and other heavy loads
which have lots of current fluctuations. It is the nosiest supply line on the robot. It should be used
for heavy loads that require large amount of current. This supply can be varied between 8V to
11.3V depending on the battery's charging state and type of power source (battery / auxiliary
power) used. This line can supply additional 500mA to the external load.

Dept. of TCE, JNNCE, Shimoga

Page 9

Autonomous Pothole filler Robot

Figure 2.3 Power supply unit of FIRE BIRD V (Robotic Vehicle)

2.6 Geared DC Motor


For movement of robot we have used geared DC motors. Two 75 RPM DC geared motors actuate
the robot. A DC motor is electromechanical device that converts electrical energy into mechanical
energy that can be used to do many useful works. It can produce mechanical movement. DC
motors comes in various ratings like 6V and 12V. It has two wires or pins. When connected with
power supply the shaft rotates. It is possible reverse the direction of rotation by reversing the
polarity of input.

Dept. of TCE, JNNCE, Shimoga

Page 10

Autonomous Pothole filler Robot

Figure 2.4 DC Geared Motors

2.7 White Line Sensors


White line sensors are used for detecting white line on the ground surface. White lines are used
to give robot sense of localization. White line sensor consists of a highly directional photo
transistor for line sensing and bright red LED for the illumination. Due to the directional nature
of the photo diode it does not get affected with ambient light unless it is very bright. White line
sensors are used for detecting white line on the ground surface. White lines are used to give robot
sense of localization. White line sensor consists of a highly directional photo transistor for line
sensing and bright red LED for the illumination. Due to the directional nature of the photo diode
it does not get affected with ambient light unless it is very bright.

Dept. of TCE, JNNCE, Shimoga

Page 11

Autonomous Pothole filler Robot

Figure 2.5 White line sensor assembly.


When the robot is not on a white line, amount of light reflected is less, hence less leakage current
flows through the photo transistor. In this case, the line sensor gives an output in the range of 2V
to 3.3V. When the sensor is on a white line, more light gets reflected resulting in considerable
increase in the leakage current which causes voltage across the sensor to fall between 2 to 0.1V.
Power to the red LEDs of white line sensor is controlled PG5 of ATMEGA2560 microcontroller
to extend robots battery life.

2.7.1 Why red LEDs are used instead of IR LEDs ?


Photo transistors are many times sensitive to IR than to visible light but we still use red light
illumination because of following reasons:

Red light is nearer to the infrared

Since we can see red light its easier to calibrate it using eyes

Any colour appears black because it does not reflect visible light.

Which means black surface can be ultraviolet or infrared in colour. If black is infrared colour
then robot's white line sensors will not be able to distinguish between white and black as black
will reflect all infrared waves as effectively as white surface. In case of red illumination which

Dept. of TCE, JNNCE, Shimoga

Page 12

Autonomous Pothole filler Robot


has very less infrared radiation even infrared black is still considered as black which makes red
light as colour of choice.

2.8 IR Proximity Sensors:


Infrared proximity sensors are used to detect proximity of any obstacles in the short range. IR
proximity sensors have about 10cm sensing range. These sensors sense the presence of the
obstacles in the blind spot region of the Sharp IR range sensors. Fire Bird V robot has 8 IR
proximity sensors. Figure 3.36 shows the location of the 8 IR proximity sensors. Sensors are
numbered as 1 to 8 from left to right in clockwise direction. In the absence of the obstacle there
is no reflected light hence no leakage current will flow through the photo diode and output
voltage of the photo diode will be around 3.3V.

Figure 2.6 IR Proximity Sensors

Dept. of TCE, JNNCE, Shimoga

Page 13

Autonomous Pothole filler Robot

2.9 Sharp IR Range Sensor

(GP2Y0A02YK)

Features of GP2Y0A02YK:

Less influence on colour of reflective objects, reflectivity.

Detecting distance 10 to 80cm.

Judgment distance.

External control circuit is not needed.

Low cost

This is used to detect the potholes present is the arena. Sharp sensor consists of IR LED and
CCD array boxed with precision lens mounted. These sensors have blind spot of particular range
within which gives wrong reading. These sensors are attached to arm hence detects potholes.

Blind spot: 0-10cm

Range: 10-80cm
These sensors are attached to the arm hence they the detect the potholes

Figure 2.7 SHARP IR Range Sensors

Dept. of TCE, JNNCE, Shimoga

Page 14

Autonomous Pothole filler Robot

2.10 Position Encoders


Position encoders give position / velocity feedback to the robot. It is used in closed loop to
control robots position and velocity. Position encoder consists of slotted disc which rotates
between optical encoder (optical transmitter and receiver). When slotted disc moves in between
the optical encoder we get square wave signal whose pulse count indicates position and time
period / frequency indicates velocity.
Optical encoder MOC7811 is used as position encoder on the robot. It consists of IR LED
and the photo transistor mounted in front of each other separated by a slot and encased in black
opaque casing and facing each other through narrow window. When IR light falls on the photo
transistor it gets in to saturation and gives logic 0 as the output. In absence of the IR light it gives
logic 1 as output. A slotted encoder disc is mounted on the wheel is placed in between the slot of
MOC7811. When encoder disc rotates it cuts IR illumination alternately because of which photo
transistor gives square pulse train as output. Output from the position encoder is cleaned using
Schmitt trigger based inverter (not gate) IC CD40106.

Figure 2.8 Position Encoders

2.11 Liquid Crystal Display (LCD)


LCD used here has HD44780 dot matrix LCD controller. It is also called 16x2 Alpha Numeric
LCD2. It can be configured to drive a dot-matrix liquid crystal display underthe control of
ATMEGA 2560.

Dept. of TCE, JNNCE, Shimoga

Page 15

Autonomous Pothole filler Robot

Figure 2.9 Liquid Crystal Display

2.11.1 Operation modes of LCD:


To reduce number of I/Os required, Fire Bird V robot uses 4 bit interfacing mode which requires
3 control lines and 4 data lines. In this mode upper and lower nibble of the data/command byte
needs to be sent separately. shows LCD interfacing in 4 bit mode with three control lines EN
(Enable), RS (Register Select), and RW (Read / Write). The EN line is connected to PC2. This
control line is used to tell the LCD that microcontroller has sent data to it or microcontroller is
ready to receive data from LCD. This is indicated by a high-to-low transition on this line. To
send data to the LCD, program should make sure that this line is low (0) and then set the other
two control lines as required and put data on the data bus. When this is done, make EN high (1)
and wait for the minimum amount of time as specified by the LCD datasheet, and end by
bringing it to low (0) again. The RS line is connected to PC0. When RS is low (0), data is treated
as a command or special instruction by the LCD (such as clear screen, position cursor, etc.).
When RS is high (1), data being sent is treated as text data which should be displayed on the
screen. The RW line is connected to PC1. When RW is low (0), the information on the data bus
is being written to the LCD. When RW is high (1), the program is effectively querying (or
reading from) the LCD.
The data bus is bidirectional, 4 bit wide and is connected to PC4 to PC7 of the microcontroller.
The MSB bit (DB7) of data bus is also used as a Busy flag. When the Busy flag is 1, the LCD is
in internal operation mode, and the next instruction will not be accepted. When RS = 0 and R/W
= 1, the Busy flag is output on DB7. The next instruction must be written after ensuring that the
busy flag is 0. Refer LCD datasheet provided in documentation CD for using Busy flag.

Dept. of TCE, JNNCE, Shimoga

Page 16

Autonomous Pothole filler Robot

Figure 2.10 LCD Timing Diagram


LCD is interfaced to the pins 22 to 28 of the main board socket. LCD uses 5V System supply for
its operation. For LCD backlight V Battery supply is used. Figure 8.45 shows LCD backlight
jumper and LCD contrast control potentiometer. In order to save power LCD backlight can be
turned off by removing LCD backlight jumper. LCDs contrast can be adjusted by LCD contrast
control potentiometer.

Figure 2.11 LCD Contrast Control

2.12 Buzzer
Robot has 3 KHz piezo buzzer. It can be used for debugging purpose or as attention seeker for a
particular event. The buzzer is connected to PC3 pin of the microcontroller. Also the same
buzzer is used in battery monitoring circuit to alert the battery low indication.

Dept. of TCE, JNNCE, Shimoga

Page 17

Autonomous Pothole filler Robot

Figure 2.12 Buzzer

Buzzer is driven by BC548 transistor. Resistor 100K is used to keep transistor off, if the input
pin is floating. Buzzer will get turned on if input voltage is greater than 0.65V.

2.13 Servo Motor


A servomotor is a rotary actuator that allows for precise control of angular position. It consists of
a motor coupled to a sensor for position feedback, through a reduction gearbox. It also requires a
relatively sophisticated controller, often a dedicated module designed specifically for use with
servomotors. Servomotors are used in applications such as robotics.

Figure 2.13 Servo Motor

Dept. of TCE, JNNCE, Shimoga

Page 18

Autonomous Pothole filler Robot


2.13.1 Mechanism of Servo Motor
As the name suggests, a servomotor is a servomechanism. More specifically, it is a closed-loop
servomechanism that uses position feedback to control its motion and final position. The input to
its control is some signal, either analogue or digital, representing the position commanded for the
output shaft.
The motor is paired with some type of encoder to provide position and speed feedback. In
the simplest case, only the position is measured. The measured position of the output is
compared to the command position, the external input to the controller. If the output position
differs from that required, an error signal is generated which then causes the motor to rotate in
either direction, as needed to bring the output shaft to the appropriate position. As the positions
approach, the error signal reduces to zero and the motor stops.
The very simplest servomotors use position-only sensing via a potentiometer. The motor
always rotates at full speed (or is stopped). This type of servomotor is not widely used in
industrial motion control, but they form the basis of the simple and cheap servos used for radiocontrolled models.
More sophisticated servomotors measure both the position and also the speed of the
output shaft. They may also control the speed of their motor, rather than always running at full
speed. Both of these enhancements, usually in combination with a PID control algorithm, allow
the servomotor to be brought to its commanded position more quickly and more precisely, with
less overshooting.

2.14 Stepper Motor


Stepper motor is an electric motor which is used in control system for the precise rotation by
some predefined angle. The Bipolar Stepper motor is very similar to the unipolar Stepper except
that the motor coils lack center taps. Because of this, the bipolar motor requires a different type
of controller, one that reverses the current flow through the coils by alternating polarity of the
terminals, giving us the name - Bipolar. A Bipolar motor is capable of higher torque since entire
coil(s) may be energized, not just half-coils. Where 4-wire steppers are strictly 'Bipolar'.
The Bipolar Stepper motor has 2 coils. The coils are identical and are not electrically
connected. You can identify the separate coils by touching the terminal wires together-- If the
terminals of a coil are connected, the shaft becomes harder to turn.
The Bipolar Controller must be able to reverse the polarity of the voltage across either
coil, so current can flow in both directions. And, it must be able to energize these coils in
sequence. Let us look at the mechanism for reversing the voltage across one of the coils...

Dept. of TCE, JNNCE, Shimoga

Page 19

Autonomous Pothole filler Robot

Figure 2.14 H-Bridge for driving Stepper Motor


This circuit is called an H-Bridge, because it resembles a letter "H". The current can be
reversed through the coil by closing the appropriate switches - AD to flow one direction then BC
to flow the opposite.

Another way of depicting the H-Bridge... Since each half of the bridge can both sink and
source current, it qualifies as a push-pull type amplifier, and can be drawn with the symbol for
the amplifier.
H-bridges are applicable not only to the control of stepping motors, but also to the control
of DC motors, solenoids and many other applications, where polarity reversal is needed. Diodes
protect the switches from the kickback of inductive type loads, such as the coils of a stepper.
Two such circuits are needed to drive both coils of the bipolar stepper, and are commonly
called a" Dual H-Bridge."

Dept. of TCE, JNNCE, Shimoga

Page 20

Autonomous Pothole filler Robot


2.14.1 Conceptual Model of Bipolar Stepper Motor

Figure 2.15 Conceptual Model of Bipolar Stepper Motor


The coils are activated, in sequence, to attract the rotor, which is indicated by the arrow in the
picture. (Remember that a current through a coil produces a magnetic field.) This conceptual
diagram depicts a 90 degree step per phase. Assuming Terminal 1a is positive and 1b is
negative, the rotor points to the East in this diagram. If these two terminals were reversed in
polarity the rotor would point to the West. Coil 2 is entirely de-activated in the diagram.
In a basic "Wave Drive" clockwise sequence, winding 1 is de-activated and winding 2
activated to advance to the next phase. The rotor is guided in this manner from one winding to
the next, producing a continuous cycle. Note that if two adjacent windings are activated, the
rotor is attracted mid-way between the two windings.

Dept. of TCE, JNNCE, Shimoga

Page 21

Autonomous Pothole filler Robot

CHAPTER 3

DESIGN AND IMPLEMENTATION


This chapter discusses the algorithm, basic design and implementation of the different analog
and digital circuit components employed in the project.

3.1 Flowchart of the Project

Start

Divider detected
to CenterIR range
sensor?

N
o

U Turn Interrupt

Y
Y
White line following & pothole detection &
filling with continuous divider sensing

White
line
found?

White line searching algorithm

Finish

Figure 3.1 Flowchart of the overall project


Dept. of TCE, JNNCE, Shimoga

Page 22

Autonomous Pothole filler Robot

Start
Configure motion ports to adjust
speed of robot

Define motion sets for robot

LCD Port Configure

ADC Port Configure

Buzzer Initialization

Left, Center, Right White line sensor and


Center, Right, Left Sharp IR Range sensors

ADC Conversion

1
Dept. of TCE, JNNCE, Shimoga

Page 23

Autonomous Pothole filler Robot

Estimation of Values for


Range sensors in millimeter

Print Value on LCD

Divider
Detecte
d?

U-Turn
Already
taken ?

U -Turn

Initialize Servo motor

Scan the entire region with


the arm mechanism

Dept. of TCE, JNNCE, Shimoga

Page 24

Autonomous Pothole filler Robot

Pothole
detected
?

Print on LCD and


Pothole filling
algorithm

White line
detected at
center
sensor?

Move with maximum velocity

Outside the left or right


sensor

Return
Adjust to white line

Figure 3.2.White line following and pothole detection algorithm

Dept. of TCE, JNNCE, Shimoga

Page 25

Autonomous Pothole filler Robot

START

MOVE FORWARD BY 30 CM

TAKE RIGHT TURN BY 90


DEGREES

MOVE FORWARD BY 49 CM

TAKE RIGHT TURN BY 90


DEGREES

RETURN
Figure 3.3 U- Turn interrupt

Dept. of TCE, JNNCE, Shimoga

Page 26

Autonomous Pothole filler Robot

START

POTHOLE
DETECTED BY
MAIN RIGHTOR
LEFT SENSOR

CALCULATE THE MID POINT OF


WIDTH OF THE POTHOLE

IF POTHOLE
DETECTED TO
THE RIGHT OR
LEFT
SECONDARY
SENSOR

CALCULATE THE MID POINT OF


WIDTH OF THE POTHOLE

L
ROTATE STEPPER MOTOR IN
ANTICLOCKWISE DIRECTION TILL
FILLER REACHES CORRECT PLACE

SENSE THE POTHOLE IN REAL TIME AND


FILL TILL POT HOLE IS COMPLETELY FILLED

ROTATE STEPPER MOTOR IN


ICLOCKWISE DIRECTION TILL FILLER
REACHES CORRECT PLACE

SENSE THE POTHOLE IN REAL TIME AND


FILL TILL POT HOLE IS COMPLETELY FILLED

TRANSFER THE POSITION


OF THE DETECTED
POTHOLE TO THE MAIN
LEFT SENSOR BY
EXTENDING THE
DETECTION ANGLE

RETURN

TRANSFER THE
POSITION OF THE
DETECTED POTHOLE TO
THE MAIN LEFT SENSOR
BY EXTENDING THE
DETECTION ANGLE

Figure 3.4 Pothole Filling

Dept. of TCE, JNNCE, Shimoga

Page 27

Autonomous Pothole filler Robot


Figure 3.1 to 3.4 depicts the flowchart of the project and its functionality. The robot continuously
follows the white line and searches for the pothole when a pothole is found then the best point of
filling is found out by the algorithm and then the filling takes. While filling real time scanning
for the filled condition will takes place, when the pothole is filled the robot is again bound to
follow the white line.
To simulate the real scenario of the pothole filling we have designed an arena, the robot
is supposed to travel on this arena,

Fig 3.5 Blue Print of the arena

Dept. of TCE, JNNCE, Shimoga

Page 28

Autonomous Pothole filler Robot


The robot is bound to complete the following tasks so as to complete the challenge of filling the
pothole on the given scenario

Traverse throughout the arena and scan the area for the potholes using arm assembly
mounted on the robot.

When Pothole is detected, automatically activate dispenser mechanism.

Dispenser mechanism will fill pothole.

Real Time scanning of pothole to ensure its complete filling.

Make a U-turn when the other part of the lane is to be traversed.

Should stop navigating when any obstacle is detected.

Should indicate when the material in the source gets empty.

The working of the complete project is divided into three kinds


1) Navigation
2) Pothole Detection
3) Pothole Filling

3.2 Navigation
Navigation consists of movement of the robot along the arena, to make this traversal
possible, the following components are involved

DC Geared Motor

Position Encoder

White line sensors

3.2.1 DC Geared Motor


Firebird V robot has two 75 RPM DC geared motors in differential drive configuration
along with the third caster wheel for the support. Robot has top speed of about 24cm per second.
Using this configuration, the robot can turn with zero turning radius by rotating one wheel in
clockwise direction and other in counter clockwise direction.

Dept. of TCE, JNNCE, Shimoga

Page 29

Autonomous Pothole filler Robot

3.2.1.1 PWM for DC Motor Speed Control

Pulse width modulation is a process in which duty cycle of constant frequency square wave is
modulated to control power delivered to the load i.e. motor. Duty cycle is the ratio of TON/ T.
Where TON is ON time and T is the time period of the wave. Power delivered to the motor is
proportional to the TON time of the signal. In case of PWM the motor reacts to the time
average of the signal.PWM is used to control total amount of power delivered to the load without
power losses which generally occur in resistive methods of power control.

Figure 3.6 PWM Illustration

Dept. of TCE, JNNCE, Shimoga

Page 30

Autonomous Pothole filler Robot


Figure shows the PWM waveforms for motor velocity control. In case (A), ON time is 90%of
time period. This wave has more average value and hence more power is delivered to the motor.
In case (B), the motor will run slower, as the ON time is just 10% of time period.

3.2.1.2 Logic level for the motor direction control

Table 3.1 Microcontroller Connections for Motor

Table 3.2 Logic Levels for Motor control

Dept. of TCE, JNNCE, Shimoga

Page 31

Autonomous Pothole filler Robot


3.2.2

Position Encoder:

Position Encoder is used for the precise movement during the U-turn of the robot to enter the
other lane of the road

Table 3.3 Position Encoder connections to Microcontroller

3.2.3 White Line Sensors:


White line sensors are fitted to the robot so as to detect the white line in the center of the arena,
the programming is done in such a way that the robot is brought back to white line when it goes
off course. For white line sensors to properly work calibration must be done , the procedure is
explained below.

3.2.3.1 White Line sensor calibration


By using trimming potentiometers located on the top center of the main board, line sensors can
be calibrated for optimal performance. Line sensors are factory calibrated for optimal
performance. Using these potentiometers we can adjust the intensity of the red LEDs of the white
line sensor. Sensitivity adjustment is needed, when colour contrast between the white and nonwhite surface in a white line grid is not adequate. In such cases the sensors can be tuned to give
maximum difference between white and non-white surfaces. You can also turn on and turn off
red LEDs and take sensor readings at the same place and nullify the effect of the ambient light.

3.2.3.2 Effect of ambient light on the white line sensors


White line sensors are highly directional in nature hence they are immune to the illumination
from tube light or CFL. Note that tube light which uses simple inductive chock actually blinks
50times a second and this blink is captured by the white line sensors as ADC can acquire data at
very fast rates. Hence it is recommended that use CFL lights or tube lights with electronic chock
Dept. of TCE, JNNCE, Shimoga

Page 32

Autonomous Pothole filler Robot


or ballast. These tube lights are the one which turns on like a bulb without flickering. White line
sensors are essentially sensitive photo transistors with precision lens assembly. All the photo
diodes and photo transistors are many times sensitive to infrared than to red light. Hence for
consistent result avoid room which have large windows even if they have curtains. Also avoid
using robots in area illuminated with filament based bulbs as they have large infrared light
radiation.

3.3 Pothole Detection:


Pothole detection is done by the Sharp IR Range sensors which are facing downward to the road
and these are fitted on the arms which are connected to the servo motor.

3.3.1 Sharp IR range sensors: GP2YOA02YK IR


The above is a precision distance sensor, which detects the potholes present in the arena. Range
sensor basically consists of the IR (Infrared) led and linear CCD (Charged Couple Device) array
which is fitted inside a plastic casing. When a narrow beam of IR Ray from the IR Transmitter
incidents on any surface or objects, it reflects back to the linear CCD array. This accounts to the
difference in angle produced due to the different distances from the object which is measured to
get the corresponding analog output voltage from the sensor. The sensor works on Triangulation
method and not on intensity. Thus it is immune to ambient light and can detect object of any
colour. This sensor has a blind spot of 0 to 10 cm where, sensors give erroneous readings.
To detect potholes present in the arena, we are using the Sharp IR Range sensor which is
fitted on the arm mechanism with the help of moving arm we can scan entire region for detection
of potholes. Servo motors are used to control two arm assembly. The Left arm detects the
pothole to the left part of the road and the right arm to right side.
The arms are placed at the height of 15 cm from the road level, on the top of the robot.
The above mentioned sensors are attached at the far end of the arms in such a way that it faces
downwards to measure the distance between road and sensor itself. When the arm is scanning,
the pothole is an increase in the distance between the surfaces due to the depth of the pothole.
This is how pothole is detected.

Dept. of TCE, JNNCE, Shimoga

Page 33

Autonomous Pothole filler Robot

Infrared Range
Sensor for
detection of
pothole.

Servo Motor

Fig 3.7 Side View of the Arm Assembly used in detecting Pothole

Dept. of TCE, JNNCE, Shimoga

Page 34

Autonomous Pothole filler Robot


3.3.2 How Pothole is detected?

Pothole is detected by the increase of distance; it is illustrated in the figures below,

Sharp Infrared Range


Sensor at Normal
Surface.

Fig 3.8 Illustration of Sharp sensor detection at normal surface

Sharp Infrared Range


Sensor at Pothole
Distance > Normal
distance

Fig 3.9 Illustration of Sharp sensor detection at Pothole

Height of Sensor from ground = x mm

When Potholes detected = x mm + y mm = (x+y) mm

When Potholes Filled = x mm

So when Distance detected is x mm, it is detected that pothole is filled or there is no pothole and
robot moves forward.
Dept. of TCE, JNNCE, Shimoga

Page 35

Autonomous Pothole filler Robot

3.3.3 Position of the IR Range Sensors on and around the robot

Auxiliary Arms

Sharp Infrared Range


Sensor Primary Leftto detect potholes to the
left of white line

Sharp Infrared Range


Sensor Right- to detect
potholes to the right of
white line

Center Sharp Infrared


Range Sensor - to give
precise location to make
a U-Turn

Four Dependent arms


connected to single
Servo Motor
Servo Motor for Arm
Movements

Fig 3.10 Position of Sensors on and around the robot

Dept. of TCE, JNNCE, Shimoga

Page 36

Autonomous Pothole filler Robot

3.3.4 Construction of assembly for pothole detection

Arms made
from Fiber
material
(Sun wood)

Fig 3.11 Illustration of arm structure

The arms are constructed with the help of the locally available material called the sun wood. This
wood provides maximum strength and is very light weight, economical too. So this is chosen as
the best material for the whole construction of the robot.

Dept. of TCE, JNNCE, Shimoga

Page 37

Autonomous Pothole filler Robot


3.3.5 Estimation of best point for filling

First Random point of


detection

Best point for Filling

First initial
estimation for

Angle traced by action


of servo

lling

Initial point

Final point

Fig 3.12: - Illustration of Selection of point of filling

The best point for filling is found out by the algorithm which finds the centroid of the whole
pothole. Initially only a random point is detected while the robot is traversing, a when this
algorithm is applied then the robot will find the best point by calculating the average of the
maximum stretches of the ends of the pothole. That average will be the center of the pothole and
itll be the best point for filling.

Dept. of TCE, JNNCE, Shimoga

Page 38

Autonomous Pothole filler Robot

3.4 Pothole Filling:


3.4.1 Construction of Dispenser Mechanism

Container

Dispenser
Mechanism

Sweeper

Fig 3.13 Illustration of Dispenser Mechanism

Dept. of TCE, JNNCE, Shimoga

Page 39

Autonomous Pothole filler Robot


3.4.2 Stepper Motor
Stepper motor is used here to switch left or right opening in the container which is connected to
the primary arms

Gear Assembly

Fig 3.14 Illustration of Gear Assembly

Dept. of TCE, JNNCE, Shimoga

Page 40

Autonomous Pothole filler Robot


3.4.2.1 Flow Selection using stepper motor

Anti Clockwise
movement of
stepper motor
for left
opening.

Figure 3.15 Flow Selection Left

Clockwise
movement of
stepper motor
for right
opening.

Figure 3.16 Flow Selection Right

Dept. of TCE, JNNCE, Shimoga

Page 41

Autonomous Pothole filler Robot

3.5 Programming the AVR

Figure 3.17 NEX Robotics ISP USB Programmer


NEX AVR USB ISP STK500V2 is a high speed USB powered STK500V2 compatible. InSystem USB programmer for AVR family of microcontrollers. It can be used with
AVR Studio on Windows7 it can be used in HID mode with GUI as programming interface. Its
adjustable clock speed allows programming of microcontrollers with lower clock speeds. The
programmer is powered directly from a USB port which eliminates need for an external power
supply. The programmer can also power the target board from a USB port with limited supply
current of up to 100mA.

Dept. of TCE, JNNCE, Shimoga

Page 42

Autonomous Pothole filler Robot


3.5.1 Features

Low cost USB compatible (No legacy RS232 required)

Can be used with AVR dude on Win7/XP/Vista

Jumper adjustable programming clock speeds for low clock speed microcontrollers. Low
speeds from 32 KHz to 1MHz are supported.

Programs almost all AVR microcontrollers

Jumper selectable HID/CDC mode.

USB powered

Jumper selectable 5V power supply for target boards

Standard 10 pin (5x2) programming connector

Power and programming activity indicator LEDs

No external power supply required

3.5.2 ISP Connector Pin Details

Figure 3.18 ISP Pin Details

Dept. of TCE, JNNCE, Shimoga

Page 43

Autonomous Pothole filler Robot

3.5.3 STK500v2 GUI


STK500V2 is a high speed USB powered STK500V2 compatible In-System USB
programmer for AVR family of microcontrollers.STK500v2 has to be configured in HID mode
to work with STK500v2 GUI.
The below figure shows the STK500v2 GUI.

Figure 3.19 ISP USB Programmers GUI

Dept. of TCE, JNNCE, Shimoga

Page 44

Autonomous Pothole filler Robot

Figure 3.20 Details of GUI


Microcontroller: - Select micro controller from the list of microcontrollers present in the
GUI to write file on them.
Exit: - Exit STK500v2 GUI.
Browse: - Browse the path of the file that you want to write on the microcontroller.
Program: - Program/Write selected file on microcontroller.
Erase: - Erase the file that is currently written on the microcontroller.
Verify: - Verify the currently loaded file on the microcontroller.
Clear: - Clear STK500v2 GUI window.
E Fuse: - Input proper extended fuse value from Table 2 or Table 3 to write the
microcontrollers fuse setting.
H Fuse: - Input proper High fuse value from Table 2 or Table 3 to write the
microcontrollers fuse setting.
L Fuse: - Input proper Low fuse value from Table 2 or Table 3 to write the
microcontrollers fuse setting.
Read: - Read the microcontrollers current fuse setting.
Write: - Write microcontrollers fuse setting.

Dept. of TCE, JNNCE, Shimoga

Page 45

Autonomous Pothole filler Robot

3.5.4 Programming using the GUI


To program the Target boards Microcontroller with the GUI we need to do the following
actions,

Select the Proper Microcontroller

Select the file for the burning(.hex file)

Click on Program

Figure 3.21 Programming using GUI


Dept. of TCE, JNNCE, Shimoga

Page 46

Autonomous Pothole filler Robot

CHAPTER 4

CONCLUSION AND FUTURE SCOPE


4.1 Conclusion
After successfully testing all different codes, the final outcome of this project is that it can be
successfully implemented on detecting and filling pothole autonomously. The outcome of the
project is discussed in terms of advantages and limitations in the following sections.

4.2 Advantages

Automatically detect and fill the potholes.

Eliminates manual filling of potholes.

Saves lot of time.

Saves the funds which are to be invested on the laborers.

Robot is highly reliable.

Since it is completely autonomous, no human intervention is needed.

Economical way of implementing automation in fixing a pothole.

4.3 Limitations

During design phase some parameters were limited to only prototype model, real life
model is still needed to designed and fabricated.

Line Sensors may be affected by the ambient light. Real life model should overcome this

4.4 Future Scope


The future scope of this project is development of a real life model which will working on fixing
the potholes. The prototype can be modified and fabricated according to the needs.

Dept. of TCE, JNNCE, Shimoga

Page 47

Autonomous Pothole filler Robot

REFERENCES
[1] ACE in the Hole: Adaptive Contour Estimation Using Collaborating Mobile Sensors
Sumana Srinivasan, Krithi Ramamritham and Purushottam Kulkarni Department of Computer
Science and Engineering,Indian Institute of Technology Bombay, Mumbai - 400076, INDIA.
[2] Resource management for real-time tasks in mobile robotics Huan Li , Krithi Ramamritham
Prashant Shenoy , Roderic A. Grupen ,John D. Sweeney
[3] Fire Bird V ATMEGA2560 Hardware Manual
[4] Fire Bird V ATMEGA2560 Software Manual
[5] AVR Studio 4 Tutorail
[6] USB ISP Programmer Manual
[7] www.stepperworld.com/Tutorials/pgBipolarTutorial.htm
[8] www.edaboard.com

Dept. of TCE, JNNCE, Shimoga

Page 48

Autonomous Pothole filler Robot

APPENDIX A
Source Code
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <math.h>
#include "lcd.c"
voidport_init();
void timer5_init();
void velocity(unsigned char, unsigned char);
unsigned char ADC_Conversion(unsigned char);
unsigned char ADC_Value;
unsigned char sharp_center;
unsigned char sharp_left;
unsigned char sharp_right;
unsigned char sharp_aux_left;
unsigned char sharp_aux_right;
unsigned char flag1 = 0;
unsigned char flag2 = 0;
unsigned char flag3 = 0;
unsigned char flag4 = 0;
unsigned char flag5 = 0;
unsigned char Left_white_line = 0;
unsigned char Center_white_line = 0;
unsigned char Right_white_line = 0;
unsigned int value_center,value_left,value_right,value_aux_left,value_aux_right;
unsigned long intShaftCountLeft = 0; //to keep track of left position encoder
unsigned long intShaftCountRight = 0; //to keep track of right position encoder
unsigned long int ShaftCountLeft1 = 0; //to keep track of left position encoder
unsigned long int ShaftCountRight1 = 0; //to keep track of right position encoder
unsigned int Degrees,degrees1; //to accept angle in degrees for turning
unsigned int count=0;
int motor_pattern[4]= {0x10,0x80,0x20,0x40};
int servo_pattern[6]={15,20,25,30,25,20};
int steps,l=0;
int v=0,p=0,k=0,z=0,x=0,u=0,w=0;
unsigned int index1=0,index2=0,y=0;

Dept. of TCE, JNNCE, Shimoga

Page 49

Autonomous Pothole filler Robot


//Configure PORTB 5 pin for servo motor 1 operation
void servo1_pin_config (void)
{
DDRB = DDRB | 0x20; //making PORTB 5 pin output
PORTB = PORTB | 0x20; //setting PORTB 5 pin to logic 1
}
//TIMER1 initialization in 10 bit fast PWM mode
//prescale:256
// WGM: 7) PWM 10bit fast, TOP=0x03FF
// actual value: 52.25Hz.
void timer1_init(void)
{
TCCR1B = 0x00; //stop
TCNT1H = 0xFC; //Counter high value to which OCR1xH value is to be compared with
TCNT1L = 0x01; //Counter low value to which OCR1xH value is to be compared with
OCR1AH = 0x03; //Output compare Register high value for servo 1
OCR1AL = 0xFF; //Output Compare Register low Value For servo 1
ICR1H = 0x03;
ICR1L = 0xFF;
TCCR1A = 0xAB; /*{COM1A1=1, COM1A0=0; COM1B1=1, COM1B0=0;
COM1C1=1 COM1C0=0}
For Overriding normal port functionality to OCRnA outputs.
{WGM11=1, WGM10=1} Along With WGM12 in TCCR1B for
Selecting FAST PWM Mode*/
TCCR1C = 0x00;
TCCR1B = 0x0C; //WGM12=1; CS12=1, CS11=0, CS10=0 (Prescaler=256)
}
//Function to rotate Servo 1 by a specified angle in the multiples of 1.86 degrees
void servo_1(unsigned char degrees)
{
floatPositionPanServo = 0;
PositionPanServo = ((float)degrees / 1.86) + 35.0;
OCR1AH = 0x00;
OCR1AL = (unsigned char) PositionPanServo;
}

Dept. of TCE, JNNCE, Shimoga

Page 50

Autonomous Pothole filler Robot


//servo_free functions unlocks the servo motors from the any angle
//and make them free by giving 100% duty cycle at the PWM. This function can be used to
//reduce the power consumption of the motor if it is holding load against the gravity.
void servo_1_free (void) //makes servo 1 free rotating
{
OCR1AH = 0x03;
OCR1AL = 0xFF; //Servo 1 off
}
//Function to configure ports to enable robot's motion
void motion_pin_config (void)
{
DDRA = DDRA | 0x0F;
PORTA = PORTA & 0xF0;
DDRL = DDRL | 0x18; //Setting PL3 and PL4 pins as output for PWM generation
PORTL = PORTL | 0x18; //PL3 and PL4 pins are for velocity control using PWM.
}
//Function to configure INT4 (PORTE 4) pin as input for the left position encoder
void left_encoder_pin_config (void)
{
DDRE = DDRE & 0xEF; //Set the direction of the PORTE 4 pin as input
PORTE = PORTE | 0x10; //Enable internal pull-up for PORTE 4 pin
}
//Function to configure INT5 (PORTE 5) pin as input for the right position encoder
void right_encoder_pin_config (void)
{
DDRE = DDRE & 0xDF; //Set the direction of the PORTE 4 pin as input
PORTE = PORTE | 0x20; //Enable internal pull-up for PORTE 4 pin
}
void left_position_encoder_interrupt_init (void) //Interrupt 4 enable
{
cli(); //Clears the global interrupt
EICRB = EICRB | 0x02; // INT4 is set to trigger with falling edge
EIMSK = EIMSK | 0x10; // Enable Interrupt INT4 for left position encoder
sei(); // Enables the global interrupt
}
Dept. of TCE, JNNCE, Shimoga

Page 51

Autonomous Pothole filler Robot

void right_position_encoder_interrupt_init (void) //Interrupt 5 enable


{
cli(); //Clears the global interrupt
EICRB = EICRB | 0x08; // INT5 is set to trigger with falling edge
EIMSK = EIMSK | 0x20; // Enable Interrupt INT5 for right position encoder
sei(); // Enables the global interrupt
}
//ISR for right position encoder
ISR(INT5_vect)
{
ShaftCountRight++; //increment right shaft position count
ShaftCountRight1++;
}

//ISR for left position encoder


ISR (INT4_vect)
{
ShaftCountLeft++; //increment left shaft position count
ShaftCountLeft1++;
}
//Function used for setting motor's direction
void motion_set (unsigned char Direction)
{
unsigned char PortARestore = 0;
Direction &= 0x0F;
// removing upper nibbel for the protection
PortARestore = PORTA;
// reading the PORTA original status
PortARestore&= 0xF0;
// making lower direction nibbel to 0
PortARestore |= Direction; // adding lower nibbel for forward command and restoring the
PORTA status
PORTA = PortARestore;
// executing the command
}
void forward (void) //both wheels forward
{
motion_set(0x06);
}
Dept. of TCE, JNNCE, Shimoga

Page 52

Autonomous Pothole filler Robot

void back (void) //both wheels backward


{
motion_set(0x09);
}
void left (void) //Left wheel backward, Right wheel forward
{
motion_set(0x05);
}
void right (void) //Left wheel forward, Right wheel backward
{
motion_set(0x0A);
}
void stop (void)
{
motion_set(0x00);
}
//Function used for turning robot by specified degrees
void angle_rotate(unsigned int Degrees)
{
floatReqdShaftCount = 0;
unsigned long intReqdShaftCountInt = 0;
ReqdShaftCount = (float) Degrees/ 4.090; // division by resolution to get shaft count
ReqdShaftCountInt = (unsigned int) ReqdShaftCount;
ShaftCountRight = 0;
ShaftCountLeft = 0;
while (1)
{
if((ShaftCountRight>= ReqdShaftCountInt) | (ShaftCountLeft>=
ReqdShaftCountInt))
break;
}
stop(); //Stop robot
}

Dept. of TCE, JNNCE, Shimoga

Page 53

Autonomous Pothole filler Robot


//Function used for moving robot forward by specified distance
void linear_distance_mm(unsigned intDistanceInMM)
{
floatReqdShaftCount = 0;
unsigned long intReqdShaftCountInt = 0;
ReqdShaftCount = DistanceInMM / 5.338; // division by resolution to get shaft count
ReqdShaftCountInt = (unsigned long int) ReqdShaftCount;
ShaftCountRight = 0;
ShaftCountLeft =0;
while(1)
{
if((ShaftCountRight>ReqdShaftCountInt ) &&
(ShaftCountLeft>ReqdShaftCountInt ))
{
break;
}
}
stop(); //Stop robot
}

void left_degrees(unsigned int Degrees)


{
// 88 pulses for 360 degrees rotation 4.090 degrees per count
left(); //Turn left
angle_rotate(Degrees);
}
voidright_degrees(unsigned int Degrees)
{
// 88 pulses for 360 degrees rotation 4.090 degrees per count
right(); //Turn right
angle_rotate(Degrees);
}

Dept. of TCE, JNNCE, Shimoga

Page 54

Autonomous Pothole filler Robot


//Function to configure LCD port
void lcd_port_config (void)
{
DDRC = DDRC | 0xF7; //all the LCD pin's direction set as output
PORTC = PORTC & 0x80; // all the LCD pins are set to logic 0 except PORTC 7
}
//ADC pin configuration
void adc_pin_config (void)
{
DDRF = 0x00;
PORTF = 0x00;
DDRK = 0x00;
PORTK = 0x00;
}
//Function to initialize Buzzer
void buzzer_pin_config (void)
{
DDRC = DDRC | 0x08;
PORTC = PORTC & 0xF7;
}

//Setting PORTC 3 as outpt


//Setting PORTC 3 logic low to turnoff buzzer

void MOSFET_switch_config (void)


{
DDRH = DDRH | 0x0C; //make PORTH 3 and PORTH 1 pins as output
PORTH = PORTH & 0xF3; //set PORTH 3 and PORTH 1 pins to 0
DDRG = DDRG | 0x04; //make PORTG 2 pin as output
PORTG = PORTG & 0xFB; //set PORTG 2 pin to 0
}
void turn_off_ir_proxi_sensors (void) //turn off IR Proximity sensors
{
PORTH = PORTH | 0x08;
}
void turn_on_sharp15 (void) //turn on Sharp IR range sensors 1,5
{
PORTH = PORTH & 0xFB;
}
Dept. of TCE, JNNCE, Shimoga

Page 55

Autonomous Pothole filler Robot

//Function to Initialize PORTS


void port_init()
{
lcd_port_config();
adc_pin_config();
motion_pin_config();
buzzer_pin_config();
motion_pin_config(); //robot motion pins config
left_encoder_pin_config(); //left encoder pin config
right_encoder_pin_config(); //right encoder pin config
servo1_pin_config(); //Configure PORTB 5 pin for servo motor 1 operation
MOSFET_switch_config();
}
// Timer 5 initialized in PWM mode for velocity control
// Prescale:256
// PWM 8bit fast, TOP=0x00FF
// Timer Frequency:225.000Hz
void timer5_init()
{
TCCR5B = 0x00;
TCNT5H = 0xFF;
with
TCNT5L = 0x01;
with
OCR5AH = 0x00;
OCR5AL = 0xFF;
OCR5BH = 0x00;
OCR5BL = 0xFF;
OCR5CH = 0x00;
OCR5CL = 0xFF;
TCCR5A = 0xA9;
COM5C1=1 COM5C0=0}

//Stop
//Counter higher 8-bit value to which OCR5xH value is compared
//Counter lower 8-bit value to which OCR5xH value is compared
//Output compare register high value for Left Motor
//Output compare register low value for Left Motor
//Output compare register high value for Right Motor
//Output compare register low value for Right Motor
//Output compare register high value for Motor C1
//Output compare register low value for Motor C1
/*{COM5A1=1, COM5A0=0; COM5B1=1, COM5B0=0;
For Overriding normal port functionality to OCRnA

outputs.
{WGM51=0, WGM50=1} Along With WGM52 in
TCCR5B for Selecting FAST PWM 8-bit Mode*/
Dept. of TCE, JNNCE, Shimoga

Page 56

Autonomous Pothole filler Robot

TCCR5B = 0x0B;

//WGM12=1; CS12=0, CS11=1, CS10=1 (Prescaler=64)

}
void buzzer_on (void)
{
unsigned char port_restore = 0;
port_restore = PINC;
port_restore = port_restore | 0x08;
PORTC = port_restore;
}
void buzzer_off (void)
{
unsigned char port_restore = 0;
port_restore = PINC;
port_restore = port_restore& 0xF7;
PORTC = port_restore;
}
void adc_init()
{
ADCSRA = 0x00;
ADCSRB = 0x00;
ADMUX = 0x20;
ACSR = 0x80;
ADCSRA = 0x86;
}

//MUX5 = 0
//Vref=5V external --- ADLAR=1 --- MUX4:0 = 0000
//ADEN=1 --- ADIE=1 --- ADPS2:0 = 1 1 0

//Function For ADC Conversion


unsigned char ADC_Conversion(unsigned char Ch)
{
unsigned char a;
if(Ch>7)
{
ADCSRB = 0x08;
}
Ch = Ch& 0x07;
ADMUX= 0x20| Ch;
ADCSRA = ADCSRA | 0x40;
//Set start conversion bit
Dept. of TCE, JNNCE, Shimoga

Page 57

Autonomous Pothole filler Robot


while((ADCSRA&0x10)==0);
//Wait for conversion to complete
a=ADCH;
ADCSRA = ADCSRA|0x10; //clear ADIF (ADC Interrupt Flag) by writing 1 to it
ADCSRB = 0x00;
return a;
}
// This Function calculates the actual distance in millimeters(mm) from the input
// analog value of Sharp Sensor.
unsigned int Sharp_GP2D12_estimation(unsigned char adc_reading)
{
float distance;
unsigned int distanceInt;
distance = (int)(10.00*(2799.6*(1.00/(pow(adc_reading,1.1546)))));
distance Int = (int)distance;
if(distance Int>800)
{
distance Int=800;
}
return distance Int;
}
//Function for velocity control
void velocity (unsigned char left_motor, unsigned char right_motor)
{
OCR5AL = (unsigned char)left_motor;
OCR5BL = (unsigned char)right_motor;
}
void init_devices (void)
{
cli(); //Clears the global interrupts
port_init();
adc_init();
timer5_init();
left_position_encoder_interrupt_init();
right_position_encoder_interrupt_init();
timer1_init();
sei(); //Enables the global interrupts
}
Dept. of TCE, JNNCE, Shimoga

Page 58

Autonomous Pothole filler Robot

void print_sensor(char row, char coloumn,unsigned char channel)


{
ADC_Value = ADC_Conversion(channel);
lcd_print(row, coloumn, ADC_Value, 3);
}
void arm_update(void)
{
sharp_left = ADC_Conversion(10);
sharp_right = ADC_Conversion(12);
value_left=Sharp_GP2D12_estimation(sharp_left);
value_right=Sharp_GP2D12_estimation(sharp_right);
sharp_aux_left = ADC_Conversion (9);
value_aux_left=Sharp_GP2D12_estimation(sharp_aux_left);
sharp_aux_right = ADC_Conversion (11);
value_aux_right=Sharp_GP2D12_estimation(sharp_aux_right);
}
void white_update(void)
{
Left_white_line = ADC_Conversion(3);
//Getting data of Left WL Sensor
Center_white_line = ADC_Conversion(2); //Getting data of Center WL Sensor
Right_white_line = ADC_Conversion(1); //Getting data of Right WL Sensor
}
void center_update(void)
{
sharp_center = ADC_Conversion(13);
//Stores the Analog value of front sharp
connected to ADC channel 13 into variable "sharp"
value_center = Sharp_GP2D12_estimation(sharp_center);
}

Dept. of TCE, JNNCE, Shimoga

Page 59

Autonomous Pothole filler Robot


void stepper_cw(unsigned int degrees1)
{
unsignedint index=0;
DDRA= 0xFF;
steps=(int)degrees1/1.8;
for(l=0;l<steps;l++)
{
PORTA= motor_pattern[index++];_delay_ms(100);
index=index%4;
}
}
void stepper_ccw(unsigned int degrees1)
{
unsignedint index=0;
DDRA= 0xFF;
steps=(int)degrees1/1.8;
for(l=0;l<steps;l++)
{
PORTA= motor_pattern[index--];_delay_ms(100);
index=index%4;
}
}
void whiteline_forward(void)
{
int flag1=0;
white_update();
if(Center_white_line<0x28)
{
flag1=1;
forward();
velocity(240,240);
}
if((Right_white_line>0x28) && (flag1==0))
{
flag1=1;
forward();
velocity(137,225);
Dept. of TCE, JNNCE, Shimoga

Page 60

Autonomous Pothole filler Robot


}
if((Left_white_line>0x28) && (flag1==0))
{
flag1=1;
forward();
velocity(225,137);
}
}
void whiteline_backward(void)
{
int flag1=0;
white_update();_delay_ms(10);
if(Center_white_line<0x28)
{
flag1=1;
back();
velocity(225,225);
}
if((Left_white_line>0x28) && (flag1==0))
{
flag1=1;
back();
velocity(137,225);
}
if((Right_white_line>0x28) && (flag1==0))
{
flag1=1;
back();
velocity(225,137);
}
}
void servo_rotate1(void)
{
whiteline_forward();
white_update();
if((Center_white_line<0x28)||(Left_white_line<0x28) ||(Right_white_line<0x28))
{
i=servo_pattern[index1++];
Dept. of TCE, JNNCE, Shimoga

Page 61

Autonomous Pothole filler Robot


servo_1(i);_delay_ms(10);
index1=index1%6;
}
}
void servo_rotate(void)
{
whiteline_forward();
i=servo_pattern[index1++];
servo_1(i);_delay_ms(10);
index1=index1%6;
}

void forward_mm(unsigned intDistanceInMM)


{
velocity(255,255);
forward();
linear_distance_mm(DistanceInMM);
}
void back_mm(unsigned intDistanceInMM)
{
velocity(255,255);
back();
linear_distance_mm(DistanceInMM);
}
void u_turn(void)
{
velocity(255,255);
forward_mm(220); //Moves robot forward 100mm
stop();
_delay_ms(500);
right_degrees(90); //Rotate robot right by 90 degrees
stop();
_delay_ms(500);
forward_mm(490); //Moves robot forward 100mm
stop();
_delay_ms(500);
Dept. of TCE, JNNCE, Shimoga

Page 62

Autonomous Pothole filler Robot


right_degrees(90); //Rotate robot right by 90 degrees
stop();
_delay_ms(500);
}

void left_open(void)
{

stop();stepper_cw(65);
while(1)
{arm_update();_delay_ms(5);
if(value_left<137){stepper_ccw(65);forward_mm(20);_delay_ms(100);break;}
}
stop();_delay_ms(30);
}
void right_open(void)
{
stop();stepper_ccw(65);
while(1)
{
arm_update();_delay
if(value_right<137){stepper_cw(65);forward_mm(20);_delay_ms(100);break;
}
}
stop();_delay_ms(30);
}
void left_fill(void)
{
x=0,v=0,k=0,p=0,z=0,y=0;
x=i;
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_left<155||i<=1){ p=i;break;} // p is lesser

Dept. of TCE, JNNCE, Shimoga

Page 63

Autonomous Pothole filler Robot


}
i=x;servo_1(i);_delay_ms(100);
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_left<155 || i>=35){k=i; break;} // K is higher ,so k-p
}
i=x;
y=k-p;
if(y<5)
{
if(p>5 && k<25)
{
u=i;
servo_1(i-5);_delay_ms(100);
arm_update();_delay_ms(10);
if(value_left>180)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_left<155||i<=1){ p=i;break;}

// p is lesser

}
}
i=u;
servo_1(i+5);_delay_ms(100);
arm_update();_delay_ms(10);
if(value_left>180)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_left<155||i>=35){ k=i;break;}

// p is lesser

Dept. of TCE, JNNCE, Shimoga

Page 64

Autonomous Pothole filler Robot


}
y=k-p;
if(y<5)
{
i=u;servo_1(i);_delay_ms(100);
left_open();
}
}
if(p<=5)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_left<155||i>=35){ k=i;break;}// p is lesser
}
}
if(k>=25)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_left<155||i<=1){ p=i;break;}

// p is lesser

}
}
}
if(p>0 && k>0)
{
z=(int)((p+k)/2);i=z;_delay_ms(100);
servo_1(i);_delay_ms(200);
while(1)
{
whiteline_backward();
arm_update();_delay_ms(5);
if(value_left<155)
{
Dept. of TCE, JNNCE, Shimoga

Page 65

Autonomous Pothole filler Robot


stop();_delay_ms(50);forward_mm(65);break;
}
}
arm_update();_delay_ms(10);
if(value_left>180)
{
left_open();
back_mm(40);stop();_delay_ms(50);
}
else
{
back_mm(50);_delay_ms(50);arm_update();_delay_ms(10);
if(value_left>180)
{
left_open();
}
else
{
back_mm(35);_delay_ms(50);
left_open();
}
}
}
if(p<=0 && k<=0)
{servo_1(1);_delay_ms(100);left_open();}
}
voidright_fill(void)
{
x=0,v=0,k=0,p=0,z=0,y=0;
x=i;
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_right<155||i<=1){ p=i;break;} // p is lesser
}
i=x;servo_1(i);_delay_ms(100);
for(v=0;v<50;v++)
{
Dept. of TCE, JNNCE, Shimoga

Page 66

Autonomous Pothole filler Robot


servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_right<155 || i>=35){k=i; break;} // K is higher ,so k-p
}
i=x;
y=k-p;
if(y<5)
{
if(p>5 && k<25)
{
u=i;
servo_1(i-5);_delay_ms(100);
arm_update();_delay_ms(10);
if(value_right>180)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_right<155||i<=1){ p=i;break;} // p is lesser
}
}
i=u;
servo_1(i+5);_delay_ms(100);
arm_update();_delay_ms(10);
if(value_right>180)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_right<155||i>=35){ k=i;break;}

// p is lesser

}
}
y=k-p;
if(y<5)
{
i=u;servo_1(i);_delay_ms(100);
Dept. of TCE, JNNCE, Shimoga

Page 67

Autonomous Pothole filler Robot


right_open();
}
}
if(p<=5)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_right<155||i>=35){ k=i;break;}

// p is lesser

}
}
if(k>=25)
{
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_right<155||i<=1){ p=i;break;}

// p is lesser

}
}
}
if(p>0 && k>0)
{
z=(int)((p+k)/2);i=z;_delay_ms(100);
servo_1(i+2);_delay_ms(200);
while(1)
{
whiteline_backward();
arm_update();_delay_ms(5);
if(value_right<155)
{
stop();_delay_ms(50);forward_mm(65);break;
}
}
arm_update();_delay_ms(10);
if(value_right>180)
{
Dept. of TCE, JNNCE, Shimoga

Page 68

Autonomous Pothole filler Robot


right_open();back_mm(40);stop();_delay_ms(50);
}
else
{
back_mm(50);_delay_ms(50);arm_update();_delay_ms(10);
if(value_right>180)
{
right_open();back_mm(40);stop();_delay_ms(50);
}
else
{
back_mm(35);_delay_ms(50);
right_open();back_mm(40);stop();_delay_ms(50)
}
}
if(p<=0 && k<=0)
{servo_1(10);_delay_ms(100);right_open();}
}
void fill_aux_left()
{
back_mm(20);stop();
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i++;arm_update();_delay_ms(10);
if (value_left>180||i>=45)
{
servo_1(i+3);_delay_ms(100);left_fill();break;}
}

// p is

void fill_aux_right()
{
back_mm(20);stop();
for(v=0;v<50;v++)
{
servo_1(i);_delay_ms(100);
i--;arm_update();_delay_ms(10);
if (value_right>180||i<=1){ servo_1(i-3);_delay_ms(100);right_fill();break;}

Dept. of TCE, JNNCE, Shimoga

// p is lesser

Page 69

Autonomous Pothole filler Robot


}
}
//Main Function
int main()
{
init_devices();// initializing ports
lcd_set_4bit();
lcd_init();// initialisinglcd.
turn_off_ir_proxi_sensors();
turn_on_sharp15 ();
while(1)
{
flag1=0;
arm_update();
center_update();
white_update();
if((Center_white_line<0x28) && (Left_white_line<0x28) && (Right_white_line<0x28)
&& flag3==1)
{
stop();
lcd_string("TASK COMPLETED");
buzzer_on ();
_delay_ms(2000);
buzzer_off ();
break;
}
if (value_left<180 &&value_right<180 &&value_aux_right<180
&&value_aux_left<180)
{
print_sensor(1,1,3); //Prints value of White Line Sensor1
print_sensor(1,5,2); //Prints Value of White Line Sensor2
print_sensor(1,9,1); //Prints Value of White Line Sensor3
if(value_center<250)
{
servo_rotate();
}
if(value_center>=250)
{
Dept. of TCE, JNNCE, Shimoga

Page 70

Autonomous Pothole filler Robot


if((Center_white_line>0x28) && (Left_white_line>0x28) &&
(Right_white_line>0x28)&& flag2==1 )
{
while(1)
{
forward();
velocity(225,50);
white_update();_delay_ms(20);
if(Center_white_line<0x28){break;}
}
}
servo_rotate1();
}
}
if ((value_left>=180 || value_right>=180 || value_aux_left>=180 ||
value_aux_right>=180))
{
while(1)
{
servo_1(i);_delay_ms(100);
stop();
if(value_left>=180)
{
left_fill(); break;
}
if(value_right>=180)
{
right_fill(); break;
}
if(value_aux_left>=180)
{
fill_aux_left();break;
}
if(value_aux_right>=180)
{
fill_aux_right();break;
}
else{break;}
}
Dept. of TCE, JNNCE, Shimoga

Page 71

Autonomous Pothole filler Robot


}
if(value_center>=650 && flag2==0 && ShaftCountRight1>28 &&
ShaftCountLeft1>28)
{
u_turn();flag2=1;flag3=1;
}
}
}

Dept. of TCE, JNNCE, Shimoga

Page 72

Autonomous Pothole filler Robot

APPENDIX- B

Dept. of TCE, JNNCE, Shimoga

Page 73

Autonomous Pothole filler Robot

Dept. of TCE, JNNCE, Shimoga

Page 74

Autonomous Pothole filler Robot

Dept. of TCE, JNNCE, Shimoga

Page 75

Autonomous Pothole filler Robot

Dept. of TCE, JNNCE, Shimoga

Page 76

Autonomous Pothole filler Robot

Dept. of TCE, JNNCE, Shimoga

Page 77

You might also like