SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat...

22
AN ADVANCED PARKING SYSTEM DESIGN VIA MICROCONTROLLER ATMEL AT89C52 SIA SOONG KEE UNIVERSITI TEKNOLOGI MALAYSIA

Transcript of SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat...

Page 1: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

AN ADVANCED PARKING SYSTEM DESIGN VIA

MICROCONTROLLER ATMEL AT89C52

SIA SOONG KEE

UNIVERSITI TEKNOLOGI MALAYSIA

Page 2: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

PSZ 19:16 (Pind. 1/97)

BORANG PENGESAHAN STATUS TESIS ♦

JUDUL : AN ADVANCED PARKING SYSTEM DESIGN VIA MICROCONTROLLER ATMEL

SESI PENGAJIAN : 2005/2006

Saya SIA SOONG KEE

(HURUF BESAR)

mengaku membenarkan tesis (PSM/Sarjana/Doktor Falsafah)* ini disimpan di Perpustakaan Universiti Teknologi Malaysia dengan syarat-syarat kegunaan seperti berikut:

1. Tesis adalah hakmilik Universiti Teknologi Malaysia. 2. Perpustakaan Universiti Teknologi Malaysia dibenarkan membuat salinan untuk tujuan

pengajian sahaja. 3. Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara

institusi pengajian tinggi. 4. ** Sila tandakan ( )

CATATAN: * Potong yang tidak berkenaan.

** Jika tesis ini SULIT atau TERHAD, sila lampirkan surat daripada pihak berkuasa/organisasi berkenaan dengan menyatakan sekali sebab dan tempoh tesis ini perlu dikelaskan sebagai SULIT atau TERHAD.

♦ Tesis dimaksudkan sebagai tesis bagi Ijazah Doktor Falsafah dan Sarjana secara penyelidikan atau disertasi bagi pengajian secara kerja kursus dan penyelidikan, atau Laporan Projek Sarjana Muda (PSM).

SULIT

TERHAD

TIDAK TERHAD

UNIVERSITI TEKNOLOGI MALAYSIA

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

(TANDATANGAN PENYELIA) (TANDATANGAN PELAJAR)

Alamat Tetap: 9F, JALAN MERAK 4, 96000 SIBU, SARAWAK.

Tarikh: 4 MEI 2006 Tarikh: 4 MEI 2006

PM. DR. RASHDI SHAH BIN AHMAD

Nama Penyelia

Disahkan oleh

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

Page 3: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

“I hereby declare that I have read this thesis and in my opinion this thesis is

sufficient in terms of scope and quality for the award of the degree of Bachelor of

Science and Education (Physics)”

Signature : _________________________________

Name of Supervisor : PM. DR. RASHDI SHAH BIN AHMAD

Date : ____________4 MAY 2006____________

Page 4: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

AN ADVANCED PARKING SYSTEM DESIGN VIA MICROCONTROLLER

ATMEL AT 89C52

SIA SOONG KEE

A report submitted in partial fulfillment of the requirement for the award of the

degree of Bachelor of Science and Education (Physics)

Faculty of Education

Technology University of Malaysia

MAY 2006

Page 5: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

ii

“I declare that this thesis entitle “An Advanced Parking Concept System Design Via

Microcontroller ATMEL AT 89C52” is the result of my own research except cited in

reference. The thesis has not been accepted for any degree and is not concurrently

submitted in candidature of any other degree.”

Signature :

Name of Student : SIA SOONG KEE

Date : 4 MAY 2006

Page 6: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

iii

Á ma famille aimée qui s'linquiètent assez pour

Rester à activement

Impliqué dans mon education

~ To my beloved family who care enough

to stay actively involved in my education

Page 7: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

iv

ACKNOWLEDGEMENTS

The tremendous appreciation in this research and development went to my

supervisor, PM. Dr. Rashdi Shah Ahmad, who has provided me with numerous

advice and suggestion while carry on this project. He had given me some suggestion

to solve problem in time and always follow up what I have been done from time to

time.

I wish to acknowledge a deep appreciation to Mr. Ding, who has helped me

with the programming of microcontroller ATMEL AT89C52. He has given me some

advice on how to recognize microcontroller and what to know about microcontroller

for I am totally naïve about microcontroller.

Besides, I would like to extend my thanks to the Advanced Electronics

Laboratory of UTM for the supplement of some electronics components.

Part of my appreciation reserve for my family, especially my parents who

always concern about my progress and health for the reason I am not skillful in

electronics and hence have to spend much more time on this project. I would not

have motivation without their support and encouragement.

Thank you very much.

Page 8: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

v

ABSTRACT

This project is conducted with the objective to build up a concept on

