You are on page 1of 80

A

Project report
on

Jerry : An Intelligent Maze Solving Robot

Submitted to
Shivaji University
in partial fulfilment of degree
Bachelor of Engineering
(Electronics and Telecommunication)

Submitted by
Shantanu V. Kulkarni
Sujay V. Patil
Karan J. Thakkar

Project Advisor: Prof. N. B. Sambre

Department of Electronics and Telecommunication


KIT’s College of Engineering, Kolhapur

i
KIT’s College of Engineering, Kolhapur

CERTIFICATE

This is to certify that

Shantanu V. Kulkarni
Sujay V. Patil
Karan J. Thakkar

have satisfactorily completed the project entitled


”Jerry : An Intelligent Maze Solving Robot”
under my guidance and supervision for the partial fulfilment of
B.E. (Electronics & Telecommunication Engineering) course as per
the rules and regulations of the Shivaji University, Kolhapur
for the year 2011-2012.

Prof. N. B. Sambre Dr. M. M. Mujumdar


Project Guide & Department Head Principal

ii
ACKNOWLEDGEMENT
We would like to take this opportunity to express our deepest gratitude to our Project Supervisor and
Head of Department, Prof. N. B. Sambre who has given us guidance throughout the entire phase of
selection of project and preparation of project. It would have been difficult for us to complete this
project without his guidance and support.

Besides, we would like to thank our family members for giving the spirit along with the supporting
and assisting our project. Their blessings were the main reason why we could handle the obstacles
that we faced.

We would also like to express our deepest gratitude to our friends, especially to all our course mates
who have given us help technically and mentally during the accomplishment of this project. Thank
you all for the technical advices, moral support and ideas to enhance our project. Thank you.

Best Regards

Shantanu V. Kulkarni
Sujay V. Patil
Karan J. Thakkar

iii
MOTIVATION
We have been keen followers of news related to Robotics and Artificial Intelligence. Its while surfing
for such news that we came across Min-7, Ng Beng Kiat’s tiny robot (also known as Micromouse). This
tiny robot which weighed just 90 grams and had dimensions 10cm x 7.5cm x 2.5cm, won the All Japan
Micromouse Contest 2012 in just under 4 seconds! Just imagining the kind of computation power,
the hardware that went behind the building of this robot was enough inspiration for us to choose this
ambitious, yet unique project for our final year.

iv
CONTENTS

1 ABSTRACT 1

2 INTRODUCTION 2

3 RELEVANCE 5

4 HARDWARE 6

4.1 LPC2148 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4.2 3-axis Gyroscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.3 L293D Motor Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.4 ULN2003 as Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4.5 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.5.1 Infrared Transmitters - TSUS4400 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.5.2 Infrared Receivers - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.6 High Speed Quad Encoder Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.7 Power Supply Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.8 Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

v
4.9 Printed Circuit Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.10 Mechanical Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.11 Expenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5 SOFTWARE 32

5.1 Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

5.2 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

5.2.1 Wall following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

5.2.2 Depth-first search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.2.3 Flood-fill algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.3 Simulation and Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

6 LEARNING EXPERIENCE 51

7 REFERENCES 52

8 DATASHEETS 53

vi
LIST OF FIGURES

4.1 Block diagram of LPC 2148 ARM7TDMI Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.2 Breakout board of 3-axis gyroscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.3 LY510ALH Single-axis Pitch Gyroscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.4 LPR510ALH Two-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.5 Three-axis Gyroscope circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.6 Illustration of an H-bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.7 Illustration showing connection of motor to supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4.8 L293D Motor Driver internal block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4.9 L293D Motor Driver circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4.10 ULN2003 Logic Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4.11 ULN2003 used as a buffer to drive IR Transmitters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.12 TSUS4400 IR Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.13 TEFT4300 IR Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.14 Basic circuit using TEFT4300 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.15 Mechanical specifications of the quad encoder motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

vii
4.16 Oscilloscope trace of the gearmotor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.17 Power supply using LM1117 (5 V and 3.3 V) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.18 Internal block diagram of LM1117 Linear Voltage Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.19 Lithium Polymer battery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4.20 Lithium Polymer battery charger with charging current 800 mA . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4.21 Top Layer Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.22 Bottom Layer Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.23 Top Layer component placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.24 Bottom layer component placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.25 Top Layer assembly layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.26 Bottom layer assembly layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.27 Complete PCB Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.28 MAX232 board component placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.29 MAX232 board PCB layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.30 MAX232 board schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

5.1 Process flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

5.2 Example of a maze in which wall-following algorithm does not work . . . . . . . . . . . . . . . . . . . . . . . 33

5.3 Flood-fill position 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.4 Flood-fill position 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

5.5 Flood-fill position 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

5.6 Flood-fill position 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

viii
5.7 Flood-fill position 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5.8 Flood-fill position 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5.9 Flood-fill position 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5.10 Snapshot showing the version of Keil IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

5.11 Snapshot showing PWM simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

ix
Jerry : An Intelligent Maze Solving Robot

Chapter 1

ABSTRACT

The IEEE micromouse competition has been a popular event among engineering students and engineers. A micromouse
is an autonomous vehicle whose objective is to find the centre of an unknown maze. This report summarizes the design
and implementation of the micromouse, Jerry. The design method of the micromouse project consisted of two stages.
The first stage was to design and construct individual system. The second stage of the design process was to interface
the systems to form the final prototype. The individual components of micromouse system consist of the motor control
system, navigation sensor array, and a mapping system or algorithm for navigating the maze intelligently. A 5x5 cell
maze was developed in order to validate the overall performance of the micromouse. As a result of the whole project, the
micromouse will eventually move to the centre of the maze without external help and manage to find the shortest path
from the mapping system after navigating all the possible path in the maze.

1
Jerry : An Intelligent Maze Solving Robot

Chapter 2

INTRODUCTION

Autonomous robotics is a field with wide-reaching applications. From bomb sniffing robots to autonomous devices for
finding humans in wreckage to home automation, many people are interested in low-power, high speed, reliable so-
lutions. There are many problems facing such designs: unfamiliar terrain and inaccurate sensing continue to plague
designers.

Robotics competitions have interested the engineering community for many years. Robots compete on an international
scale hundreds of times a year, in events as varied as the annual MIT robot competition and the BEAM robotics games
in Singapore. One of the competitions with the richest history is the Micromouse competition. In 1977, the IEEE Spec-
trum Magazine first introduced the idea of the autonomous Micromouse robot as a maze solving device. The first IEEE
Amazing Micromouse Maze Contest was held in New York in June 1979. The first world Micromouse competition, open
to contestants from across Europe and the United States, was held in Tsukuba, Japan in August 1985. The Micromouse
competition has existed for almost 20 years in the United States, and even longer in Japan. It has changed little since its
inception.

A Micromouse is a self contained fully autonomous mobile robot, capable of transporting itself to the centre of an un-
known arbitrary two-dimensional maze in accordance with the IEEE regulations. The robot must find its way to the centre
of the maze. Micromouse mazes are typically designed as a lattice of square posts with slots in the sides to accommodate
modular wall units. In order to achieve this several factors must be addressed; motion control, spatial awareness, collision
avoidance, intelligent and precise chassis design. The design and construction of a Micromouse requires a broad range of
engineering skills such as electronics design, mechanical design, program design and how the student approach complex
engineering problems.

Objective

