You are on page 1of 11

[Type the document subtitle] | Jackass

COMPSYS
301
LINE FOLLOWING ROBOT
TABLE OF Contents

1.0 Introduction..................................................................................................................3
2.0 Hardware..................................................................................................................... 3
2.1 Chassis.................................................................................................................... 4
3.0 Sensors....................................................................................................................... 4
3.1 Calibration................................................................................................................ 4
3.2 Runtime reading.......................................................................................................4
4.0 Motor Control............................................................................................................... 5
4.1 DC motor..................................................................................................................5
5.0 Algorithm..................................................................................................................... 6
5.1 Forward....................................................................................................................6
5.2 Crossing...................................................................................................................6
5.3 Turn Leave............................................................................................................... 6
5.4 Turn Seek................................................................................................................ 6
5.5 TurnLeft/TurnRight ?................................................................................................6
5.6 Charging.................................................................................................................. 6
5.7 Reading....................................................................................................................7
6.0 Discussion................................................................................................................... 7
7.0 Problems..................................................................................................................... 7
8.0 Time structure..............................................................................................................8
9.0 Conclusion...................................................................................................................8
10.0 References..................................................................................................................8
11.0 Appendix..................................................................................................................... 8

1
Table of Figures
Figure 1. Sensor Top View.....................................................................................................5
Figure 2 Sequence of the states.............................................................................................7

2
Abstract
This report is conceptual design of a maze solving robot. The main idea behind this project
was to learn about hardware/software co design by programming a micro controller. The
project was split into two parts, electrical and software. The simulation of the electronic
circuit was done using LTSpice. The PCB was designed using Altium Protel. The code was
written in C.

3
1.0 Introduction
The basic idea behind the SB1818 was to build a line following robot capable of navigating a
maze. The maze will include barcodes placed before intersections to guide the robot towards
the exit. The functionality of the robot is implemented in an Atmel ATMega8 microprocessor.
An ISP port along with a DonKEY is utilised to easily reprogram the microprocessor. In order
to read the black line, an array of LEDs is used as sensors. The frame of robot was built to
be sturdy and light enough for the robot to navigate to the end. Low power consumption was
one of the main aims since the beginning.

The robot is an autonomous line follower capable of reading barcodes and taking decisions.
Robust line following algorithms and a quality chassis build allows the robot to run in low light
conditions and follow sharp corners. The trail is a black line on a white surface. Using the
sensors, the robot must follow the track and act in accordance with with the barcodes laid out
all over the map. The robot must also be able to charge up its super capacitor by IPT
(inductive power transfer) using a pickup coil. The robot uses its magnetic field sensors to
position itself close to the IPT charging station.

Talk about structure of report.

2.0 Hardware
The robot consists of an Atmel ATmega8 chip, pickup coil, super capacitor, two magnetic
field sensors and two motors. It has five led sensors at the bottom of the chassis to detect
the track. Based on the amount of light a led receives, a surface of black or white can be
detected. It includes a super capacitor which provides the robot with a constant voltage of
5V. A pickup coil is used to charge up this capacitor at an IPT (inductive power transfer)
charging station.

The robot also includes as ISP (in system programming) port for easy reconfiguration.

4
Left motor

ATmega8 H bridge

Led sensors

Right motor

INPUT PROCESS OUTPUT

2.1 Chassis
For a stable robot, weight distribution was essential. This led to the decision of placing the
IPT blackbox was placed over the motors.

Skids were placed at the front and rear to prevent the robot from tilting in one way while in
motion. The front skids also protect the LEDs from impact. Velcro was placed beneath the
skids so as to reduce friction with the surface.

IPT pickup coil and the IPT sensors were placed at the rear so that the robot can back up
into the charging station. This was done so that it’s easier for the robot to get back on track
after charging up as the track would be straight ahead. IPT sensors are placed on either side
of the pickup coil so as to guide the robot such that it is perpendicular to the charging station.

3.0 Sensors
There are a total of ten LEDs that form the sensor board for the robot. Five being emitting
and five receiving. The receiving led’s are charged up to 5V and then allowed to discharge.
LEDs on the black line will have a longer discharge time whereas those on white will have a
shorter discharge time. All the five LEDs are read at once and their state saved to be
decoded later on.

3.1 Calibration
The discharge timings will vary according to the time of day and the amount of incident light.
Calibration is therefore required such that the reference values are updated if the
environment changes. There are two stages for calibration, one for black and one for white.
The sensors are placed over the black and white surfaces during these stages. These values
are saved to the EEPROM to be used as a reference. The weighted average value of white
and black is then calculated, and be used when the machine is running. BIAS

5
3.2 Runtime reading
During runtime, the sensor reads the values and checks it against the reference. Based on
which LEDs detects white or black, the robot changes into the appropriate state.

