You are on page 1of 10

LINE – MAZE

SOLVING ROBOT

EEE 456
REPORT OF
INTRODUCTION TO
ROBOTICS PORJECT

PROJECT OWNER: HAKAN UÇAROĞLU


2000502055

INSTRUCTOR: AHMET ÖZKURT

1
CONTENTS

I- Abstract

II- Sensor Circuit

III- Compare Circuit

IV- Microcontroller Circuit

V- Motor Driver Circuit

VI- Used Bateries

VII- Hardware Difficulties

VIII- C Algorithm for Maze Solving

IX- Flowchart of Algorithm for Maze Solving

X- Schematics of the Circuits

XI- PCBs of the circuits

2
I- Abstract

This project is my final year project. But also, this is the project of Introduction to
Robotics lesson. The aim of this project is to learn the artificial intelligence
fundamentals. Also, robotics fundamentals are seen. I encountered with some
diffuculties, while I were trying solving the maze with robot. So, the project is not
finished perfectly. I wish I will finish the project until the end of the year.

The labyrinth is a line maze. In other words, the paths are line. The color of the lines
are black and the ground is white. So, at first, the robot must have an ability to follow
the lines. Lines are 1.5 cm width. Of course there will be + and T intersections in the
maze. The problem is these intersections in my project. How the robot will behave in
these intersections. Robot can select the same way every time, and this can cause
the robot can not find the exit. This was challenge for me. I developed some
hardware and some algorithms for this diffuculty.

In this report, I will explain the oprating of the robot, some difficulties that I
encountered during the realizing the project. Now, I will explain the operating of the
robot.

In this project C programming language is used to program the microcontroller. The


labyrinth is a line labyrinth. So, the line following technique is used. Robot can see
the lines with help of 6 sensors. These sensors are simply an IR led and photo
transistor. IR led sends light to the ground. If the ground is black the light is absorbed.
So the reflected light from ground can not trigger the photo transistor, and the output
of the transistor is 0 when the robot is on the black line. When the robot is on the
white, the reflected IR light is enough for trigger the transistor, and the output of
transistor is 1 in this condition. According to this information about the sensors, the
robot is directed in the ground.

To specify the coordinates of the robot, an encoder circuit is used. This encoder
measures the wheel rotation. This specifies the coordinates of the robot. For this
circuit IR detectors are used. Toothed disks are putted onto the shafts of the robot.
As the disk goes round it breaks an IR beam, which the microcontroller detects as a
series of pulses. When the detector can see the LED, the microcontroller pin goes
low. When the disk blocks the beam it goes high.

To specify the exit of the labyrinth an eye logic is used. This eye is connected to a
step motor. This step motor turns 360 degree at every junction. An IR LED is putted
to the exit. The eye is a simple photo transistor. While the step motor turning, the
position where photo transistor detects the IR LED(exit), specify the direction of the
exit according to the position of the robot. And according to this exit direction
specifying, the appropriate direction is selected.

3
II- Sensor Circuit
I used 6 sensors to follow the line. As I mentioned in the abstract section, I used
CNY70 Rflective Optical sensor. CNY70 sensor sensing distance is 0.3 mm. So,
sensors had to be very near to the ground. The view of the sensor and the element in
the sensors are shown in below Figure.

As we can see from this figure, sensor consists of one opto transistor and an IR
LED. I will explain the operating of this sensor with the help of Figure 2.

(Figure 2)

IR LED sends beam to the ground. If the ground is black, the beam is absorbed by
the ground. So the reflected beam would not be enough to trigger the base of the
opto transistor. So the transistor output is LOW. If the ground is white, the most of the
beam will be reflected from the ground and this beam would be enough to trigger the
base of the transistor. This causes the transistor to give HIGH output. The HIGH
output of the transistors is approximately 1.8V. When the HIHG voltage is produced
the robot thinks that, I am on the white ground. If LOW voltage level is produced, This
voltage level is not enough for the microcontroller control. So I used comparator logic
for this constraints.