Our objective is to develop an efficient, intelligent, small, autonomous robot to solve an arbitrary maze by finding the
shortest/fastest path to the destination. This seminar report explores the necessary hardware required, starting from
the choice of an appropriate micro-controller to the choice of a battery for power supply. Also included in this report
are a review of some common maze solving algorithms along with the functions(tasks) that will be enveloped in the
programming of the robot. Our design strives to incorporate many of the advances in small scale robotics that have been
explored in 20 years of Micromouse competitions.

Social / Technological Implications

The field of robotics is rapidly becoming one of the leading frontiers in engineering technology. While the emergence of
robotics may appear to have stemmed from development of computer technology, the idea of artificial people has long
fascinated mankind. Computers have only provided a tool for the practical realization of numerous sophisticated systems
required to create an autonomous robot. Fuelled by the rash of movies, television programs, and books about robots
popularized in the mid-twentieth century, people at the time expected robots to become a regular part of their lives in
positions such as domestic workers, store clerks, bankers, and the like by the end of the millennium. The progress of the

2
Jerry : An Intelligent Maze Solving Robot

field has occurred at a slower pace than perhaps was initially expected, but robotics is now at the forefront of technology.
Robots offer us effective solutions for many global problems, and they are now coming to pervade more and more aspects
of our daily lives.

Robots are currently being utilized in many different manufacturing and industrial applications. They are often used for
work considered to be too dangerous or difficult for human workers. Robots are also able to perform repetitive tasks
that are tedious for humans with great precision and accuracy. For example, automobile manufacturers commonly use
robots for welding and painting applications, semiconductor companies use robots for inserting integrated circuits onto
printed circuit boards and soldering chips, etc. In addition, manufacturing companies often use computer-aided design
(CAD), computer-aided manufacturing (CAM), and computer numerical control (CNC) machines to produce designs,
make components and assemble machines. This technology allows engineers to design a component using CAD and
then quickly manufacture the design using robot-controlled equipment. Robots help to raise the overall profit margin
of companies due to increase in productivity and higher quality products, savings which can then be passed onto con-
sumers.

Medical robots are ideal for various diagnostic testing and surgery applications. For instance, laboratory testing is often a
manual task requiring analyst to examine a sample under a microscope for abnormal conditions. This procedure is well-
suited to robot automation. Surgeons use robots to perform delicate surgeries that were once considered impossible. In
the future, researchers hope to use nanotechnology to create microscopic robots that are injected into human beings to
perform actions such as removing fatty deposits from blocked arteries and destroying cancerous cells in tumours.

Another vast area of research and development is robot-based space exploration. The National Aeronautics and Space
research Administration (NASA) arguably has the most sophisticated robotics program in the world today. NASA often
sends unmanned robot explorers on missions impossible for human explorers to accomplish. In addition to the risk
involved with sending a human being into outer space, humans also require a substantial support system for their space
travel, including breathable atmosphere, food and water, heat living accommodations. Robots on the other hand, require
far less support and can be abandoned if necessary.

Robots are particularly useful for performing hazardous duty services. They can easily perform hazardous work without
risking human life or limb. For instance, they are used in many bomb squads around the country. Resembling small
armoured tanks, these robots are usually guided remotely by personnel using video cameras attached to the front of the
robot. Similar robots can also help with handling or cleaning up toxic waste. they can work unimpeded in all types of
polluted chemical environments, including ones dangerous in which unprotected human being would quickly die. In
fact the nuclear industry was the first to develop and use robotic arms for handling radioactive materials. Currently,
there is research being done in developing fire-fighting robots that can detect a fire anywhere in a building, travel to the
location, and put out the fire.

In addition, robots are becoming increasingly indispensable in war and weaponry. Defence Services around the world are
developing sophisticated robotics programs to keep watch on enemies and help ensure their victory if the need for war
should arise. In modern warfare, drone aircraft tracks enemy movements and keeps the enemy under close surveillance.
Other examples of intelligent weaponry are ”smart” bombs and cruise missiles.

There are also many different applications for domestic robots. While labour-saving devices such as washing machines,
clothes dryers, dishwashers, ovens, and the like have been computerized for some time now, most people would not
characterize them as robots but rather as machines since they do not autonomously gather the materials they need to
perform their functions. Although it may be a while yet before we all have ”Rosie the Robot” maids to perform various
household duties, current research in the development of domestic robots is in the area of greater automation.

The social impacts of robots are significant and varied. While there are some obvious and indisputable advantages to
using robots for performing certain functions or duties, there are also considerable ethical concerns involved with their
other uses or misuses. As with the advent of any new technology, there are fears of domination by the technology we
created. Specifically, there are concerns that the advanced development of robots may be used to do harm to human
beings. Considering all the robotics war and weaponry applications, these fears are perhaps not unfounded. It is also true
that many humans have already been and will continue be replaced by human in certain jobs.

Many also question the right of scientists and engineers to ”play god” and attempt to create autonomous robots that
have the ability to reproduce and exist outside of human control, or even to make humanoid robots in man’s image.
Some people are wary of the possibility of robots having anthropomorphic traits and real human emotions. Clearly, the

3
Jerry : An Intelligent Maze Solving Robot

assimilation of humanoid robots into our everyday lives and interactions may take some time. Non-humanoid robots,
on the other hand, may gain acceptance more easily since, according to definition, robots are already all around us in
washing machines and other automated machines and devices. Looking back in history, we see computers were initially
looked upon with great suspicion, but are now almost universally accepted for ordinary applications.

Thus, the social implications of robots involve a complex interplay of their payable benefits to mankind and the substan-
tial ethical concerns associated with their rapidly increasing sophistication. The question of whether robots can provide
some good to humanity ozone as old as technology itself. There always have been doubts and questions raised when new
technologies have been introduced. At this stage, it is uncertain if engineers will ever be able to develop robots to the
point that some people fear. Nevertheless, given the current level of research in robotics, one point is clear: robots will be
a force to reckon with in the future.

4
Jerry : An Intelligent Maze Solving Robot

Chapter 3

RELEVANCE

The real beauty of our project lies in the fact that we are actually implanting intelligence into a machine. The fact that
our Micromouse can identify obstacles, show spatial awareness, scan and find the shortest path to the centre of any
arbitrary maze justifies the fact that it actually has intelligence. This idea of a robot/machine to traverse unknown terrains
autonomously can be used for a variety of real time applications:

1. Bomb Sniffing: It can be of use to bomb squads to identify the location of the bomb by traversing a target area and
identifying anything suspicious.
2. Home Automation: It can be used in a variety of purposes at home such as an automatic vacuum cleaner, automatic
ironing machine, automatic vessel arranging machine, etc.
3. Finding Humans in Wreckage due to earthquakes and other natural or man-made hazards
4. It can be used for spying a target area and sending real time imagery.

5
Jerry : An Intelligent Maze Solving Robot

Chapter 4

HARDWARE

4.1 LPC2148

The LPC2148 Microcontrollers, developed and manufactured by NXP, a subsidiary company of Philips, are based on
32/16 bit ARM7TDMI-S CPU with real time emulation and embedded trace support that combines the microcontroller
with embedded high speed memory range from 32kb to 512kb.

Due to its tiny size and low power consumption, LPC2148 is ideal for applications where miniaturization is a key
requirement, such as access control and point-of-sale. Various 32-bit timers, single or dual 10-bit ADC(s), 10-bit
DAC, PWM channels and 45 fast GPIO lines with up to nine edge or level sensitive external interrupt pins make these
microcontrollers particularly suitable for industrial control and medical systems.

