You are on page 1of 26

TABLE OF CONTENTS

List of Contents
Pages
1. INTRODUCTION
2. LIST OF FIGURE AND APPENDIX
3. PROJECT DESCRIPTIONS
4. LIST OF HARDWARE, COMPONENTS AND
5
SOFTWARE USE
5. EXPLANATION ON HARDWARE AND
COMPONENTS SELECTION
6. CONTROLLER CIRCUIT DEVELOPMENT
7. SOFTWARE AND PROGRAM
DEVELOPMENT
8. SOP ON HARDWARE AND SOFTWARE
9. EXPECTED RESULT ACHIEVE
10.
DISCUSSION
11.
CONCLUSION

INTRODUCTION

2
3
4

6-8

For the subject Mechatronic System Design (FAB 30503), lectured by Mdm.
Siti Khadijah, students are required to come out with a line following robot.
A line following robot is basically a robot designed to follow a line or
path which already predetermined by the user. This line or path may be as
simple as a physical white line on the floor or as complex path marking
schemes e.g. embedded lines, magnetic markers and laser guide markers.
In order to detect this specific line, various sensing schemes can be
employed. These schemes may vary from simple low cost line sensing
circuit to expensive vision systems. The choice of these schemes would be
dependent upon the sensing accuracy and flexibility required. From the
industrial point of view, line following robot has been implemented in semi
to fully autonomous plants. In this environment, these robots functions as
materials carrier to deliver products from one manufacturing point to
another where rail, conveyor and gantry solutions are not possible. Apart
from the line following capabilities, these robots should also have the
capability to navigate junctions and decide on which junction to turn and
which junction ignore. This would require the robot to have 90 degree turn
and also junction counting capabilities. To add on to the complexity of the
problem, sensor positioning also plays a role in optimizing the robots
performance for the tasks mentioned earlier.
Line-following robots with pick- and- placement capabilities are
commonly used in manufacturing plants. These move on a specified path
to pick the components from specified locations and place them on desired
locations. Basically, a line-following robot is a self-operating robot that
detects and follows a line drawn on the floor. The path to be taken is
indicated by a white line on a black surface. The control system used must
sense the line and manoeuvre the robot to stay on course while constantly
correcting the wrong moves using feedback mechanism, thus forming a
simple yet effective closed- loop system.

LIST OF FIGURE AND APPENDIX

Pages

Figure
1
..12
Figure
2
..13

PROJECT DESCRIPTIONS
This project aims at developing a line following robot which is
programmed by using microcontroller AT89C51. The microcontroller has
been used to program the ROBOT to turn in a direction followed by
line.
Secondly, this project, Line Following Robot is based on 8 bit
Microcontroller AT89C51. This robot follows the white line which is drawn
over the black surface .The infrared sensors are used to sense the line.
When the infrared signal falls on the white surface, it gets reflected and if
it falls on the black surface, it is not reflected. This principle is used to scan
the lines for the robot to moves the path.
All the above systems are controlled by the Microcontroller. In our
project we are using the popular 8 bit microcontroller AT89C51. It is a 40
pin microcontroller. The Microcontroller AT89C51 is used to control the
motors. It gets the signals from the infrared sensors and it drives the
motors according to the sensor inputs. Two DC geared motors are used to
drive the robot in forward, left or right direction.

LIST OF HARDWARE, COMPONENTS AND SOFTWARE


NO.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

Component
PIC Start-up Kit (SK40A)
Comparator LM324
Motor Driver L293D
LED
IR Receiver
IR Emitter
Resistor 4.7K
Resistor 330R
Trimmer 10K
2510 -05 PCB Connector
2510 -02 PCB Connector
Wrapping Wire
PIC 16F877A
14 Pins IC Socket
16 Pins IC Socket
Rainbow Cable 5 Ways
RC Servo Motor C36S (modified)
Robot Base
Servo Wheel
Screw for Wheel
Castor BTU-720
9V Battery Snap
4AA Battery Holder
Donut Board
Software
MPLABX IDE
Proteus 7 Professional
Optional Item
UIC00A
UIC-s

