Automatic Railway Gate Control By Using Microcontroller.

i

AUTOMATIC RAILWAY GATE CONTROL BY USING MICROCONTROLLER

AHMAD HAFIZI BIN MOHAMAD

This report is submitted in partial fulfillment of the requirements for the award of
Bachelor of Electronics Engineering (Industrial Electronics) with Honours

Faculty of Electronics Engineering and Computer Engineering
Universiti Teknikal Malaysia Melaka

May 2011

ii

UNIVERSTI TEKNIKAL MALAYSIA MELAKA
FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER
BORANG PENGESAHAN STATUS LAPORAN

PROJEK SARJANA MUDA II


Tajuk Projek

:

Sesi
Pengajian

:

Automatic Railway Gate Control By Using Microcontroller
1

0

/

1

1


Saya AHMAD HAFIZI BIN MOHAMAD mengaku membenarkan Laporan Projek Sarjana Muda
ini disimpan di Perpustakaan dengan syarat-syarat kegunaan seperti berikut:
1.

Laporan adalah hakmilik Universiti Teknikal Malaysia Melaka.

2.

Perpustakaan dibenarkan membuat salinan untuk tujuan pengajian sahaja.

3.

Perpustakaan dibenarkan membuat salinan laporan ini sebagai bahan pertukaran antara institusi
pengajian tinggi.

4.

Sila tandakan ( √ ) :


SULIT*

*(Mengandungi maklumat yang berdarjah keselamatan atau
kepentingan Malaysia seperti yang termaktub di dalam AKTA
RAHSIA RASMI 1972)

TERHAD**

**(Mengandungi maklumat terhad yang telah ditentukan oleh
organisasi/badan di mana penyelidikan dijalankan)

TIDAK TERHAD

Disahkan oleh:

__________________________
(TANDATANGAN PENULIS)

Tarikh: ………………………..


___________________________________
(COP DAN TANDATANGAN PENYELIA)

Tarikh: ………………………..

iii

“I hereby declare that this report is the results of my own work except for quotes as cited
in the reference.”

Signature

: ………………………………………………

Author

: AHMAD HAFIZI BIN MOHAMAD

Date


: 3rd MAY 2011

iv

“I hereby declare that I have read this report and in my opinion this report is sufficient in
terms of the scope and quality for the award of Bachelor of Electronic Engineering
(Industrial Electronics) With Honors”

Signature

: ………………………………………………

Supervisor’s name

: MISS MUZALIFAH BINTI MOHD SAID

Date

: 3rd MAY 2011


v

Dedicated to my parents, my siblings, and all my beloved person.

vi

ACKNOWLEDGEMENT

First of all, I would like to thank God for his blessing, and I also want to
express my deepest gratitude to my supervisor Miss Muzalifah Bt. Mohd Said for
support and guidance throughout this project running and completion of this report.

My deepest appreciation also goes out to Mrs. Sharatul Izah Bt. Samsudin who
gave me many needed support, encouragement and help throughout my project’s
improvement in PSM I, and my friends who struggling with me exploring this scope.
Not to forget, thanks to my family and fellow friends who encouraged me.

Finally, thank you to all those involved directly and indirectly helping me out
during my PSM I & PSM II which I can’t state out every one of them. A special
expression of gratitude is extended to everyone for their tolerance and patience in doing

the project. I must admit that they had enriched me in many ways and words alone are
not enough to express my gratitude.

vii

ABSTRACT

The purpose of this project is to develop an automatic railway gate system that
uses the microcontroller as a main function of design. The principle objective of this
project was to design an automatic railway gate control by microcontroller. This project
deals to develop a prototype of railway gate that function automatically by using
microcontroller. Besides that, the interfacing program also had been developed for the
integration part. The operation using microcontroller (PIC16F877A) that integrated with
other circuits involved such as power supply, IR sensor, light and buzzer, gate motor and
LCD display. All the circuits will be combining to demonstrate the operation of
microcontroller (PIC16F877A). This system will make improvement towards the
manually operation before this. Human supervision will be considered if there are
problems occurred while this system was operated.

viii


ABSTRAK