Why LPC2148?

Choosing the right microcontroller for this application was a challenging task for us. Our system is battery powered.
Being an efficient embedded system, it needs to keep the power consumption to the minimum possible level which
clearly justifies the need of advanced ARM core microcontroller. After analysing the requirement of resources for our
system, we reached to the conclusion that LPC2148 will be the best choice. We needed more than 8 ADC channels, 2
PWM outputs, 4 Capture modules and so on. LPC2148 fulfils all the requirements of our system.

Apart from the features mentioned above, LPC2148 is In-System and In-Application programmable which helped us a
lot in developing the source code for our system. We could best use this feature because of the fact that we chose to go
for modular programming. We developed all the modules separately, flashed it on the controller time to time, tested the
functionality, made the necessary changes and developed the final program by clubbing together all these modules.

6
Jerry : An Intelligent Maze Solving Robot

Figure 4.1: Block diagram of LPC 2148 ARM7TDMI Microcontroller

7
Jerry : An Intelligent Maze Solving Robot

Features

• 16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.


• 8 to 40 kB of on-chip static RAM and 32 to 512 kB of on-chip flash program memory.
• 128 bit wide interface/accelerator enables high speed 60 MHz operation.

• In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader software.


• Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1 ms.
• EmbeddedICE RT and Embedded Trace interfaces offer real-time debugging with the on-chip RealMonitor software
and high speed tracing of instruction execution.

• USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM.
• In addition, the LPC2146/8 provide 8 kB of on-chip RAM accessible to USB by DMA.
• One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total of 6/14 analog inputs, with conver-
sion times as low as 2.44 s per channel.

• Single 10-bit D/A converter provides variable analog output.


• Two 32-bit timers/external event counters (with four capture and four compare channels each), PWM unit (six out-
puts) and watchdog.
• Low power real-time clock with independent power and dedicated 32 kHz clock input.

• Multiple serial interfaces including two UARTs (16C550), two Fast I2 C-bus (400 kbit/s), SPI and SSP with buffering
and variable data length capabilities.
• Vectored interrupt controller with configurable priorities and vector addresses.

• Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.


• Up to nine edge or level sensitive external interrupt pins available
• 60 MHz maximum CPU clock available from programmable on-chip PLL with settling time of 100 µs.
• On-chip integrated oscillator operates with an external crystal in range from 1 MHz to 30 MHz and with an external
oscillator up to 50 MHz.
• Power saving modes include Idle and Power-down.
• Individual enable/disable of peripheral functions as well as peripheral clock scaling for additional power optimiza-
tion.

• Processor wake-up from Power-down mode via external interrupt, USB, Brown-Out Detect (BOD) or Real-Time
Clock (RTC).
• Single power supply chip with Power-On Reset (POR) and BOD circuits:
• CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O pads.

8
Jerry : An Intelligent Maze Solving Robot

4.2 3-axis Gyroscope

Figure 4.2: Breakout board of 3-axis gyroscope

Figure 4.3: LY510ALH Single-axis Pitch Gyroscope

9
Jerry : An Intelligent Maze Solving Robot

Figure 4.4: LPR510ALH Two-axis

Specifications

1. Gyroscopes: LY510 and LPR510


2. Supply voltage (Vdd): 2.7 V to 3.6 V, 5 mA
3. Sensitivity on the yaw, pitch or roll rate output pin 4xOUT (4 times amplified output): 3.33 mV/degrees/ sec (± 100
degrees/ sec)

4. Sensitivity on the yaw, pitch or roll rate output pin OUT: 0.83mV/degrees/sec (± 400 degrees/sec)
5. Steady state position output: OUT : 1.23V (± 10%) 4xOUT : 1.23V (± 10%)
6. Bandwidth: 140 Hz

7. Self-Test checking for checking chip functionality


8. Power-down option

The gyroscope module used in the project uses a yaw rate MEMS (Micro Electro Mechanical System) gyro chip developed
by ST Microelectronics. The LY510ALH is a low-power single-axis micromachined gyroscope capable of measuring
angular rate along yaw axis (i.e along the axis perpendicular to ground).

The very purpose of using this gyro module is to measure the absolute angle of rotation of Jerry with respect to its starting
direction so as to keep the track of directions and update wall map without errors.

10
Jerry : An Intelligent Maze Solving Robot

Pin Configuration
Pin Number Pin Name Analog Function
1 4xOUTZ Yaw-rate or Z-rate output voltage 4 times amplified (± 100 /sec)
2 OUTZ Yaw-rate or Z-rate output voltage (± 400 /sec)
3 ST Self-test (logic 0: normal mode; logic 1: self-test) for Yaw Gyroscope
4 PD Power-down(logic 0: normal mode; logic 1: Power-down mode) for Yaw Gyroscope
5 HP High pass filter reset(logic 0: normal mode; logic 1: external high pass filter is reset) for
Yaw Gyroscope
6 NC Not connected
7 GND Supply Ground
8 NC Not connected
9 NC Not connected
10 Vref Vref output from the Yaw Gyroscope IC. (Leave unconnected)
11 OUTY Roll-Rate or Y-rate output voltage (± 400 /sec)
12 4xOUTY Roll-rate or Y-rate output voltage 4 times amplified (± 100 /sec)
13 4xOUTX Pitch-rate or X-rate output voltage 4 times amplified (± 100 /sec)
14 OUTX Pitch-rate or X-rate output voltage (± 400 /sec)
15 ST Self-test (logic 0: normal mode; logic 1: self-test) for Pitch and Roll Gyroscope
16 PD Power-down(logic 0: normal mode; logic 1: Power-down mode) Pitch and Roll Gyroscope
17 HP High pass filter reset(logic 0: normal mode; logic 1: external high pass filter is reset) Pitch
and Roll Gyroscope
18 Vdd 3.3V supply voltage
19 Vref Vref output from the Pitch and Roll Gyroscope IC. (Leave unconnected)
20 NC Not connected
21 NC Not connected
22 Vref Vref output from the IC. (Leave unconnected)
23 NC Not connected
24 NC Not connected

Figure 4.5: Three-axis Gyroscope circuit diagram

11
Jerry : An Intelligent Maze Solving Robot

4.3 L293D Motor Driver

Specifications

1. 600 mA Output current capability per channel

2. 1.2 A peak output current (non repetitive) per channel


3. Enable facility
4. Overtemperature Protection
5. Logical ”0” input voltage up to 1.5 V (High Noise Immunity)

6. Internal clamp diodes

Motor driver L293D is a simple electronic quadruple H-bridge which allows controlling the direction of rotation of motor.
To interface the motor with microcontroller, H-Bridge is a preferred way usually. The name ”H-Bridge” is derived from
the actual shape of the switching circuit which controls the motion of the motor. It is also known as ”Full Bridge” as it has
four switching elements as shown in figure 4.6

Figure 4.6: Illustration of an H-bridge

As you can see in the figure, there are four switching elements names as ”High Side Left, High Side Right, Low Side Left
and Low Side Right”. When these switches are turned ON in pair, motor starts rotating in some direction. When the other
pair of switches is turned ON, the motor rotates in opposite direction. If we switch on High Side Left and Low Side Right,
the motor will rotate in forward direction (say) as the current flows from positive terminal of a motor to negative and then
ground as shown in figure 4.7

12
Jerry : An Intelligent Maze Solving Robot

Figure 4.7: Illustration showing connection of motor to supply