Unit
1
1
1
4
4
4
4
8
4
2
3
3
1
1
1
1
2
1
2
8
2
1
1
1
Unit
1
1
Unit
1
1

HARDWARE AND COMPONENTS SELECTION


Component

Picture

PIC Startup Kit


(SK40A)

Comparato
r LM324

Motor
Driver
L293D

LED

IR Sensor
Set (IR
Emitter and
IR Receive)

Explanation
ICSP connector for UIC00B
-simple and fast method to
load program.
Perfect fit for 40 pins PIC16F
and PIC18F.
Operating Voltage Range: 7V 15VDC
2 x programmable switch.
2 x LED indicator.
Exchangeable Crystal.
UART connection to interface
with other controller or even
computer.
Large DC Voltage Gain: 100dB
Input Common Mode Voltage
Range Includes Ground
Large Output Voltage Swing:
0V to VCC -1.5V
Power Drain Suitable for
Battery Operation
Wide Supply-Voltage Range:
4.5 V to 36 V
Separate Input-Logic Supply
Internal
ESD
Protection
Thermal Shutdown
High-Noise-Immunity Inputs
Peak Output Current 2 A Per
Channel (1.2 A for L293D)

3.0-3.4VDC Forward Voltage


80mA Forward Current
30 degree viewing angle
8,000-10,000 MCD output
LED used: white, red, yellow
and green

Consists of an IR transmitter
and an IR receiver mounted
side by side on a tiny PCB
Minimum interface
5VDC power

Value: 4.7K ohm


Watt: 0.25watt
Tolerance: 5%

Value: 330 ohm


Watt: 0.25watt
Tolerance: 5%

Value: 10K ohm


Type: Top adjustment
Size: 19.4mm x 4.4mm
9.6mm

2510 -05
PCB
Connector

2510 -02
PCB
Connector

Current rating: 3A AC, DC


Voltage rating: 250V AC, DC
Voltage rating: 250V AC, DC
Temperature range: -25o C to
+85o C
Current rating: 3A AC, DC
Voltage rating: 250V AC, DC
Voltage rating: 250V AC, DC
Temperature range: -25o C to
+85o C
Type : 30AWG
Colour used: Black and Red
Wire Size : 0.5 x 0.25mm /
0.019" x 0.009"(OD*Wire Dia.);
Cable Length(Approx.) : ~30M /
100Ft

Resistor
4.7K

Resistor
330R

Trimmer
10K

Wrapping
Wire

PIC
16F877A

Pin Count: 40-pin PDIP


Program Memory: 14KB or 8K
14-bit Flash
Max Crystal Speed: 20MHz
RAM Bytes: 368
EEPROM Bytes: 256
Timers: 2 x 8 bit, 1 x 16-bit
Digital
Communication:
1xA/E/USART, 1 x MSSP(SPI/I2C)
Capture/Compare/PWM: 2 x
CCP
ADC: 8ch, 10-bit
Comparators: 2

14 Pins IC
Socket

16 Pins IC
Socket

Rainbow
Cable 5
Ways

RC Servo
Motor C36S
(modified)

Number of contacts: 14
Contact Gender: female
Number of rows: 2
Mounting style: straight
Low profile
Row Centerline: 0.3 inch

Number of contacts: 16
Contact Gender: female
Number of rows: 2
Mounting style: straight
Low profile
Row Centerline: 0.3 inch
5 ways rainbow cable

Plastics gears
Operating Voltage: 4.8 - 6VDC
Speed
at 6.0V(no
load):
0.12 s/60
Torque at 6.0V : 4.4 kg.cm
(~0.431 N.m)
Size: 40.7x20.5x39.5mm
Weight: 43g
Rotation angle: 180 degree
Approximate
Dimensions:
18.8cm x 18.2cm x 3.4cm
(Aluminium Thickness, 1mm)

Robot Base