Tujuan projek ini adalah untuk membina sebuah sistem pengendalian pagar
lintasan keretapi secara automatik yang menggunakan mikropengawal sebagai asas
binaan di dalam rekaannya. Prinsip tujuan projek ini adalah untuk membina sistem
pengendalian pagar lintasan kereta api secara automatik dengan menggunakan
mikropengawal. Ia termasuk untuk membangunkan sebuah prototaip sistem pagar
lintasan kereta api yang berfungsi secara automatic. Selain itu, sebuah program juga
dibentuk bagi menggabungkan bahagian-bahagian tertentu di dalam sistem ini. Operasi
mikropengawal (PIC16F877A) juga melibatkan litar-litar lain seperti litar bekalan kuasa,
infrared, lampu dan buzzer, motor dan paparan LCD. Kesemua litar-litar ini
digabungkan bagi menunjukkan bagaimana mikropengawal (PIC16F877A) beroperasi.
Sistem ini berfungsi bagi menambah baikkan sistem yang sedia ada sekarang yang
masih menggunakan sistem manual. Khidmat pekerja hanya diperlukan apabila situasi
berdepan masalah seperti sistem gagal beroperasi.

ix

CONTENTS


CHAPTER

I

TITLE

PAGE

PROJECT TITLE

i

REPORT STATUS VERIFICATION FORM

ii

STUDENT’S DECLARATION

iii


SUPERVISOR’S DECLARATION

iv

DEDICATION

v

ACKNOWLEDGEMENT

vi

ABSTRACT

vii

ABSTRAK

viii


CONTENTS

ix

LIST OF TABLES

xii

LIST OF FIGURES

xiii

LIST OF APPENDICES

xvi

INTRODUCTION

1

1.1

Project Introduction

1

1.2

Project Objectives

2

1.3

Problem Statement

2

1.4

Scope of Works

3

1.5

Methodology

4

1.6

Report Structure

5

x

II

LITERATURE REVIEW

6

2.1

Previous System

6

2.2

Block Diagram Description

7

2.2.1 Gate Control Unit

9

2.2.2 Announcement Unit

10

Microcontroller

10

2.3.1 PIC16F877A

11

2.4

Programming Language

13

2.5

Infrared Sensor

14

2.5.1 IR Transmitter

14

2.5.2 IR Receiver

15

2.6

Motor Theory

16

2.7

H-Bridge

17

2.7.1 L293D

18

2.8

LCD

19

2.9

Proteus VSM

20

2.3

III

2.10 PIC C Compiler

23

METHODOLOGY

26

3.1

Project Methodology

26

3.2

Project Flow Chart

28

3.3

System Flow

29

3.3.1 Process Procedure

30

Hardware Assembly

31

3.4

xi

IV

RESULTS AND DISCUSSION

33

4.1

System Explanation

33

4.2

The Designed Circuits

36

4.2.1 Sensor Circuit

36

4.2.2 Buzzer Circuit

38

4.2.3 Lighting Alarm Circuit

39

4.2.4 Voltage Regulator Circuit

40

4.2.5 LCD Circuit

41

4.2.6 Motor Circuit

44

4.2.7 PIC16F877A Integration Circuit

46

The Simulation Result

47

4.3.1 Voltage Supply

47

4.3.2 PIC16F877A Interfacing Result

48

4.4

The Programming Result

50

4.5

Hardware Description

53

4.5.1 The Constructed Circuits

53

4.5.2 The Prototype

57

4.3

IV

CONCLUSION AND RECOMMENDATION

59

5.1

Conclusion

59

5.2

Recommendation

60

REFERENCES

61

xii

LIST OF TABLES

NO.
4.2.5

TITLE

The pin structure of LCD module

PAGE
43

xiii

LIST OF FIGURES

NO.

TITLES

PAGE

2.2.1

Block diagram of the system

7

2.2.2

The functionality between microcontrollers

8

2.2.1.1 The diagram of gate control unit

9

2.3.1.1 PIC16F877A pins/terminals

12

2.3.1.2 PIC16F877A chip

12

2.5.1

Infrared sensor

14

2.5.1.1

IR transmitter circuit using 555 IC timer

14

2.5.2.1 IR receiver circuit using 555 IC timer