Similarly when we switch on LOW Side Left and High Side Right, motor rotates in opposite direction as that of the first
case (Say reverse). This is because now current flow is from negative of motor to positive and then ground.

Figure 4.8: L293D Motor Driver internal block diagram

13
Jerry : An Intelligent Maze Solving Robot

Figure 4.9: L293D Motor Driver circuit diagram

14
Jerry : An Intelligent Maze Solving Robot

4.4 ULN2003 as Buffer

Specifications

1. 500 mA rated Collector Current (Single Output)


2. High-Voltage Outputs - 50 V
3. Output Clamp Diodes

4. Inputs Compatible With Various Types of Logic


5. Relay-Driver Applications

Figure 4.10: ULN2003 Logic Diagram

15
16
Figure 4.11: ULN2003 used as a buffer to drive IR Transmitters
Jerry : An Intelligent Maze Solving Robot
Jerry : An Intelligent Maze Solving Robot

4.5 Sensors

IR Transmitter and Receiver pairs are used as proximity sensors which detect the presence of walls around. IR transmit-
ters are clocked from GPIO pins of LPC2148. Left and Right sensors are triggered simultaneously at one instance whereas
LeftFront and RightFront are triggered simultaneously at another instance. This way, we avoid the IR transmitter inter-
ference. The remaining pair of left and right diagonal transmitters receivers is kept for the future use wherein alignment
errors can be corrected and the robots smooth movement can be ensured.
IR Receivers are connected to ADC channels of microcontroller and depending on the received voltages; prediction of
distance of walls from Jerry is made. It gives Jerry the capability of turning and stopping at right time when it reaches
exactly at the centre of the cell.
The maximum range of IR Transmitter-Receiver is about 15 cm.

4.5.1 Infrared Transmitters - TSUS4400

Features

1. Low forward voltage


2. High radiant power and radiant intensity
3. Suitable for DC and high pulse current operation

4. Standard T1(φ 3 mm) package


5. Angle of half intensity ϕ = ± 18◦
6. Peak wavelength λp = 950 nm

7. High reliability

Figure 4.12: TSUS4400 IR Transmitter

Please refer figure 4.11 on page 16 for the connection diagram of the IR Transmitters. These IR Transmitters from Vishay
Semiconductors are preferred over locally available IR Transmitters because they are spectrally matched to the IR Receiver
TEFT4300 we have used. The matching reduces the noise and ambient light thereby increasing the efficiency of overall
system. The receiver is explained in the section 4.5.2.

17
Jerry : An Intelligent Maze Solving Robot

4.5.2 Infrared Receivers -

Figure 4.13: TEFT4300 IR Receiver

Figure 4.14: Basic circuit using TEFT4300

Features

1. High radiant sensitivity


2. Fast response times
3. T1 (ϕ 3 mm) plastic package with IR filter

4. Additional polarity sign


5. Wide viewing angle φ = ± 30 ◦
6. Suitable for near infrared radiation

7. Matches with TSUS4400 GaAs infrared emitter

18
Jerry : An Intelligent Maze Solving Robot

4.6 High Speed Quad Encoder Motors

Features

1. Operating Voltages: 3 V - 24 V DC
2. Load current: 660 mA max

3. Speed: 9200 rpm @ 8VDC


4. Weight: 25 grams
5. Shaft length: 4 mm
6. Shaft Diameter: 1 mm

7. Motor Diameter: 16 mm
8. Motor Length: 34 mm
9. Stall Torque: 12.1 mNm

10. Continuous torque: 5.3 mNm


11. Max Angular Acceleration: 265000 rad/sec2
12. Power Rating: 5 Watts
13. Resolution: 512 pulses per revolution

14. 6 pin Interface: Motor +, +5V, Encoder A, Encoder B, GND, Motor-

Figure 4.15: Mechanical specifications of the quad encoder motor

19
Jerry : An Intelligent Maze Solving Robot

The encoder is connected via a 6 wire FRC. The pinout is:

1. Motor positive. Connect to GND or 3 V to 9 V. Pin 1 is nearest the side of the ribbon cable with the red color.
2. Encoder Vcc. Connect to 5V.
3. Channel A digital output. Pulled up to Vcc through a 10 kilohm resistor. Switches between GND and Vcc.
4. Channel B digital output. Pulled up to Vcc through a 10 kilohm resistor. Switches between GND and Vcc.

5. Encoder GND.
6. Motor negative. Connect to GND or 3 V to 9 V.

The encoder and motor were tested by connecting 5 V to pins 1 and 2. GND was connected to pins 5 and 6. Channels A
and B (pins 3 and 4) output digital square waves in the standard quadrature (2-bit graycode) format as shown in the figure
4.16. External pull-up resistors are not required because they are built into the encoder.

Figure 4.16: Oscilloscope trace of the gearmotor two-channel encoder output. The edges are clean and sharp. Zooming
in shows the rise time.

The output of the encoder is very clean. However, to avoid errors due to glitches or to measure rotation direction, the
microcontroller can watch both channels A and B.

20
Jerry : An Intelligent Maze Solving Robot

4.7 Power Supply Unit

Figure 4.17: Power supply using LM1117 (5 V and 3.3 V)


[Note: The Jumper in the circuit diagram is used to separate Analogue Ground (AGND) and Digital Ground (DGND)]

Figure 4.18: Internal block diagram of LM1117 Linear Voltage Regulator

The power supply for the above circuit will be provided from a 3-cell, 11.1 V, 720 mAh, 20C high discharge Lithium Poly-
mer Battery shown in the figure 4.19.

21
Jerry : An Intelligent Maze Solving Robot

Figure 4.19: Lithium Polymer battery

Figure 4.20: Lithium Polymer battery charger with charging


current 800 mA

22
Jerry : An Intelligent Maze Solving Robot

4.8 Schematic

Note: This schematic is prepared using open source PCB Design software KiCad. It is prepared on an A2 size paper. A
magnified view of the schematic is attached at the end of the report.

23
Jerry : An Intelligent Maze Solving Robot

4.9 Printed Circuit Board

To keep the size of the robot very small and to utilize all the PCB space efficiently, we decided to go for double sided plated
through-hole (PTH) PCB. This PCB itself serves as the body of our robot eliminating the need of chassis, which would have
added an extra weight to the robot otherwise. It uses a glass epoxy type of copper clad which gives the added strength to
the PCB. The PCB is designed in OrCAD Layout. Following figures show the PCB Layout & Component Placement.

Figure 4.21: Top Layer Layout Figure 4.22: Bottom Layer Layout

24
Jerry : An Intelligent Maze Solving Robot

Figure 4.23: Top Layer component placement Figure 4.24: Bottom layer component placement

Figure 4.25: Top Layer assembly layout Figure 4.26: Bottom layer assembly layout

25
Jerry : An Intelligent Maze Solving Robot

Figure 4.27: Complete PCB Layout

26
Jerry : An Intelligent Maze Solving Robot

On the main PC Board, we decided not to keep the programming circuit unnecessarily. We went for a custom home made
PCB, designed using KiCAD’s PCB designing tool, PCBnew, and manufactured using Toner Transfer method. This is a
single layer PCB. Figure 4.28 and Figure 4.29 show the component placement and layout for the same.

Figure 4.28: MAX232 board component placement Figure 4.29: MAX232 board PCB layout

This board has the capability of software RESET using hand shaking signals, DTR and RTS. These signals are derived from
pin numbers 4 and 7 respectively of RS232 interface. See schematic in figure 4.30