Servo
Wheel and
Screw for
Wheel

Castor
BTU-720

The metal key coupling/hub is


made of steel with zinked
plated and comes with the
necessary bolts for mounting
The robot wheel is 5 inches in
diameter and outer ring is
made of rubber that provide
great grip on most of surface
Load Capacity: 29.5kg
Weight: 60g
Bolt: M6

9V
Battery
Snap

4AA
Battery
Holder

Donut
Board

standard

volt

Plastic holder use for standard


AA battery
Number of cell: 4
Double sided

Donut board (individual copper


per hole)
Material: Paper Pheonolic
Dimension: 10cm x 24cm

UIC00A

Use with
battery

Program most of the +3.3V or


+5V PIC
Compatible with PICkit2s UART
Tool and Logic Tool
Program most of the current 8-,
16-, and 32-bit Flash PIC
microcontroller
Compatible with Windows XP,
Vista, 7, 8 and 8.1
Compatible with Microchips
PICkit 2.
Powered directly from USB port.
NO
EXTERNAL
POWER
REQUIRED
for
UIC00B
to
function.
Compatible with PICkit2's Logic
Tool and UART Tool.
Integrated into MPLAB and
MPLAB X IDE, write program
and load directly into your PIC
with 1 software.
UIC00B
supports
on-board
programming which eliminates
the need of plug-in and plugout of PIC MCU.
This also allows user to modify
the program without removing
the PIC from the development
board.

UIC-s

No external power needed


Power Indicator LED on board
Fit perfectly with UIC00A and
UIC00B
Support 18-pin, 28-pin and 40pin 8-bit PIC microcontroller.
Selector to program 18-pin or
28-pin&40-pin PIC
Come with 40-pin ZIF socket for
ease of plug and unplug of PIC

CONTROLLER CIRCUIT DEVELOPMENT

Figure 1: Schematic diagram using Proteus 7 Professional

SOFTWARE AND PROGRAM DEVELOPMENT


1) Open software: MPLABX IDE
2) Load the program below:
#include
#include
#include
pin
#include

<htc.h>// include htc for HI-TECH header file for PIC


"system.h" // include hardware system define header file
"adc.h" // include adc initialization for correct digital and analog
"pwm.h"

// include pwm library functions

/
***************************************************************************
****
* DEVICE CONFIGURATION WORDS
*
***************************************************************************
****/
__CONFIG(HS &
WDTDIS &
PWRTEN &
BORDIS &
LVPDIS);

//
//
//
//
//

High Speed Crystal.


Disable Watchdog Timer.
Enable Power Up Timer.
Disable Brown Out Reset.
Disable Low Voltage Programming.

/
***************************************************************************
****
* PRIVATE FUNCTION PROTOTYPES
*
***************************************************************************
****/
void
void
void
void
void
void
void

delay_ms(unsigned int ui_value);


beep(unsigned char uc_count);
line_follow(void);
foward(void);
stop(void);
turn_right(void);
turn_left(void);

/
***************************************************************************
****
* Global Variables
*

***************************************************************************
****/
char string_buffer[40] = {0};
/
***************************************************************************
****
* MAIN FUNCTION
*
***************************************************************************
****/
int main(void)
{
PORTA=0;
PORTB=0;
PORTC=0;
PORTD=0;
PORTE=0;
TRISA=0;
TRISB=0b00001111;
TRISC=0b00000110;
TRISD=0b00001111;
TRISE=0;
ADCON1=0b00001110;
CCP1CON=0b00000110;
CCP2CON=0b00000110;
T2CON=0b00000101;
PR2=0xFF;
while(1)
{
//start
int counter=0;
while (counter<1)
{
line_follow();
if (COUNTER==0)
{
while (COUNTER==0);
counter++;

//motor
//pwm
//sensor

//pwm1
//PMW2
//5khz
//255

}
}

//first corner
stop();
delay_ms(1000);
turn_right();
delay_ms(1700);
counter=0;
while (counter<2)
{
line_follow();
if (COUNTER==0)
{
while (COUNTER==0);
counter++;
}
}
//second
stop();
delay_ms(1500);
turn_left();
delay_ms(1900);
counter=0;
while (counter<2)
{
line_follow();
if (COUNTER==0)
{
while (COUNTER==0);
counter++;
}
}
//third
stop();
delay_ms(1500);
turn_right();
delay_ms(1900);
counter=0;
while (counter<2)
{

line_follow();
if (COUNTER==0)
{
while (COUNTER==0);
counter++;
}
}
//fourth
stop();
delay_ms(1500);
turn_left();
delay_ms(1900);
counter=0;
while (counter<1)
{
line_follow();
if (COUNTER==0)
{
while (COUNTER==0);
counter++;
}
}
//finish
foward();
delay_ms(1500);
stop();
delay_ms(10000);
}
while(1) continue;
prevent the PIC from reset
}