15

2.6.1

Stepper motor

16

2.6.2

Servo motor

16

2.6.3

DC motor

17

2.7.1

The diagram of basic H-bridge

17

2.7.1.1 The interfacing diagram

18

2.7.1.2 L293D IC chip

19

2.8

LCD

19

2.9.1

Proteus VSM

20

2.9.2

ISIS 7 Professional user interface

21

2.9.3

ARES 7 Professional user interface

21

2.9.4

Components selection

22

2.9.5

Parameter settings

22

xiv

2.9.6

Simulation buttons

23

2.10.1

CCS C Compiler

23

2.10.2

PIC C Compiler user interface

24

2.10.3

Create new file/project

24

2.10.4

Example program

25

2.10.5

Compile summary

25

3.2

Project flow chart

28

3.3

System flow chart

29

3.3.1.1 The flow of the process in the system

30

3.4.1

The diagram of hardware assembly done

31

4.1.1

The system diagram with fully explanation

33

4.2.1.1

The designed IR sensor circuit

36

4.2.1.2 Example of IR module with pins/terminals

37

4.2.1.3

37

The diagram of suggested arrangement IR module

4.2.2.1 The designed buzzer circuit

38

4.2.3.1 The designed lighting alarm circuit

39

4.2.4.1

The designed voltage regulator circuit

40

4.2.5.1

The designed LCD circuit interface with PIC16F877A circuit

41

4.2.6.1

The designed motor circuit interface with PIC16F877A circuit

44

4.2.7.1

The designed overall PIC16F877A interfacing circuit

46

4.3.1.1 The simulation result give value of 5V

47

4.3.2.1

The result after PIC16F877A being triggered

48

4.3.2.2

The result after PIC16F877A triggered to back normal condition

49

4.4.1

The programming result

52

4.5.1.1

The sensor circuit

53

4.5.1.2

The sensor circuit on PCB

53

4.5.1.3 The main circuit

54

4.5.1.4 LCD show the notification of closing the gate

55

xv

4.5.1.5 The gate motor used

55

4.5.1.6 The sensor located at side of the railway track

56

4.5.2.1 The prototype of model railway gate system

57

4.5.2.2 The prototype of model railway gate system

58

xvi

LIST OF APPENDICES

NO.

TITLES

PAGE

A

Gantt Chart

63

B

Microchip PIC16F87XA Data Sheet

65

1

CHAPTER I

INTRODUCTION

1.1

Project Introduction
In general, this project utilizes the importance of microcontroller as a main

design. It used to provide improvement into manual system that exist nowadays.

Microcontroller is a small unit of controller that acted following the instruction
programmed. All the circuits included in this prototype were designed following the
suitability of PIC16F877A.

This automatic railway gate system was operated after signal received from the
IR sensor. This signal used to trigger the PIC16F877A for operating the gate motor and
alarm indicators by instruction programmed.

Electronic applications used to enable this system operated in automatic mode.
The computer usage must be fully utilized to building up a system that encourage
implementing of the technology.

2
1.2

Project Objectives
The microcontroller (PIC16F877A) is use to demonstrate the integration of computer

method in railway gate operation.The objectives of this project are:

i.

To develop a prototype of railway gate that function automatically by using
microcontroller.

ii.

To develop an interfacing program for the integration part of microcontroller
operation.

iii.

To design an automatic railway gate control by using microcontroller.

Furthermore, this project is aimed to replace the gatekeepers with an automatic
system. It is develop to apply the structure of interfacing program in between to give a
lot of advantages.

1.3

Problem Statement
Nowadays, the railway gate is operating by manual operation. It is operating in

the area that there are railway line junction with the road. The railway gate management
has to employ workers to be on duty for control the operation. Due to this, the worker
will manually open and close the gate with under supervision.

This prototype will introduce the automatic railway gate operation. This system
will make improvement towards the manually operation before this. Human supervision
will be considered if there are problems occurred while this system was operated.

This is an idea to perform computer integration with mechanical structure to
simulate what the system can do. Control system with computer applications will make
the management or consumer become more effective. Therefore, this is the best example
in develop railway gate management system become more efficient.

3
1.4