27
Jerry : An Intelligent Maze Solving Robot

Figure 4.30: MAX232 board schematic

28
Jerry : An Intelligent Maze Solving Robot

4.10 Mechanical Design

As the double sided PTH board acted as the body, there was no need for construction of a mechanical chassis. However,
we had to make two brackets to fix the motor into. Following are some figures that show the entire setup of our robot.

29
Jerry : An Intelligent Maze Solving Robot

30
Jerry : An Intelligent Maze Solving Robot

4.11 Expenses

Sr. No. Component Name Cost (INR)

1 Phototransistor (TEFT4300) 468


2 IT Emitter (TSUS4400) 260
3 3-axis Analog Gyroscope Module 1600
4 High Precision Quad Encoder DC Motor 3600
5 Double sided PTH Printed Circuit Board 5500
6 LPC2148 Microcontroller 480
7 LM1117-3.3 V SOT-223 226
8 LM1117-5 V SOT-223 226
9 Isopropyl Alcohol 150
10 Aluminium Brackets 200
11 5 x 5 Maze 2000
12 Miscellaneous components (Resistors, capacitors, etc.) 1156

Total 15866

Online and local stores from where electronic components have been bought:

• Kavita Electronics, Kolhapur

• Kishor Electronics, Kolhapur


• Nex-Robotics Pvt. Ltd., Mumbai [ www.nex-robotics.com ]
• element14, Singapore [ www.kitsnspares.com/element14/ ]

31
Jerry : An Intelligent Maze Solving Robot

Chapter 5

SOFTWARE

5.1 Flowchart

Figure 5.1: Process flow

32
Jerry : An Intelligent Maze Solving Robot

The primary purpose of the software is to maintain control over the hardware at all times and determine where to move
by solving the maze(see figure 5.1). Controlling the hardware consists of reading the sensors, setting the motor speed and
communicating with any external peripherals. Since each of the motor speeds are controlled independently, alignment
corrections can be made by increasing or decreasing the speed of a single motor.

In addition to controlling the hardware, software must also keep track of the current position within the maze and deter-
mine where to move based on the selected algorithm.

5.2 Algorithm

The principal goal of Jerry is to solve the maze and find the center as quickly as possible. To accomplish this task, Jerry
uses a particular searching algorithm.

A vast amount of research on searching techniques already exists and is currently being undertaken.

Mathematicians in the fields of topology and graph theory have been studying maze creation and maze solving algorithms
for several centuries. However, the algorithms they have developed are not feasible for these applications due to memory
and speed limitations of most micromouse controllers. As a result, micromouse robots generally use some variation of
the following three searching algorithms:

1. Wall following

2. Depth-First Search
3. Flood-fill

5.2.1 Wall following

Figure 5.2: Example of a maze in which wall-following algorithm does not work

Wall following is a trivial algorithm in which the mouse chooses a wall, either left or right, then always keeps the chosen
wall on its side as it moves through the maze. The algorithm is very simple to implement in code, but unfortunately it is
inefficient and does not work for IEEE mazes because they are specifically designed to prevent such wall-following mice
from succeeding. For instance the maze in figure 5.2 is an example of a maze in which a left wall-following mouse would
end up circling the outer perimeter and never travel further into the maze.

33
Jerry : An Intelligent Maze Solving Robot

5.2.2 Depth-first search

Depth-first search is an intuitive algorithm for searching a maze in which the mouse first starts moving forward and
randomly chooses a path when it comes to an intersection. If that path leads to a dead end, the mouse returns to
the intersection and choose another path. This algorithm forces the mouse to explore each possible path within the
maze, and by exploring every cell, the mouse eventually finds the center. It’s called ”depth-first” because if the maze
is considered a spanning tree, the full depth of one branch is searched before moving onto the next branch. The
relative advantage of this method is that the micromouse always a route. Unfortunately, the major drawback is that
the mouse does not necessarily find the shortest or quickest route, and it wastes too much time exploring the entire maze.

5.2.3 Flood-fill algorithm

Flood-fill algorithm is a heuristic search technique wherein the mouse learns about its surroundings as it navigates
through the maze and constantly updates its memory map to keep track of the walls and the shortest path. The flood-fill
algorithm involves assigning values to each of the cells in the maze where these values represent the distance from any
cell on the maze to the destination cell. The destination cell, therefore, is assigned a value of 0. If the mouse is standing
in a cell with a value of 1, it is 1 cell away from the goal. If the mouse is standing in a cell with a value of 3, it is 3 cells away
from the goal. Assuming the robot cannot move diagonally, the values for a 5X5 maze without walls would look like Figure
5.3.

Figure 5.3: Flood-fill position 1

Of course for a full sized maze, you would have 16 rows by 16 columns = 256 cell values. Therefore you would need 256
bytes to store the distance values for a complete maze.

When it comes time to make a move, the robot must examine all adjacent cells which are not separated by walls and
choose the one with the lowest distance value. In our example above, the mouse would ignore any cell to the West
because there is a wall, and it would look at the distance values of the cells to the North, East and South since those are
not separated by walls. The cell to the North has a value of 2, the cell to the East has a value of 2 and the cell to the South
has a value of 4. The routine sorts the values to determine which cell has the lowest distance value. It turns out that
both the North and East cells have a distance value of 2. That means that the mouse can go North or East and traverse
the same number of cells on its way to the destination cell. Since turning would take time, the mouse will choose to go
forward to the North cell. So the decision process would be something like this:

Decide which neighbouring cell has the lowest distance value.

Is the cell to the North separated by a wall?


Yes -> Ignore the North cell
No -> Push the North cell onto the stack to be examined

34
Jerry : An Intelligent Maze Solving Robot

continued . . .

Is the cell to the East separated by a wall?


Yes -> Ignore the East cell
No -> Push the East cell onto the stack to be examined

Is the cell to the South separated by a wall?


Yes -> Ignore the South cell
No -> Push the South cell onto the stack to be examined

Is the cell to the West separated by a wall?


Yes -> Ignore the West cell
No -> Push the West cell onto the stack to be examined

Pull all of the cells from the stack (The stack is now empty)
Sort the cells to determine which has the lowest distance value

Move to the neighbouring cell with the lowest distance value.

Now the mouse has a way of getting to centre in a maze with no walls. But real mazes have walls and these walls will affect
the distance values in the maze so we need to keep track of them. Again, there are 256 cells in a real maze so another
256 bytes will be more than sufficient to keep track of the walls. There are 8 bits in the byte for a cell. The first 4 bits can
represent the walls leaving you with another 4 bits for your own use. A typical cell byte can look like this:

Bit Number 7 6 5 4 3 2 1 0
Wall - - - - W S E N

Remember that every interior wall is shared by two cells so when you update the wall value for one cell you can
update the wall value for its neighbour as well. The instructions for updating the wall map can look something like this:

Update the wall map:

Is the cell to the North separated by a wall?


Yes -> Turn on the "North" bit for the cell we are standing on and
Turn on the "South" bit for the cell to the North
No -> Do nothing

Is the cell to the East separated by a wall?


Yes -> Turn on the "East" bit for the cell we are standing on and
Turn on the "West" bit for the cell to the East
No -> Do nothing

Is the cell to the South separated by a wall?


Yes -> Turn on the "South" bit for the cell we are standing on and
Turn on the "North" bit for the cell to the South
No -> Do nothing