// Infinate loop at the end of program,

/
***************************************************************************
****
* PRIVATE FUNCTION: delay_ms
*
* PARAMETERS:
* ~ ui_value
- The period for the delay in miliseconds.

*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* Delay in miliseconds.
*
***************************************************************************
****/
void delay_ms(unsigned int ui_value)
{
while (ui_value-- > 0)
{
__delay_ms(1);
// must not over 39ms
}
}

/
***************************************************************************
****
* PRIVATE FUNCTION: beep
*
* PARAMETERS:
* ~ uc_count
- How many times we want to beep.
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* Beep for the specified number of times.
*
***************************************************************************
****/
/*
void beep(unsigned char uc_count)
{
while (uc_count-- > 0)
{
BUZZER = 1;
delay_ms(50);
BUZZER = 0;
delay_ms(50);
}
}
*/

/
***************************************************************************
****
* PUBLIC FUNCTION: pwm_set_duty_cycle
*
* PARAMETERS:
* ~ ui_duty_cycle - The duty cycle of the PWM, 10 bits.
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* Set the duty cycle of the PWM.
*
***************************************************************************
****/
//====================
line
following
functions
=====================
/
***************************************************************************
****
* PUBLIC FUNCTION: fast_line_follow
*
* PARAMETERS:
* ~ void
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* perform line following in fast speed. This function must use SPG10-30K
and 46x10mm mini wheel,
* the position of motor to LSS05 is very important.
***************************************************************************
****/
void foward(void)
{
MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}
void turn_right(void)
{

MR_1=0;
MR_2=0;
ML_1=1;
ML_2=0;
}
void turn_left(void)
{
MR_1=1;
MR_2=0;
ML_1=0;
ML_2=0;
}
void stop(void)
{
MR_1=0;
MR_2=0;
ML_1=0;
ML_2=0;
}
void line_follow(void)
{
if ((S_LEFT == 1)&&(S_MIDDLE == 0)&&(S_RIGHT == 1))
//check middle, left and right sensor
//assuming black line, dark ON
{
//

motor(85,85);
MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}

if ((S_LEFT == 0)&&(S_MIDDLE == 1)&&(S_RIGHT == 1))


//check middle, left and right sensor
//assuming black line, dark ON
{
MR_1=1;
MR_2=0;
ML_1=0;
ML_2=0;

}
if ((S_LEFT == 1)&&(S_MIDDLE == 1)&&(S_RIGHT == 0))
//check middle, left and right sensor
//assuming black line, dark ON
{
MR_1=0;
MR_2=0;
ML_1=1;
ML_2=0;
}
if((S_LEFT==
0)&&(S_MIDDLE
==
0)&&(S_RIGHT
0)&&(COUNTER==1)) //check middle, left and right sensor
//assuming black line, dark ON
{

==

MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}
if((S_LEFT==
0)&&(S_MIDDLE
==
0)&&(S_RIGHT
1)&&(COUNTER==1)) //check middle, left and right sensor
//assuming black line, dark ON
{

==

MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}
if((S_LEFT==
0)&&(S_MIDDLE
==
1)&&(S_RIGHT
0)&&(COUNTER==1)) //check middle, left and right sensor
//assuming black line, dark ON
{

==

MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}
if((S_LEFT==
0)&&(S_MIDDLE
==
1)&&(S_RIGHT
1)&&(COUNTER==1)) //check middle, left and right sensor
//assuming black line, dark ON
{

==

MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}
if((S_LEFT==
1)&&(S_MIDDLE
==
1)&&(S_RIGHT
1)&&(COUNTER==1)) //check middle, left and right sensor
//assuming black line, dark ON
{
MR_1=1;
MR_2=0;
ML_1=1;
ML_2=0;
}
}