Advanced Parking System to guide drivers in congested areas to the nearest parking

facility with empty parking spaces and to guide drivers within parking facilities to

empty spaces. This project consists of mainly three parts, which are: photoelectric

sensors, the linking of these sensors to a microcontroller, and lastly to the 7-segment

LED display. The 40 pins microcontroller used is the ATMEL AT89C52. It is the

central processing unit in the system. It is a low power, high performance CMOS 8-

bit microcomputer with 8K bytes of Flash programmable and erasable read only

memory (PEROM). It contains 256 bytes internal RAM, 32 programmable

input/output lines, 2 counters 16 bits and provides nonvolatile memory. The

AT89C52 is programmed using universal programmer, the ALL-11C2 by HI-LO

System Research Co. The photoelectric sensors can sense the existence of vehicle at

certain parking lot. Detection occurs when the target (vehicle) crosses the beam

between transmitter and receiver to indicate the output as 1 when the lot is empty

while 0 as the lot is being occupied. The sensors are the inputs while the LED

display is the output, which both are linked to the microcontroller AT89C52. Thus

LED display shows to the user the unit of parking lots available.

Page 9: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

vi

ABSTRAK

Projek ini dijalankan dengan tujuan membina dan merangka satu konsep yang

berdasarkan Sistem Meletak Kenderaan Pintar yang berupaya membimbing pemandu

kepada tempat letak kenderaan kosong yang paling dekat dalam sesebuah tempat

letak kenderaan yang sibuk dan sesak. Projek ini boleh terbahagi kepada tiga

bahagian yang utama, iaitu : pengesan fotoelektrik, penyambungan pengesan-

pengesan kepada mikropengawal dan akhir sekali pemapar LED yang memaparkan

maklumat kepada pemandu. Mikropengawal 40 pin yang digunakan ialah ATMEL

AT89C52 yang merupakan komponen utama dalam sistem ini. Mikropengawal ini

bertindak sebagai unit pemproses utama kepada seluruh sistem. Ia berkuasa rendah

dan setanding dengan mikrokomputer 8 bit CMOS yang berprestasi tinggi. Ia

mempunyai 8K bait ingatan aturcara dalaman bentuk Flash EPROM, 256 bait RAM,

32 talian masukan / keluaran, 2 pembilang 16 bit dan juga mempunyai ingatan yang

mantap. Ingatan Flash EPROM diprogramkan dengan menggunakan pengaturcara

universal, iaitu ALL-11C2 oleh HI-LO System Research Co. Pengesan fotoelektrik

boleh mengesan kewujudan kenderaan pada sesuatu tempat letak kenderaan.

Pengesanan berlaku apabila sasaran (kenderaan) melintasi arus sinaran di antara

pemancar dan pengesan untuk memberikan isyarat keluaran sebagai 1 apabila tempat

letak kenderaan adalah kosong dan 0 apabila tempat kosong diisi oleh kenderaan.

Pada bahagian mikropengawal AT89C52, pengesan-pengesan merupakan

sambungan masukan manakala pemapar LED adalah sambungan keluaran kepada

mikropengawal itu. Oleh itu, pemapar LED menunjukkan kepada pemandu bilangan

tempat letak kenderaan yang masih kosong.

Page 10: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

vii

CONTENTS

CHAPTER TITLE PAGE

SUPERVISOR DECLARATION

PAGE TITLE i

STUDENT DECLARATION ii

DEDICATION iii

ACKNOWLEDGEMENT iv

ABSTRACT v

ABSTRAK vi

CONTENTS vii

LIST OF TABLES x

LIST OF FIGURES xi

LIST OF SYMBOLS xiii

LIST OF ABBREVIATIONS xiv

CHAPTER 1 INTRODUCTION

1.1 The Concept of Advanced Parking System (APS) 1

1.2 Objective 4

1.3 Research Scope 4

1.4 Background of Study 5

Page 11: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

viii

CHAPTER 2 THEORY

2.1 Introduction 9

2.2 Photoelectric sensor 9

2.2.1 Basic Operation of Photoelectric Sensors 13

2.2.2 Modes of Detection 14

2.3 The Microcontroller ATMEL AT89C52 19

2.3.1 Block Diagram of ATMEL AT89C52 21

2.3.2 Pin Description 22

2.3.3 Oscillator Characteristics 26

2.3.4 Idle Mode 27

2.3.5 Power-down Mode 27

2.3.6 Program Memory Lock Bits 28

2.4 Programming the Flash 29

2.4.1 Programming Algorithm 30

2.5 Seven-segment Display 32

2.5.1 Concept and Visual Structure 32

2.5.2 Implementation 37

2.5.3 Alphabetic Display 38