Is the cell to the West separated by a wall?


Yes -> Turn on the "West" bit for the cell we are standing on and
Turn on the "East" bit for the cell to the West
No -> Do nothing

35
Jerry : An Intelligent Maze Solving Robot

So now we have a way of keeping track of the walls the mouse finds as it moves about the maze. But as new walls are found,
the distance values of the cells are affected so we need a way of updating those. Returning to our example, suppose the
mouse has found a wall.

Figure 5.4: Flood-fill position 2

We cannot go West and we cannot go East, we can only travel North or South. But going North or South means going up
in distance values which we do not want to do. So we need to update the cell values as a result of finding this new wall. To
do this we “flood” the maze with new values. As an example of flooding the maze, let’s say that our mouse has wandered
around and found a few more walls. The routine would start by initializing the array holding the distance values and
assigning a value of 0 to the destination cell:

Figure 5.5: Flood-fill position 3

The routine then takes any open neighbours (that is, neighbours which are not separated by a wall) and assigns the next
highest value, 1:

Figure 5.6: Flood-fill position 4

The routine again finds the open neighbours and assigns the next highest value, 2:

36
Jerry : An Intelligent Maze Solving Robot

Figure 5.7: Flood-fill position 5

A few more iterations:

Figure 5.8: Flood-fill position 6

This is repeated as many times as necessary until all of the cells have a value:

Figure 5.9: Flood-fill position 7

Notice how the values lead the mouse from the start cell to the destination cell through the shortest path. The instructions
for flooding the maze with distance values could be:
Flood the maze with new distance values:

Let variable Level = 0


Initialize the array DistanceValue so that all values = 255
Place the destination cell in an array called CurrentLevel
Initialize a second array called NextLevel
Begin:
Repeat the following instructions until CurrentLevel is empty:
{
Remove a cell from CurrentLevel
If DistanceValue(cell) = 255 then
let DistanceValue(cell) = Level and
place all open neighbors of cell into NextLevel
End If
}

37
Jerry : An Intelligent Maze Solving Robot

continued . . .

The array CurrentLevel is now empty.

Is the array NextLevel empty?


No ->

continued . . .

{
Level = Level +1,
Let CurrentLevel = NextLevel,
Initialize NextLevel,
Go back to "Begin:"
}

Yes -> You’re done flooding the maze\\

The flood-fill algorithm is a good way of finding the shortest (if not the fastest) path from the start cell to the destination
cells. You will need 512 bytes of RAM to implement the routine: one 256 byte array for the distance values and one 256
array to store the map of walls.

Every time the mouse arrives in a cell it will perform the following steps:

1. Update the wall map


2. Flood the maze with new distance values
3. Decide which neighboring cell has the lowest distance value
4. Move to the neighboring cell with the lowest distance value
Flood-fill is called a ”breadth-first” algorithm because, if the maze is considered to be a spanning tree, an entire level is
searched before exploring the whole depth of a particular branch. The major advantage of the flood-fill algorithm is that it
always finds the shortest path to the center of the maze. It is important to note that the shortest path is not necessarily the
quickest path since a path filled with turns will take longer time to traverse than one primarily composed of forward-going
moves. The relative disadvantage of this algorithm is that more memory is required for execution.

5.3 Simulation and Testing

We have used Keil Vision4 IDE developed by ARM for developing, compiling, testing and simulation. Keil Vision 4 is the
package which includes C/C++ compilers, debuggers, integrated environments, RTOS, simulation models includes sup-
port for evaluation boards for ARM, Cortex-M, Cortex-R, 8051, C166 and 251 processor families. We have used modular
programming technique so as to make it easier for us to test different modules used in our project. The codes for different
modules are shown on page 41

38
Jerry : An Intelligent Maze Solving Robot

Figure 5.10: Snapshot showing the version of Keil IDE

39
40
Figure 5.11: Snapshot showing PWM simulation
Jerry : An Intelligent Maze Solving Robot
Jerry : An Intelligent Maze Solving Robot

Port Configuration Header file


# define LM ENCA 18 // Port0
# define LM ENCB 17 // Port0
# define RM ENCA 29 // Port0
# define RM ENCB 28 // Port0
# define LMDir 10 // Port0
# define RMDir 11 // Port0

# define LeftTx 21 // Port1


# define RightTx 20 // Port1
# define LfrontTx 17 // Port1
# define RfrontTx 16 // Port1

# define LeftRx 13 // Port0


# define RightRx 12 // Port0
# define LfrontRx 21 // Port0
# define RfrontRx 22 // Port0

# define Buzzer 31 // Port1


# define ModeSel 2 // Port0

# define GyroOut 5 // Port0


# define GyroOut4X 4 // Port0

Main Program
/∗∗∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗
Programming f o r ” J e r r y : An I n t e l l i g e n t Maze S o l v i n g Robot ” using LPC2148 M i c r o c o n t r o l l e r
Programs w r i t t e n by
Shantanu Vivek K u l k a r n i [ 3 0 ]
Sujay Vasantrao P a t i l [47]
Karan J i t e n d r a Thakkar [ 5 9 ]

BE E&TC a t KIT ’ s C o l l e g e o f Engineering

Under the Guidance o f −> Mr . N. B Sambre s i r


∗∗∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗/

/∗∗∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗
Clock S e t t i n g s :
FOSC >> 12MHz ( onboard )
PLL >> M=5 , P=2
CCLK >> 60MHz
PCLK >> 15MHz

∗∗∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗∗ ∗∗∗ ∗∗∗ ∗∗∗ ∗/

# include<lpc21xx . h>
# inclu de <PortConfig . h>

double RMCount ;
double LMCount ;
long IRfrontValLeft IRfrontValRight ;
void main ( )
{

41
Jerry : An Intelligent Maze Solving Robot

PINSEL0 = 0xCF0A3000 ; // PWM4 ( P0 . 0 8 ) & PWM6 ( 0 . 0 9 )


PINSEL1 = 0x0A001814 ; // Capture 1 . 2 &1.3 ( P0 . 1 7 , P0 . 1 8 )
PINSEL2 = 0 x00000000 ; // and Capture 0 . 2 & 0 . 3 ( P0 . 2 8 , P0 . 2 9 )
IODIR0 = 0xffffffff ;
IODIR0 |=(0 < <2) | (0<<3) | (0<<4) | (0 < <5);
// Pins 0 . 2 thro 0 . 5 are Input , Rest output
IODIR1 = 0xffffffff ; // Port1 Output

b i t modeTemp ;

while ( 1 )
{
modeTemp = mode ( ) ;

switch (modeTemp)
{
case 0 :
ScanMode ( ) ;
break ;

case 1 :
RunMode ( ) ;
break ;
}
}
}

Flood-fill Algorithm
# include<lpc21xx . h>

# define NORTH 1
# define EAST 2
# define SOUTH 4
# define WEST 8
# define VISITED 16
# define ONROUTE 32

# define NOTNORTH (24−NORTH)


# define NOTEAST (24−EAST )
# define NOTSOUTH (24−SOUTH)
# define NOTWEST (24−WEST)
# define ALLWALLS (NORTH| EAST |SOUTH|WEST)

// maze s t o r a g e
# d e f i n e NUMCELLS 25
e x t e r n CELL maze [NUMCELLS] ;
e x t e r n CELL map[NUMCELLS ] ;