Front

FarLeft MidLeft Center MidRight FarRight

Emitter Figure 1.
Sensor Top
View
Receiver
90º left Follow line
Scan
barcode
Follow line 90º right 4.0 M
o
Rear
t
o
r
Control
4.1 DC motor
DC motors have the benefit of being easier to control and can run at a low voltage. Motor
speed is controlled by a PWM signal from the micro controller. Two control signals are used
to control the direction of the motor. Changing the polarity of these control signals changes
the direction of the motor.

Since a high speed was not necessary, gear ratio C was chosen as adequate torque.

Direction Right Motor Left Motor


Forward Forward Forward
Reverse Reverse Reverse
Stop Stop Stop
90° Left Forward Reverse
90° Right Reverse Forward
Gentle Left Forward – slow Forward
Gentle Right Forward Forward – slow
Sharp Left Brake Forward
Sharp Right Forward Brake
Direction Positive terminal Negative terminal
Forward 0V Vss
Reverse Vss 0V
Stop 0V 0V
Stop Vss Vss

5.0 Algorithm
The software is partitioned into multiple files based on functionality. They are as follows:

6
i
a
t
o
M
c
n
S
b
e
D
s
r
h
.
g
u
The state machine for the functioning of the robot is as follows:
1. Forward
2. Reading
3. Crossing
4. Turn Leave
5. Turn Seek
6. Reverse
7. Charging

Overall sequence of the states

7
lw
F
s
o
iC
v
a
L
g
k
e
S
n
r
u
T 5.1 Forward

intercepting a barcode.
Figure 2 Sequence of the states

The robot is made to move forward as straight as possible. This state uses the MidRight and
MidLeft LEDs to slightly adjust the motion of the car whenever either LED is out of the track.

The car needs to stabilise quickly after a sharp turn to ensure that it is running straight before

It switches to the TurnLeft/TurnRight state when the FarLeft/FarRight triggers.

5.2 Crossing
The robot is in the crossing state while passing over an intersection. This is detected when
either FarLeft or FarRight detects black. The values of both these sensors are buffered so
that it is easier to detect the end of the intersection, which is when both LEDs detect white.

At this point the robot selects one of the possible directions based on a previously read
barcode. It then goes into the Turn leave state.

5.3 Turn Leave


As soon as the machine enters the turn Leave state, it starts to turn 90°. The robot enters
Turn Seek state when the middle LED sensor and the LED next to it (on the turning direction)
detect white.

5.4 Turn Seek


The behaviour of the robot is identical from the Turn Leave. The only difference from the
Turn Leave is that Turn Seek state goes on until the robot detects the black. Similar from the
Turn Leave state, the mid LED and the LED next to mid LED are used.

5.5 Charging

8
Figure 3. IPT Charging

5.6 Reading
The car reads the barcode in this state. The amount of time spent reading the barcode, is
recorded and accordingly the type of barcode is interpreted. This barcode is saved in
memory and to be followed when the car reaches an intersection. To ensure that the car
moves at a constant speed while reading and does not adjust itself, the line following
algorithm is ignored and the car is made to run straight. For this to work properly, the car has
to be stable before reading the barcode or else it will go off track.

The types of barcodes are as follows:

Barcode Dimension (cm)


Straight 1
Charge 2
Turn Left 3
Turn Right 4
Stop 6

Direction of motion

A B C D

gap gap
Sample Barcode

A timer is started when the car reaches point A and it is stopped when point D is reached.
The value of the timer is saved when the car reached point A, B, C and D. The time for the

9
barcode is calculated as C – B. The time for the gap would be ((D - A) – (B - C)) / 2. The time
for the barcode divided by the time for the gap would give us the length of the barcode. To
ensure proper rounding of values, 0.5 is added to length of the barcode. FACTOR

6.0 Discussion

7.0 Problems
 To make it easier to write code for the complex sections, the entire library was
rewritten using efficient coding practices. Most of the calculations were performed by
the compiler, which lowered the overhead while the car was running.
 There was a considerable amount of noise picked up by the sensors when the car
was in motion. This was a problem especially when code was being written for
reading the barcodes. Buffers were therefore implemented which helped alleviate the
problem.
 Finding the reference points for the black and white surfaces was a bit of a hassle to
do at start up. Hence two new modes were added to specifically calculate theses
references while the robot was placed on white and black respectively and saved to
the EEPROM.

8.0 Improvement

9.0 Time structure


1. Rewriting the library.
2. Coding the functionality of the robot.
3. Preparing the cost sheet.
4. Writing the report.

Week 9 Week 10 Week 11 Week 12


Task 1
Task 2
Task 3
Task 4

10.0 Conclusion

11.0 References

12.0 Appendix

10

You might also like