CHAPTER 3 METHODOLOGY

3.1 Introduction 40

3.2 Infra Red Switch 40

3.2.1 Schematic Diagram of Infra Red Switch 42

3.2.2 Part List 43

Page 12: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

ix

3.3 Universal Programmer 44

3.3.1 Flash Programming Algorithm and Interface 45

3.3.2 Reading the Hex File 48

3.4 Advanced Parking System Circuit 49

3.5 Programming Language 52

3.6 Flow Chart 53

CHAPTER 4 RESULT, DATA ANALYSIS AND DISCUSSION

4.1 Introduction 54

4.2 Infra Red Switch Results 54

4.3 Flash Programmer Results 56

4.4 Advanced Parking System Design Results 57

CHAPTER 5 CONCLUSION

5.1 Conclusion 60

5.2 Research Limitation 60

5.3 Recommendation 62

REFERENCES 63

Page 13: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

x

LIST OF TABLES

TABLE NO TITLE

PAGE

2.1 Strengths and weaknesses of a thru-beam photoelectric 14

sensor

2.2 Strengths and weaknesses of a reflex photoelectric sensor 16

2.3 Types of photoelectric sensor 16

2.4 Alternate functions of Pin 1.0 and Pin 1.1 23

2.5 The alternate function of Port 3 24

2.6 Status of external pins during Idle and Power-down modes 28

2.7 Lock bit protection modes 28

2.8 The respective top-side marking and device signature codes 29

3.1 Programming modes 46

Page 14: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

xi

LIST OF FIGURES

FIGURE NO TITLE PAGE

1.1 Entering Smart Park garage. Ultrasonic sensors mounted

over each parking space monitor the vacancy status of

each space; an LED sign indicates the number of space

available in each row 2

1.2 An example of an LED sign indicating the number of spaces

available in this row 2

1.3 Exiting Smart Park garage 3

2.1 Photoelectric sensors 11

2.2 Different mode of photoelectric sensor 11

2.3 Photoelectric sensor operation 13

2.4 Thru-beam operation 14

2.5 Reflex operation 15

2.6 Pin configuration of AT89C52 microcontroller 20

2.7 Block diagram of ATMEL AT89C52 microcontroller 21

2.8 Oscillator connections 26

2.9 External clock drive configuration 26

2.10 Forward biased LED 32

2.11 Current / voltage (GaAsP) 33

2.12 Luminous intensity / current (GaAsP) 34

2.13 Relative intensity wavelength (GaAsP) 34

2.14 Series resistor 35

2.15 Interconnection methods 35

Page 15: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

xii

2.16 A typical 7-segment LED display component, with

decimal point 37

3.1 An infra red switch 41

3.2 The schematic diagram of an infra red switch 42

3.3 A common universal programmer with functions

description 45

3.4 Programming the Flash 47

3.5 Verifying the Flash 47

3.6 Block diagram of the overall Advanced Parking System 50

3.7 The Advanced Parking design control circuit 51

3.8 Programming language for AT89C52 52

3.9 Flow chart of overall setting operation 53

4.1 The LED turn on when there is no object blocking the

beam between transmitter and receiver 55

4.2 The LED turn off when the beam between transmitter and

receiver is blocked 55

4.3 Universal programmer, ALL-11P2 by HI-LO System

Research Co. Ltd. 56

4.4 Writing the Flash Memory 57

4.5 An Advanced Parking System concept design 58

4.6 A view on the base of prototype consisting of switches and

microcontroller 58

4.7 A view on the finished prototype with two cars parking in

the lots and LED displays will show the empty parking lots

left 59

4.8 The LED displays showing two more lots left when another

car goes in 59

Page 16: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

xiii

LIST OF SYMBOLS

A - Ampere

C - Capacitor

F - Farad

Hz - Hertz

K - Kilo (103)

µ - Micro (10-6)

m - Mille (10-3)

Ω - Ohm

P - Pico (10-12)

R - Resistor

Vcc - Supply Voltage

V - Voltage

Page 17: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

xiv

LIST OF ABBREVIATIONS

ALE - Address Latch Enable

APS - Advanced Parking System

BSY - Busy

CLK - Clock

CMOS - Complementary Metal-Oxide Semiconductor

CPU - Central Processing Unit

CTRL - Control

DB - Data Bit

DC - Direct Current

DIP - Dual In-line Packages

E - Enable

EA - External Access Enable

EL - Emitting Light

EPROM - Erasable and Programmable Read-Only-Memory

GND - Ground

HI / H - High

IC - Integrated Circuit

I/O - Input/Output

INT - Interrupt

LB - Lock Bit

LCD - Liquid Crystal Displays