4
III- Compare Circuit

As I said in the sensor circuit part, the output of the sensors, which is approximately
1.8V, is not enough for HIGH sensing of the microcontroller. So I had to use a
comparator. For this purpose I used LM324 IC. This IC contains 4 op-amp in it. This
feature of the IC decreased the used area for op-amps. The connection diagram of
this IC circuit is shown in Figure 3.

(Figure 3)

As we can see from this figure the IC consists of four independent, high gain,
internally frequency compensated operational amplifiers.

The Unique Characteristics of this IC are;


• In the linear mode the input common-mode voltage range
includes ground and the output voltage can also swing to ground,
even though operated from only a single power supply voltage.
• The unity gain cross frequency is temperature compensated.
• The input bias current is also temperature compensated

I applied a reference voltage to inverting inputs of the op-ams, and output of the
sensors to the non-inverting input of the op-amps. When the output of the sensor is
smaller than the reference voltage, the output of the op-amp is 0, if the output of the
sensor is higher than the reference voltage, the output of the op-amp is +5V. These
results are the expected inputs to microcontroller.

I applied the reference voltage to the op-amps with help of the 10K potantiometer. I
used potantiometer because the outputs of sensors are changing according to the
environment light. So, to get the right voltage level from the op-amp`s output, the
reference voltage can be changed. I got this changing reference voltage with the help
of potantiometer.

5
IV- Microcontroller Circuit (PIC16F877)

For my solution of solving maze, I need a microcontroller which must have got
enough memory space for storing the intersection coordinates and for storing which
direction/s are selected in this intersection. The labyrinth can be very large and it can
contains numbers of intersections. We can not know that and also robot can not
know this before starting the search of the exit.

As I mentioned in the preliminary report, the port number is also very inportant
for me. Until now, except port E, I used all of the ports.
PortB is used for DC motor driver pulses and Step motor driver pulses. PORTD is
used for sensor inputs. PORTC is used for PWM settings. PORTA is used for analog
inputs.
The main features of the PIC16F877 are given in Table 1.

(Table 1)
Features PIC16F877
Operating Speed DC-20MHz
Program Memory 8Kx14 word FLASH ROM
EEPROM Memory 256 byte
User RAM 368 x 8 byte
Input / Output Port Number 33
Timer Timer 0, Timer 1, Timer 2
A / D Converter 8 Channel 10 bit
PWM 10 bit PWM
USART/SCI 9 bit address

PWM is used for energizing the Dc motors with the wanted duty cycle. I had to need
this because, the robot must operate very slow because it must follow the line.
Sensors are very sensitive, if all are on white ground the robot behaves with
unwanted reactions. To eliminate this condition, the robot must move very slow. By
adjusting the PWM duty cycle I can change the speed of the robot.

I used this microcontroller also because, the programming of it is very easy. To


program the microcontroller I used PICC compiler. With this compiler the program is
written with C programming language. And I think C is the most usage language for
robotic applications. I will give the program codes at the end of this report. And I will
try to explain the program with the help of the flowchart of the program.

To connect th microcontroller circuit to the other circuits I used connectors. These


connectors supplied me not to deal with disorder of cables. And it made the view of
the robot very original.

I could use 89C52 or 8051 microcontrollers also. But in PIC16F877 pin referencing is
included. This simplifies the program writing for me.

6
V- Motor Driver Circuit
As a motor driver circuit I think to use L293D push pull driver IC. This driver capable
of delivering output currents to 1A per channel. Each channel is controlled by TTL-
compatible logic input and each pair of drivers (a full bridge) is equipped with an
inhibit input which turns off all four transistors. A separate supply input is provided for
the logic that it may be run off a lower voltage to reduce dissipation. I will use this
driver to control back wheels. The block diagram of this IC is shown below.

VI- Used Batteries

For this project I used two betteries. One them is 9V Ni-Mh rechargeable battery and
the other is 3.7V Li-ion mobile phone battery. I used 3.7V battery for motor driver
circuit and 9V battery for ICs. I could not used 9V battery for motor drivers. The
reason of that is for motor driving high current is needed. If I used 9v battery for this
purpose, the battery could not live a long time. And this can cause the robot stop at
unwanted points.

Also, using two separate battery for these purpose eliminated the noise interference
for ICs and for sensor outputs. I did not know that two grounds of the batteries must
to be connected together before. So, when I first tried to operate the motors, there
wre not any energy that motors feeding. I worked very hard on this topic. But at last, I
found my fault and after connection the grounds, the motors are energised.

7
VII- Hardware Difficulties

The first problem in hardware was the gearbox problem. This was very important for
me because line following is very sensitive procedure. The two back wheels must
rotate in the same speed and same torque must be applied to them. But soon, the
problem was solved by buying a twin motor gearbox. I gave important fetures and
view of this gearbox in the preliminary report.

The second problem was the sizes of the circuits that I used. The sizes of the firstly
designed circuits were a bit big. My instructor suggested me to small the circuit. So I
had to design he circuits again. And this caused to small the sizes of the robot. But
normally the height of the robot increased. But this is not problem for my project.

After I finished the first part of the project, that is the line following, I saw that the back
wheels of the robot is not good enough. They spin the robot when the robot trying to
turn. This was a big problem for me because that causes the encoders to count
unnecessarily. So the coordinates of the robot can be wrong even if the robot is on
the same coordinates. Spinning is not just the error for coordinates. It causes the
robot not to turn properly. But difficulty is solved with the help of my instructor. He
gave me the Tamiya`s special wheels. These wheels are produced for Tamiya`s
productions. And twin motor gear box is also Tmaya`s production. So these wheels
simplified my work. And they are very qualified. They don`t spin and with them robot
is operating properly. The view of this wheels shown below;

Since in my project there are 6 sensors that sense the line, switching losses is a lot.
Because of that and since the sensors are feeding from 9V battery, battery can not
live a lot. So I had to recharge it everytime. But this caused time loss for me. So I
decided to use a voltage source for experimenting procedures. After my project is
finished, I will deal with this problem.

8
VIII- C Algorithm for Maze Solving

For following the line the sensor places were very important. As I mentioned before I
used 6 sensor for this purpose. The places of the sensors are like that shown in
figure 4.

1 2
1.5 cm

3 4

5 6

1.5 cm

The following line program is very simple. When the 1 and 2 sensors are on the line,
the robot goes straight. If the sensors 3 and 5 or 3 or 5 or 1 and 3 are on the line,
robot turns left. If the sensors 2 and 6 or 2 or 4 or 2 and 4 are on the line, robot turns
right. The program codes of this logic will be given at the end of the report.

In the preliminary wark, I pointed out that the storing of the data will be realized by
using Link List logic in data structure of C language. By I saw that the PICC compiler
do not support this function. I thought that my final project will not finish. But soon I
decided to use arrays. This will restrict my work bu I must use array. The array sizes
must be initialized before the program execution. This means that the size of memory
for intersection must be guessed before encountering the maze solving. But this not
appropriate for the nature of robot. Nothing must be known before encountering the
solving. But I must use array.

When the robot come to one intersection, it will compare the intersections passed
before. By comparing it will decide that it came to this intersection before or not. If it
came, it will look which directions selected and according to these information it will
select another direction. Robot will repeat this procedure at every intersection. By
using this algorithm it will find the exit. At the intersections it will also use its eye. The
eye is a simply a opto transistor. There will be an IR LED at the exit. The eye will be
connected to the stepper motor. At every intersection the stepper motor will turn,
when the eye see the exit, robot will decide that which direction is most appropriate to
select. I could not realize this part yet. But I hope I will finish. Nowadays, I am trying
to realize that. But I have some problems with realizing the coordinate specifications.
I used encoder circuit for coordinate specification. But I am forced with the robot`s
movement.

9
10

You might also like