/∗
floodMaze s o l v e s the maze using w a l l data found in the a r r a y maze
and p l a c e s the f l o o d i n g data − e f f e c t i v e l y the routemap − i n t o
the a r r a y map . The d e s t i n a t i o n c e l l i s passed in to the f u n c t i o n

42
Jerry : An Intelligent Maze Solving Robot

to allow s o l v i n g f o r any l o c a t i o n .
The s t a t e o f map on e n t r y i s not important and i t i s not important
whether a l l the w a l l s have been found . The algorithm simply performs
the f l o o d based on what i t knows a t the time i t i s c a l l e d .
At worst , up to 24 passes are made through the maze date in g e n e r a t i n g
the map . I f t h a t many passes are made , t h e r e has been an e r r o r and
the maze should be considered to be s e r i o u s l y in e r r o r .
Passes o f the algorithm are made u n t i l e i t h e r the l i m i t has been reached
or the change f l a g i n d i c a t e s t h a t none o f the map data has changed in
t h a t pass . At t h a t point the maze can be considered to have been solved .
C l e a r l y , u n l e s s a l l the w a l l s have been observed , the map w i l l contain
i n v a l i d paths . The mouse w i l l d i s c o v e r new w a l l s and c a l l the s o l v e r again
as needed .
The f u n c t i o n r e t u r n s the number o f passes r e q u i r e d to s o l v e the maze .
A returned value o f 25 i n d i c a t e s an e r r o r .
Note t h a t the a r r a y i s allowed to wrap around in a most dangerous
manner by r e l y i n g on the 8 b i t p o i n t e r .
This should not be a r e a l problem in as much as the e x i s t e n c e o f the outer
w a l l s means we never have to make use o f the value
∗/

unsigned char floodMaze ( char g o a l )


{
unsigned char i , j ;
unsigned char now , next ;
unsigned char passes ;
unsigned char c e l l w a l l s ; // the w a l l data f o r a given c e l l
unsigned char changed ;

i = 0;
do{
map[ i −−] = 2 5 ;
} while ( i ) ;

map[ g o a l ] = 0 ;
passes = 0 ;
now = 0 ;
next = now+ 1 ;
do
{
changed = 0 ;
i = 0;
do
{
i f (map[ i ]==now)
{
c e l l w a l l s =maze [ i ] ;
i f ( ( c e l l w a l l s & NORTH) == 0 )
{
j = i +1;
i f (map[ j ] == 25){ map[ j ] = next ; changed = 1 ; }
}
i f ( ( c e l l w a l l s & EAST ) == 0 )
{
j = i + 2;
i f (map[ j ] == 25){ map[ j ] = next ; changed = 1 ; }
}

43
Jerry : An Intelligent Maze Solving Robot

i f ( ( c e l l w a l l s & SOUTH) == 0 )
{
j = i + 3;
i f (map[ j ] == 25){ map[ j ] = next ; changed = 1 ; }
}
i f ( ( c e l l w a l l s & WEST) == 0 )
{
j = i + 4;
i f (map[ j ] == 25){ map[ j ] = next ; changed = 1 ; }
}
}
i −−;
} while ( i ) ;
now = now+ 1 ;
next = now+ 1 ;
passes ++;
} while ( changed ) ;
r e t u r n passes ;
}

Generation of PWM
# include<lpc21xx . h>
# inclu de ” PortConfig .H”

void PWMinit ( )
{
PWMMR0 = 0 x00001000 ; // T o t a l PWM Duration
PWMPR = 0 x00000100 ; //PWM P r e s c a l a r
PWMMR4 = 0 x00000100 ; //PWM4 Match R e g i s t e r f o r 10\% duty c y c l e
PWMMR6 = 0 x00000100 ; //PWM6 Match R e g i s t e r f o r 10\% duty c y c l e
PWMPCR | = (1<<12 | 1<<14); // Enable Outputs a t PWM4 and PWM6
}

void StartPWM ( )
{
PWMinit ( ) ;
Delay ( 2 5 ) ;
PWMTCR = 0 x00000009 ; // Enables PWM Counters and Timers
}
/∗ f o r f u t u r e use

void pwm( )
{
while ( I R F r o n t V a l L e f t == 0 && I R f r o n t V a l R i g h t == 0 )
{
PWMMR4 = PWMMR4 + 0 x100 ;
PWMMR6 = PWMMR6 + 0 x100 ;
DelayMS ( 1 0 )
}
}

∗/

Program for starting motor movement

44
Jerry : An Intelligent Maze Solving Robot

# include<lpc21xx . h>

b i t LeftTurn ( )
{
LMDir = 0 ;
RMDir = 1 ;
StartPWM ( ) ;
return 1;
// value returned to check i f l e f t turn was taken ( used in w a l l map updation )
}

b i t RightTurn ( )
{
LMDir = 1 ;
RMDir = 0 ;
StartPWM ( ) ;
return 1;
}

b i t Forward ( )
{
LMDir = 0 ;
RMDir = 0 ;
StartPWM ( ) ;
return 1;
}

void StopAllMotors ( )
{
PINSEL0 | = (0 < <16)|(0 < <17)|(0 < <18)|(0 < <19); //GPIO i n s t e a d o f PWM4 and PWM6
IODIR0 | = (1 < <8)|(1 < <9)|(1 < <10)|(1 < <11); // pins 0 . 8 through 0 . 1 1 are o/p
IOCLR0 | = (1 < <8)|(1 < <9)|(1 < <10)|(1 < <11); // stop motors
}

Code for Mode selection


# include<lpc21xx . h>

b i t mode ( )
{
double modeIn ;

modeIn = IOPIN1&0x00000004 ;

i f ( ! modeIn )
{ return 1;} // run mode when 1 returned
else return 0; // scan mode when 0 returned
}

Code for clocking IR Transmitters


# include<lpc21xx . h>

void s i d e S e n s o r s ( )

45
Jerry : An Intelligent Maze Solving Robot

{
IOSET1 = 0 x00300000 ; // s i d e sen sors on pins 20 and 21 o f port 1
Delay ( 1 0 ) ;
IOCLR1 = 0 x00300000 ;
Delay ( 1 0 ) ;
}

void f r o n t S e n s o r s ( ) // f r o n t s ensors on pin 16 and 17 o f port 1


{
IOSET1 = 0 x00030000 ;
Delay ( 1 0 ) ;
IOCLR1 = 0 x00030000 ;
Delay ( 1 0 ) ;
}

/∗
Future Use

void diagSensors ( ) // diag s ensors on pin 18 and 19 o f port 1


{
IOSET1 = 0x000C0000 ;
Delay ( 1 0 ) ;
IOCLR1 = 0x000C0000 ;
Delay ( 1 0 ) ;
}
∗/

Code for sensing values from IR Receivers


# include<LPC214x . h>

void I R r e c e i v e ( )
{
f o r ( i n t index = 0 ; index <25; index ++)
{
frontSensors ( ) ;
Delay ( 5 ) ;
}

LeftData = ADCconversion ( 1 , 6 ) ;
RightData = ADCconversion ( 1 , 7 ) ;

// Decision Block void Decision ( ) ;

f o r ( i n t index = 0 ; index <25; index ++)


{
sideSensors ( ) ;
Delay ( 5 ) ;
}

LeftSideData = ADCconversion ( 1 , 4 ) ;
RightSideData = ADCconversion ( 1 , 3 ) ;

// Decision Block void Decision ( ) ;


}

46
Jerry : An Intelligent Maze Solving Robot

Code for taking data from gyroscope and passing it to ADC