==

SOP ON HARDWARE AND SOFTWARE


7.1 Hardware
1) Place the robot on the track.
2) Adjust the robot location and position so that the middle sensor at the
front is placed on the line.
3) Switch on the PIC controller and release the robot.
4) Hold the robot and switch off the PIC controller when robot has arrived
at the end line.
7.2

Software
7.2.1 Creating New Program
1) Open MPLABX IDE software on computer.
2) Select Project Wizard > Next > select Device for PIC and Next >
select HI-TECH Universal ToolSuite and Next > Browse then write
a File Name and Save and Next > Next > Finish
3) Add file .c for Source File and .h for Header File
4) Build and wait until window show Build Successful!
7.2.2 Load Program
1) Plug-in cables to PIC controller, UIC00A and a computer.
2) Open MPLABX IDE software on computer.
3) Switch on the PIC controller.
4) Click Programmer > Select Programmer > select PICkit 2.
5) Click Programmer > Settings and tick all except Output to debug
file, Preserve device EEPROM and set VDO Voltage to:.
6) Click Rebuild and wait until window show PICkit 2 ready.
7) Create or load a program.
8) Click Rebuild and wait until window show PICkit 2 ready.
9) Switch off the PIC controller.
10)
Unplug the cable from PIC controller.

EXPECTED RESULT ACHIEVE

21 | P a g e

Figure
1

Figure 1 - above is the desired line following track. Yellow colored line is the
path which the robot need to move.

22 | P a g e

Figure
2

As shown as 4 of the figure above, our line following robot managed to


follows the white line on the black surface. Along the path, the left and right
sensors were able to sense the robot when over movement was resulted,
therefore providing the straight path by controlling the motor speed and
gives the line following robot a straight path until the end.

23 | P a g e

DISCUSSION
1. It can act as maze solver. Basically, it follows a line, therefore it can be
used in mining where the robots are used to find the way out of the
mine.
2. If we implement a robotic arm along with the line follower then it can
be used to pick and place the objects in its way and can be very useful
in our day to day life.
3. Apparatus to control the automatic placing of material along a junction
between surfaces with reference to the form and position of the
junction including a tool controllably movable to deposit material
progressively along the junction in response to a control signal.
4. An imager linked to the movement of the tool to produce an image of
the surfaces.
5. By modifying the position of the sensors, same principle can be used in
obstacle avoidance and edge detection.

24 | P a g e

CONCLUSION
This is the first step of making intelligent robots capable of making their own
decisions on the situations provided. The design, implementation and testing
of a working project proved to be very challenging. The primary objective of
detecting and following a specific colored line proved to be a great learning
experience, as we did not have prior hands-on experience in Embedded
Systems.
The difficulties in project management as well as those brought to light
during experimentation provided an opportunity to work on problem-solving
abilities. Despite many problems encountered, I found this experience a
rewarding and educational one.
This project can have many uses in practical fields, from teenagers
toy cars to robots working in industries and even in wars. It can be further
improved to have more decision taking capabilities by employing varied
types of sensors and thus could be used in big industries for different
applications.
As an ending, we would like to express our gratitude to Mdm. Siti
Khadijah, our lecturer and guider in completing this line following robot.

25 | P a g e

APPENDIX

26 | P a g e

You might also like