LED - Light Emitting Diode

LO / L - Low

LSB - Least Significant Bit

MPU - Microprocessor Unit

Page 18: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

xv

MSB - Most Significant Bit

PCB - Printed Circuit Board

PROG - Program

PROM - Programmable Read-Only-Memory

PSEN - Programme Store Enable

RAM - Random Access Memory

RDY - Ready

ROM - Read-Only-Memory

RST - Reset

RXD - Serial Input Port

SFR - Special Function Registers

TTL - Transistor-Transistor Logic

TXD - Serial Output Port

VMS - Variable Message Signs

XTAL - Crystal

Page 19: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

CHAPTER 1

INTRODUCTION

1.1 The Concept of Advanced Parking System (APS)

Advanced Parking Systems obtain information about available parking spaces,

process it and then present it to drivers by means of variable message signs (VMS). The

information may also be presented via phone, the Internet, or in-vehicle navigation

systems. APS is used in two ways: to guide drivers in congested areas to the nearest

parking facility with empty parking spaces and to guide drivers within parking facilities

to empty spaces. Although the former function is more common, guidance systems

within parking lots are becoming more common. This growing number of guidance

systems addresses drivers' need for more information about the position and number of

the spaces that are actually available within a parking structure. These systems avoid

time and fuel from wasted while searching for empty spaces and helps the car park

operate more efficiently.

The need for APS is most prominent in highly dense areas, where the search for

parking facilities congests and interrupts traffic flows. European cities have shown the

most interest in APS, having implemented it since the late 1970’s. Among European

and Asian cities with these systems are Frankfurt am Main and Koeln, Germany; Bristol,

UK; Ghent, Belgium; and Yokahama and Toyota, Japan. American cities have only

begun testing APS in the past decade. The systems have been implemented in St. Paul,

Minnesota, Pittsburgh, and Baltimore.

Page 20: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

2

Figure 1.1 : Entering Smart Park garage. Ultrasonic sensors mounted over each

parking space monitor the vacancy status of each space; an LED sign

indicates the number of spaces available in each row.

Figure 1.2 : An example of an LED sign indicating the number of spaces available

in this row.

Page 21: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

3

Figure 1.3 : Exiting Smart Park garage.

An Advanced Parking System uses the latest technology in designing a parking

system to provide convenience to drivers who congest in a certain parking area.

Sometime we will feel frustrated when we fail to find a parking space especially at

shopping mall. Some even spent hours just to look for a parking lot. After that we would

not have any mood to shop anymore,

Although the Advanced Parking System is widely used all around the world, but

in Malaysia, we still cannot notice a single parking system applies such kind of

technology. Even our neighbour country, Singapore has started using it and it brings

effective result in solving congestion problem and is welcomed by the public. Knowing

the fact that the amount of vehicles in Malaysia is in the increase, it is the time to

introduce Advanced Parking System at congested parking places in Malaysia to reduce

the problem of taking long time just to wait for an empty parking lot.

One microcontroller ATMEL AT89C52 was chosen for the purpose in preceding

this final project. This device is manufactured using ATMEL’s high-density non-volatile

memory technology and is compatible with the industry-standard MCS-51 instruction set

and pinot.

The main purpose of this project is to design an Advanced Parking System with

the monitoring and controlling by the microcontroller. The powerful microcontroller is

Page 22: SIA SOONG KEE - Faculty of Education€¦ · Saya SIA SOONG KEE ... Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara ... over each parking space monitor

4

capable to receive the outputs from sensors and give the information needed after

process. Definitely the self-control automation parking system can apply to the parking

system to bring convenience.

1.2 Objective

The objective of this project is to design and erect a circuit system as well as

programme the ATMEL AT89C52 microcontroller for the purpose to build an intelligent

parking system that reduce the problem of congestion by leading the drivers to their

nearest parking lot.

I will try to show out how “intelligent” the parking system can be and is suitable

to apply into the real parking system with their advantages.

1.3 Research Scope

The continuous experiments will encourage the researchers to achieve the

objective. The research scope of this preceding project is to do a detail literature on the

Advanced Parking System concept. To be a researcher with minimum supervision, I had

to get the basic inspiration before starting the experiment. However, my supervisor had

given me a suggestion to do a research on a parking system can bring convenience for

those who always face congestion problem. Then I had to planning a parking system

using sensors with the guide of my supervisor.

Afterward I had to programme the Flash memory of the ATMEL AT89C52

microcontroller either with a in-circuit programmer or an universal programmer. Being

at the programming part, I had to think of interfacing the sensing circuit to the

microcontroller. Finally, for the display part, I had to choose either using LED display o

LCD display depend on my budget.