# include<lpc21xx . h>

long gyro ( )
{
long GyroData ;
// ADCinit ( 0 , 6 ) ;
Delay ( 2 5 ) ;
GyroData = ADCconversion ( 0 , 6 ) ;
}

Code for delay


# include<lpc21xx . h>

void Delay ( unsigned char T i c k s ) // Function to generate small delay


{
unsigned i n t i = 0 ;
i f ( T i c k s ==0)
{
Ticks =1;
}

f o r ( ; Ticks >0; Ticks −−)


f o r ( i = 0 ; i <60000; i + + ) ;
}

Code for ringing the buzzer


# include<lpc21xx . h>

void buzzer ( b i t a )
{
b i t tempA = a ;

i f ( tempA == 1 )
{
IOSET1 = (1<<buzzerPin ) ;
}

i f ( tempA == 0 )
{
IOCLR1 = (1<<buzzerPin ) ;
}
}

Code for ADC Data Conversion


# include<lpc21xx . h>

long ADCdata = 0 ;

47
Jerry : An Intelligent Maze Solving Robot

char ChannelNo ;
void ADCinit ( char ADCx , char Channelx )
{

switch (ADCx)
{
case 1 :
{
AD0CR = 0 x00000000 ;
Delay ( 2 5 ) ;
AD0CR | = (1<<Channelx )|(1 < <16)|(1 < <21);
// Channel s e l e c t i o n , Burst Mode, 10 b i t Res , ADC0 Operational
}
break ;
case 2 :
{
AD1CR = 0 x00000000 ;
Delay ( 2 5 ) ;
AD1CR | = (1<<Channelx )|(1 < <16)|(1 < <21);
// Channel s e l e c t i o n , Burst Mode, 10 b i t Res , ADC1 Operational
}
break ;
}
}

long ADCconversion ( char Channel , char ADC)


{
ChannelNo = Channel ;
ADCno = ADC;

ADCinit (ADCNo, ChannelNo ) ; // C a l l ADC i n i t i a l i z a t i o n

switch (ADCno)
{

/∗ADC0∗/

case 1 :
{
AD0CR = (AD0CR&0xFFFFFF00 ) | ChannelNo ;
// S e l e c t AD0 . Channel f o r conversion
AD0CR| = ( 1 << 2 4 ) ;

i f ( ChannelNo == 0 )
{
while ( ( AD0DR0 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR0 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 1 )
{
while ( ( AD0DR1 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR1 ;
ADCdata = ( ADCdata >> 6 ) ;

48
Jerry : An Intelligent Maze Solving Robot

r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 2 )
{
while ( ( AD0DR2 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR2 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 3 )
{
while ( ( AD0DR3 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR3 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 4 )
{
while ( ( AD0DR4 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR4 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 5 )
{
while ( ( AD0DR5 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR5 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 6 )
{
while ( ( AD0DR6 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD0DR6 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
}
break ;

/∗ADC1∗/

case 2 :
{
AD1CR = (AD1CR&0xFFFFFF00 ) | ChannelNo ;
// S e l e c t AD1 . Channel f o r conversion
AD1CR| = ( 1 << 2 4 ) ;
i f ( ChannelNo == 0 )
{
while ( ( AD1DR0 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR0 ;

49
Jerry : An Intelligent Maze Solving Robot

ADCdata = ( ADCdata >> 6 ) ;


r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 1 )
{
while ( ( AD1DR1 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR1 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 2 )
{
while ( ( AD1DR2 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR2 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 3 )
{
while ( ( AD1DR3 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR3 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 4 )
{
while ( ( AD1DR4 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR4 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 5 )
{
while ( ( AD1DR5 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR5 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
i f ( ChannelNo == 6 )
{
while ( ( AD1DR6 & 0 x80000000 )== 0 ) ;
// wait f o r conversion to complete
ADCdata = AD1DR6 ;
ADCdata = ( ADCdata >> 6 ) ;
r e t u r n ( ADCdata ) ;
}
}
break ;
}
}

50
Jerry : An Intelligent Maze Solving Robot

Chapter 6

LEARNING EXPERIENCE

This project has been an incredible learning experience. It is a daunting task to undertake a project of such magnitude and
wide breadth, but we are able to meet the challenge by diligently working on the design for the entire year. Micromouse
project is of great value to our future academic goals due to its broad engineering nature. By completing this project,
we have gained a great deal of experience in several areas of electronics and telecommunication engineering only briefly
studied in our courses. In addition, the development of the searching algorithm has allowed us to incorporate aspects
of mathematical backgrounds. Furthermore, the project has a research aspect which is strongly in accordance with our
future aspirations.

51
Jerry : An Intelligent Maze Solving Robot

Chapter 7

REFERENCES

1. C. Scott Ananian and Greg Humphreys, Theseus: A Maze-Solving Robot, Princeton University, New Jersey, May 1997
2. Chang Yeun Chung, Micromous: Maze Solving Robot, Universiti Teknologi, Malaysia, May 2009

3. Bob Clough, Rooter - A MicroMouse Maze Solving Robot


4. Tondra De, Drew Hall, The Inception of Chedda: A detailed design and analysis of Micromouse, University of Nevada,
Las Vegas, Fall 2004
5. Kelly Ridge, Sanjeev Giri, Peter Shaw, Jason Flynn, MightyMouse: An Autonomous Maze Solving Robot

6. Michael Gims, Sonja Lenz, Dirk Becker, MICROMOUSE: Microprocessor Controlled Vehicle, University of East Lon-
don, May 19999
7. Faton Avdiu, Andy Zhou, Redwan Ahmed, Emmanuel Hereira, Allen Gutierrez, Mohammad M. Hossain, MICRO-
MOUSE, City College of New York, Spring 2008
8. Philips Semiconductor, LPC214x User Manual, 25th August 2005, Volume 1, Revision 1

9. Brian Beckman, The Physics of Racing


10. Andrew N. Sloss, Dominic Symes, Chris Wright, Arm System Developer’s Guide: Designing and Optimizing System
Software, Published by: Elsevier Inc., 2004
11. The amazing micromice: see how they won,
www.users.ece.gatech.edu/%7Ehamblen/papers/micromouse/mmrace.pdf

12. Software Suggestions, http://micromouseinfo.com/introduction/software.html, 5th November 2004

52
Jerry : An Intelligent Maze Solving Robot

Chapter 8

DATASHEETS

53
Jerry : An Intelligent Maze Solving Robot

54
Jerry : An Intelligent Maze Solving Robot

55
Jerry : An Intelligent Maze Solving Robot

56
Jerry : An Intelligent Maze Solving Robot

57
Jerry : An Intelligent Maze Solving Robot

58
Jerry : An Intelligent Maze Solving Robot

59
Jerry : An Intelligent Maze Solving Robot

60
Jerry : An Intelligent Maze Solving Robot

61
Jerry : An Intelligent Maze Solving Robot

62
Jerry : An Intelligent Maze Solving Robot

63
Jerry : An Intelligent Maze Solving Robot

64
Jerry : An Intelligent Maze Solving Robot

65
Jerry : An Intelligent Maze Solving Robot

66
Jerry : An Intelligent Maze Solving Robot

67
Jerry : An Intelligent Maze Solving Robot

68
Jerry : An Intelligent Maze Solving Robot

69
Jerry : An Intelligent Maze Solving Robot

70
Jerry : An Intelligent Maze Solving Robot

71

You might also like