Scope of Works
This project covered the operation of automatic railway gate control by using

microcontroller (PIC16F877A). The circuits involved such as power supply, IR sensor,
light and buzzer, gate motor and LCD display.

All of these operations will be combining to demonstrate the operation of
microcontroller (PIC16F877A).

The operations of microcontroller works follow the instruction programmed. The
combining circuits were constructed on Proteus software to seen whether that circuits
was right or not. After that, the hardware part was constructed after all the simulation
being done.

IR sensor circuit is providing signal to triggered the PIC16F877A. The sensed
signal wills active the gate motor and LCD display. Alarm and indication light circuit
was provided as additional part of this system.

Additional elements can be added without affecting the remaining elements. This
allows the flexibility of the developed system.

4
1.5

Methodology
This project began with the research of the proposed title. The result of that

research is then discussed with the supervisor. Once the title of project was approved,
the background of study for this project was explored.

PIC16F877A was chosen as a microcontroller. Then, the circuits’ simulation was
performed. In the other hand, the instruction programmed also being built for the
interfacing part. After all being settled, the construction of hardware part was started
after the components were being chosen.
In all the steps done there are troubleshooting part to resolve the problems
facing. Between hardware part and instruction programmed built, there are integrated
step that allows the PIC16F877A to simulate all the operations of the system.

After all the part is complete to built, some analysis should being made to show
what the solution of the problems occurred. It involving the comparison between the
research that had been done before this.

5
1.6

Report Structure
Chapter 1 introduced the project as a whole. The early and basic explanations

were mentioned in this chapter. This chapter consisted of the project introduction and
objectives, problem statements, scope of work, and the simplified methodology.

Chapter 2 is literature review. Past projects system were taken into consideration
when completing this chapter. The ways those projects and researches had been done
were compared with what this project. These comparisons were done to understand what
this project is all about and where it stands.

Chapter 3 is methodology. It explained how this project came to be. This chapter
explained the part most important of all, the flow this project. What had been researched
and what needed to be done was explained in this chapter.

Chapter 4 concentrated on the result and discussion of this project. What had
been done was explained in diagrams and written programs. The expected results also
mentioned in this chapter.

Chapter 5 was the final chapter in this report. The conclusions and
recommendations were placed in this chapter. In other words, the conclusion was the
summary of what had been done throughout this project. After the project was done,
recommendations were made and any expansions or upgrades that might be done in the
future were suggested.

6

CHAPTER II

LITERATURE REVIEW

2.1

Previous System
At present scenario, in the level crossing line the railway gate is operated

normally by a gate keeper. This happen when the railway line is cross over the road and
there are a gate that have to be controlled. The gate keeper work after receiving the
information about the train arrival from the nearer station. When the train starts to leave
the station, the particular station delivers the information to give the signal for gate
keeper to get ready. This is the operation are followed for operating the railway gates.

In addition, this automatic railway gate system can contribute a lot of benefit
either to the road user or to the railway management. This type of gate can be
implementing in the level crossing where the chances of accidents are higher. The
computer integration will be use to provide addition in the latest technology.

7
2.2

Block Diagram Description

Figure 2.2.1: Block diagram of the system

This prototype of project demonstrated the Automatic Railway Gate Control by
Using Microcontroller (PIC16F877A). The sensors are fixed at the certain distance on
both sides of the gate, that is before the train arrive and after the train departure. The
sensed signal is send to the microcontroller (PIC16F877A) and checked whether there
are vehicles or people between the gate. At the same time, alarm and indication light
signal are provided to the road users to warn the closing of gates.

In sequences, the gate motor will move forward direction to close the gate. It will
stay closed at certain time until the train has crossed the gate and reached the second
sensor activate the motor in backward direction so the gate will open.

8
Lighting signal also provided at the certain distance as pre cautionary step for
driver. Meanwhile, the nearer station also will provide an indication alarm to remind
them about the crossing train. If anything happened at the gates, this alarm will alert the
station. LCD display will show the arrival of the train to cross the gate as additional
features of this system.

Sensor

LCD

Motor
PIC16F877A
Microcontroller

Buzzer

Lighting
Alarm

Figure 2.2.2: The functionality between microcontrollers