0% found this document useful (0 votes)
92 views

Smart Car Parking System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Smart Car Parking System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 174

Palestine Polytechnic University

College of Engineering and Technology


Electrical Engineering Department

Graduation Project

Smart Car Parking System

Project Team
Riham Walled Zalloum Maysa Al_Mohtaseb
Jihan Khamayseh

Project Supervisor
Eng. Mazen Zalloum

Hebron-Palestine
June-2007
‫ﺟﺎﻣﻌﺔ ﺑﻮﻟﯿﺘﻜﻨﻚ ﻓﻠﺴﻄﯿﻦ‬
‫اﻟﺨﻠﯿﻞ – ﻓﻠﺴﻄﯿﻦ‬
‫ﻛﻠﯿﺔ اﻟﮭﻨﺪﺳﺔ واﻟﺘﻜﻨﻮﻟﻮﺟﯿﺎ‬
‫داﺋﺮة اﻟﮭﻨﺪﺳﺔ اﻟﻜﮭﺮﺑﺎﺋﯿﺔ واﻟﺤﺎﺳﻮب‬

‫‪Smart Car Parking System‬‬

‫ﻣﯿﺴﺎء اﻟﻤﺤﺘﺴﺐ‬ ‫رھﺎم زﻟﻮم‬


‫ﺟﯿﮭﺎن ﺧﻤﺎﯾﺴﺔ‬

‫ﺑﻨﺎء ﻋﻠﻰ ﻧﻈﺎم ﻛﻠﯿﺔ اﻟﮭﻨﺪﺳﺔ واﻟﺘﻜﻨﻮﻟﻮﺟﯿﺎ وإﺷﺮاف وﻣﺘﺎﺑﻌ ﺔ اﻟﻤﺸ ﺮف اﻟﻤﺒﺎﺷ ﺮ ﻋﻠ ﻰ اﻟﻤﺸ ﺮوع و ﻣﻮاﻓﻘ ﺔ أﻋﻀ ﺎء‬
‫اﻟﻠﺠﻨﺔ اﻟﻤﻤﺘﺤﻨﺔ ﺗﻢ ﺗﻘﺪﯾﻢ ھ ﺬا اﻟﻤﺸ ﺮوع إﻟ ﻰ داﺋ ﺮة اﻟﮭﻨﺪﺳ ﺔ اﻟﻜﮭﺮﺑﺎﺋﯿ ﺔ واﻟﺤﺎﺳ ﻮب وذﻟ ﻚ ﻟﻠﻮﻓ ﺎء ﺑﻤﺘﻄﻠﺒ ﺎت درﺟ ﺔ‬
‫اﻟﺒﻜﺎﻟﻮرﯾﻮس ﻓﻲ اﻟﮭﻨﺪﺳﺔ ﺗﺨﺼﺺ أﻧﻈﻤﺔ ﺣﺎﺳﻮب‪.‬‬

‫ﺗﻮﻗﯿﻊ اﻟﻤﺸﺮف‬
‫‪.................................................‬‬

‫ﺗﻮﻗﯿﻊ اﻟﻠﺠﻨﺔ اﻟﻤﻤﺘﺤﻨﺔ‬

‫‪....................................‬‬ ‫‪.....................................‬‬ ‫‪...................................‬‬

‫ﺗﻮﻗﯿﻊ رﺋﯿﺲ اﻟﺪاﺋﺮة‬


‫‪...............................................‬‬

‫‪ii‬‬
Dedication

To our parents who


spent nights and days doing their best
to give us the best...

To all students and who


Wish to look for
the future...

To who love the knowledge and


Looking for the new
in this world...

To who carry candle of science


To light his avenue
of life...

To our beloved country Palestine...

To all of our friends…

Riham Walled Zalloum


Maysa Al_Mohtaseb Jihan Khamayseh

iii
Acknowledgments

To our great supervisor, who offered his best for this project to see light
through his instructions and advices, Eng. Mazen Zalloum with all his kindness and
wisdom we thank him.

We would also like to thank every person who offered anything to success
this work; we sincerely believe that this work wouldn't exist without his inspiration.
Great thanks to our college for his support and help, and any one who help us in our
project.

iv
Abstract

This project is involved in design and implementation of a smart parking


system. The system will direct the driver to the available parking spaces in each floor
when entering the parking. Then, from the floor the driver will be derived to the
parking available slots.

The project will be implemented with the 8051 microcontroller for all the
necessary controlled hardware components are used such as sensors display and
motor for our system.

‫ اﻟﻨﻈ ﺎم ﺳ ﻮف ﯾﻮﺟ ﮫ اﻟﺴ ﺎﺋﻖ إﻟ ﻰ‬.‫ھﺬا اﻟﻤﺸﺮوع ﻣﮭﺘﻢ ﻓﻲ ﺗﺼﻤﯿﻢ وﺗﻄﺒﯿ ﻖ ﻧﻈ ﺎم ذﻛ ﻲ ﻹﯾﻘ ﺎف اﻟﺴ ﯿﺎرات‬
‫ ﺛ ﻢ ﻣ ﻦ اﻷرﺿ ﯿﺔ ﯾﺘﻮﺟ ﮫ اﻟﺴ ﺎﺋﻖ إﻟ ﻰ‬.‫أﻣ ﺎﻛﻦ اﻟﻮﻗ ﻮف اﻟﻤﺘ ﻮﻓﺮة ﻓ ﻲ ﻛ ﻞ أرﺿ ﯿﺔ ﻋﻨ ﺪﻣﺎ ﺗ ﺪﺧﻞ اﻟﺴ ﯿﺎرات ﻟﻺﯾﻘ ﺎف‬
.‫اﻹﯾﻘﺎف ﻓﻲ اﺣﺪ أﻻﻣﺎﻛﻦ اﻟﻤﺘﻮﻓﺮة‬

‫ ﻣﯿﻜﺮوﻛﻮﻧﺘﺮوﻟﺮ ﻟﻠﺘﺤﻜﻢ ﺑﺠﻤﯿﻊ اﻷﺟﺰاء اﻷﺧﺮى اﻟﺘﻲ ﺳﻮف ﯾﺘﻢ‬٨٠٥١ ‫اﻟﻤﺸﺮوع ﺳﯿﺘﻢ ﺗﻄﺒﯿﻘﮫ ﺑﺎﺳﺘﺨﺪام‬
.‫ واﻟﻤﻮﺗﻮر‬،‫ وأﺟﮭﺰة اﻟﻌﺮض‬،‫اﺳﺘﺨﺪاﻣﮭﺎ ﺑﺎﻟﻤﺸﺮوع ﻣﺜﻞ اﻟﻤﺠﺴﺎت‬

v
TABLE OF CONTENTS

DEDICATION III
ACKNOWLEDGMENT IV
ABSTRACT V
TABLE OF CONTENTS ERROR! BOOKMARK NOT DEFINED.
LIST OF TABLES XI
LIST OF FIGURES XII
CHAPTER ONE 1
INTRODUCTION 1
1.1 Preface.. ………………………………………………….…………………. .2
1.2 Project Importance……………………………………………………………3
1.3 Review of Literature………………………………………….…………….. 4
1.4 Project Scheduling.…………………………………..…………...……..…… 5
1.5 Project Cost ………………………………………………..………………... 7
1.6 Road Map…………………………………………………………………… 8

CHAPTER TWO 11
THEORETICAL BACKGROUND 11
2.1 Preface……………….…………………………………………………………….. 11
2.2 Project Components ……………..………………………………………..... 11
2.2.1 8051 Microcontroller…………………………………………….…………..........
12
2.2.1.1 Introduction to Microcontroller …………….…………………………. 12
2.2.1.2 Advantages of a Microcontroller………………………………………………13
2.2.1.3 The Intel 8051………………………………………………………… 14
2.2.1.3.1 Why we use choose 8051 microcontroller board………………....16
2.2.1.3.2 Programmable Peripheral Interface (PPI). .……………………..…………
16
2.2.2 Sensor (Switch)……………………………………………………………17

vi
2.2.3 Motor…………………………………………………………………… 18
2.2.4 LCD.………...………………………………………………………….. 19
2.2.5 Gate……………….……………………………………………………. 21
2.2.6 Spring.…………………… ………………..…………………………… 21
2.2.7 Force on Spring……….…………………………………………………….
22
2.2.8 General Parking Diagram……….………………………………………….
22

CHAPTER THREE 25
DESIGN CONCEPTS 25
3.1 Project Objectives……………………………………………..…………….. 26
3.2 Project Main Hardware Components….…………………….……….……… 26
3.3 General Block Diagram…………………………………………….………. 27
3.3.1 Floor Subsystems…………………………………………………………28
3.3.2 Entrance System ………………………………………………………..2 28
3.3.3 8051 Microcontroller System ………………………………………….. 29
3.4 Interfacing ………………………………………………………………….. 30
3.5 Motors ……………………………………………………………………… 31
3.6 How System Work …………………………………………………………. 32
3.6.1 Microcontroller with Switch, LCDs and Motors……………………… 32
3.6.2 The Switch with Microcontroller…...……………………………….….35
3.6.3 The LCDs with Microcontroller………..……………………………… 36
3.6.4 The Motor with Microcontroller…..……………………………………36
3.6.5 The Spring with Switch…..…………………………………………… 37
3.6.6 The Gate with The Motor…...…………………………………………. 37

CHAPTER FOUR 36
HARDWARE SYSTEM DESIGN 38
4.1 Preface...……………………………… ………………………….………... 39
4.2 The Units Design……….………………………………….……..……….... 39

vii
4.2.1 Sensors (Interlocking Push Buttons)…………………………………… 40
4.2.2 DC_motor and H_Bridges ……………………………………….……… 42
4.2.2.1 LCDs ……………………………………………………….………. 42
4.2.4 Control Unit…………………………………………………………..….. 41
4.2.5 Serial Ports …………….……………………………………………..…. 44
4.2.4.1.1 Pins and Wires…………………………………………….……….. 45
4.2.4.1.2 Data Flow…………………………………….……………………..46
4.2.4.2 Controlling the Motor………………………………………………… 47
4.2.4.3 Electrolytic Capacitor………………………………………………….. 48
4.2.4.4 (74244) Buffer …...………………………………………………….. 48
4.2.5 Over All System Unit (Application Unit)…………………………..…… 49
4.2.5.1 Interfacing Circuit ………………………………………………….. 49
4.2.5.1.1 Interfacing Sensors with Microcontroller (8051) board ……….. 50
4.2.5.1.2 Microcontroller 8051 Interfacing with LCD Display…………. 51
4.2.5.1.3 Microcontroller 8051 Interfacing with Motors………………… 53
4.2.5.1.4 Microcontroller System Interface….……………………………. 54
4.2.6 Parallel Port …………………………………………………………… 55
4.2.6.1 Hardware….……………………………………………………….. 56
4.2.6.2 Parallel Port Registers..……………………………………………..57
4.2.6.3 Where this Registers ………………………………………………. 58
4.3 Overall System Design …………………………………………………….. 59

CHAPTER FIVE 62
SOFTWARE SYSTEM DESIGN 62
5.1 Preface….…………………………….…………………………………….. 63
5.2 Software Requirement….…………………………………………….…….. 63
5.2.1 Win 95/98/Me/NT/2000/XP Compatible Software ……………………. 63
5.2.2 HyperTerminal………………….…………………………………….…. 64
5.2.3 Standard Serial Cable (Straight Through)…..…….….………………….. 67

viii
5.2.4 Assembler or 'C' Compiler, Usually As31 or SDCC…………………… 68
5.2.5 Text Editor Program…..…………………………………………………. 70
5.3 Function Description…….………………………………………………..… 70
5.3.1 To Use PPI set Ports and System Parameters………………………….…70
5.3.2 Timer Initialization...………………………………………………….… 71
5.3.2.1 Code for Enable Timer ……………………………………………… 72
5.3.3 Display Data on LCD…..…………………………………………………72
5.4 Serial Interfacing between the Microcontroller and PC…..…………………. 73
5.5 General System Flowchart…...……………………………………………….73
5.6 System Operational Flowchart ……………………………………………… 75
5.6.1 Sensors of Gates Flowchart ……………………………………………... 75
5.6.2 Floor One Flowchart ……………………………………………………. 77
5.6.3 Floor Two Flowchart ……………………………………………………. 79
5.6.4 Main LCD Flowchart …………………………………………………… 81
5.6.5 Motor1 and Motor2 Flowchart …………………………………………...82
5.7 Algorithms and Pseudocode ………………………………………………… 84

CHAPTER SIX 101


IMPLEMENTATION AND TESTING 101
6.1 Preface …………….…………………………………………………..……..102
6.2 Implementation ………………….…………………………………….…… 102
6.3 Testing …………………………..………………………………….………. 103
6.3.1 Testing 8051 Downloading Programs………………..…………….…….103
6.3.2 Motors and H-Bridge Testing.………………………………….……… 104
6.3.2.1 Option One Using C Language for Motor Testing ………………… 106
6.3.2.2 Option Two Using VB.net for Motor Testing ……………….……... 107
6.3.3 Switches Testing…..………..…………………………………….……...107
6.3.3.1 Option One Using C Language for Switching Testing.……….……...108
6.3.3.2 Option Two Using VB.net for Switching Testing ………………….. 108

ix
6.3.4 LCDs Testing …………………………………………………………….109
6.3.4.1 Option One Using C Language for LCD Testing ………………….. 109
6.3.4.2 Option Two Using VB.net for LCD Testing ……………………….. 109
6.3.5 Access the Parallel Port Using VB.net ………………………………… 109
6.3.5.1 Testing Output Ports in VB.net …………………………………….. 109
6.3.5.2 Testing Input Port in VB.net ……………………………………….. 110
6.4 Implementation and Testing for Integrated System …………………….….. 111

CHAPTER SEVEN 112


CONCLOUSIONS AND FUTURE WORK 112
7.1 Preface…..…………………………………………………………………… 113
7.2 Conclusions…………………………………………………………………..114
7.2.1 Problems…….……………………………………………………………115
7.2.1.1 Hardware Problems….………………………………………………..115
7.2.1.1 Software Problems……………………………………………………115
7.3 Future Work…..………………………………………………………………116

REFERENCES 117
APPENDICES 118

x
LIST OF TABLES

TABLE PAGE
TABLE 1.1: PROJECT ACTIVITY BAR CHART (FIRST SEMESTER) ……………………… 6
TABLE 1.2 PROJECT ACTIVITY BAR CHART (SECOND SEMESTER)………………… 6
TABLE 4.1: SERIAL PORT PINS………………………………………………………… 46
TABLE 4.2: OPERATION OF THE DC MOTOR DRIVING CIRCUIT ……………………. 47
TABLE 4.3: CONTROL WORD OF THE PPI ……………………………………………… 54
TABLE 4.4: PARALLEL PORT SIGNAL LINE ………………………………………. 57
TABLE 4.5 REGISTER ADDRESSES OF LPT1 AND LPT2: ………..………………. 58

xi
LIST OF FIGURES

FIGURE PAGE

FIGURE 2.1: 8051……………………...…………………………………………..13


FIGURE 2.2: THE 8051 MICROCONTROLLER KIT ………….…………………….. 1 6
FIGURE 2.3: SWITCH ……………………………………………………………………17
FIGURE 2.4 SWITCH SENSOR ……….………………………………………………. 18
FIGURE 2.5: MOTOR ……..………………………………………………………..19
FIGURE 2.6: LCD DISPLAY …………………….……………………………………. 20
FIGURE 2.7: THE GATE ………………………………………………………………. 21
FIGURE 2.8: THE SPRINGS ……………………….…………………………………… 22
FIGURE 2.9: THE FIRST FLOOR ……………………………………………………….. 23
FIGURE2.10: THE SECOND FLOOR …………………………………………………24
FIGURE 3.1: GENERAL BLOCK DIAGRAM ………………………………….……. 28
FIGURE 3.2: FLOOR SUBSYSTEM …………………………………………………. 28
FIGURE 3.3: ENTRANCE SYSTEM …………………………….……………..…… 29
FIGURE 3.4: THE 8051 MICROCONTROLLER ……………………….….…………. 30
FIGURE 3.5: INTERFACING MAIN SYSTEM ………..................……….………….. 31
FIGURE 3.6: INTERFACING FLOOR 1..........................…………………………….. 31
FIGURE 3.7: DC MOTOR ………………………………………….……………… 32
FIGURE 4.1: SWITCH…………………………………………………….………..40
FIGURE 4.2: SERIAL PORT CABLE ……………………………………………….. 44
FIGURE 4.3: SERIAL PORT PINS ………………………….………………………...45
FIGURE 4.4: PC COM PORT ………………………………………..….…………..46
FIGURE 4.5: DC MOTOR CIRCUIT ……….……………………………………….. 47
FIGURE 4.6: SINGLE CAPACITOR ………………………….…………………….. 48
FIGURE 4.7: RESISTORS ………………………………………………………….. 48
FIGURE 4.8: 74244 BUFFER ……………………………………………………… 49
FIGURE 4.9: INTERFACING FLOORS SENSORS WITH 8051 MICROCONTROLLER ….. 50

xii
FIGURE 4.10: INTERFACING MAIN ENTRANCE AND EXIT GATE SENSORS WITH 51
8051 MICROCONTROLLER ……………………………………………………….
FIGURE 4.11: INTERFACING LCDS WITH 8051 MICROCONTROLLER ……..……… 52
FIGURE 4.12: INTERFACING MOTORS WITH 8051 MICROCONTROLLER ………….. 53
FIGURE 4.13: PARALLEL PORT REGISTER ……………………………………… 56
FIGURE 4.14: THE SYSTEM DESIGN CIRCUIT 1…………………………………… 60
FIGURE 4.15: THE SYSTEM DESIGN CIRCUIT 2………………………………….. 61
FIGURE 5.1: CONNECTION DESCRIPTION SCREEN………………………..………..64
FIGURE 5.2: CONNECT TO SCREEN …………………….………………………… 65
FIGURE 5.3: COM1 PROPERTIES ……………………………………………….…66
FIGURE 5.4: DIAL UP SCREEN …..…………………………………………………67
FIGURE 5.5: MS_DOS …………………………………………………………… 69
FIGURE 5.6: GENERAL FLOWCHART ….…………………………………………. 74
FIGURE 5.7: SENSORS OF GATES FLOW CHART……………………………………76
FIGURE 5.8: FLOOR ONE SENSORS FLOW CHART ……………………………..… 78
FIGURE 5.9: FLOOR TWO SENSORS FLOW CHART …………………….…………. 80
FIGURE 5.10: MAIN LCD FLOW CHART……………………….………………… 81
FIGURE 5.11: MOTOR1 FLOW CHART …..………………………………………. 83
FIGURE 5.12: MOTOR2 FLOW CHART ……………………………………………. 83
FIGURE 6.1: PORT TESTING EXAMPLE (LEDS) …………..…………………….. 103
FIGURE 6.2: MOTOR CIRCUIT …………………………… ……………………… 106
FIGURE 6.3A: SWITCH CIRCUIT OFF ………………………..……………………...107
FIGURE 6.3B: SWITCH CIRCUIT ON ……………………………………..……..…. 108
FIGURE 6.4: LCD TESTING ………………………………………..………………109
FIGURE 6.5: OUTPUT PORT TESTING …………………………………….………..110
FIGURE 6.6: INPUT PORT TESTING ………………………………..………………110

xiii
1
Introduction

1.1. Preface
1.2. Project Importance
1.3. Review of Literature
1.4. Project Scheduling
1.5. Project Cost
1.6. Road Map

١
Chapter One
Introduction

1.1 Preface

In this chapter introduces the general idea of the project, importance and
discuss some of the related projects.

The project smart car parking system is a microcontroller based smart parking
system. Usually, in large parking areas we need to search through the whole place for
space and then park the car. Our project aims to overcome this trouble. We want that
some sensors should be placed at space for each car. These sensors will be connected
to screen like LCDs through the microcontroller at the parking entrance via
microcontroller. The display would show whether or not space is there for more cars,
and if there is any, what the exact location of that space is. This would be carried out
by programming through the microcontroller.

So, the project take about general parking for all the people, consists of two
floors, and in each one the park has a place form which the car to enter the park and
another to leave it, the output of the system is displayed on LCDs the free places for
the cars that enter the park, we use for this push button switch, we will connect them
to the microcontroller to get the number of car in the park.

There will be a screen (LCD) on the place from which the car enter show if
the park is full or have places in it for another car, also show the number of empty
places and which places in each floor is empty, so the person can go to any empty
place and then put his car on it.

٢
On each place in each car park we will have sensors (switch) that show if the
place is empty or available, the screen of that park show that.

The system is consists of the microcontroller, the sensors, and the displays
(LCDs), all of them will be connected to each other in the project to have a complete
smart car parking system.

1.2 Project Importance

The importance of this project that the smart parking system will be more
comfortable, easier to locate empty parking spaces, without driving around the park.
Also, a chargeable system at the entrance will be implemented as a final stage of the
project. The system easily can be expanded to accommodate more floors as each of
parking floor is treated separately and report only the number of the available spaces
for parking.

The importance of the project view on more security, safe and more
intelligent parking that not require employee to work in it and the customers will
have enough information about how to use the park and in which space, then he
chose the place in the park he will go to and know the exact location of that space.

This help parking especially large parking to use it in very easy and perfect
way and it will encourage the customers to put their cars in it. We don't need to
search through the whole place for space and then park the car. Our project aims to
overcome this.

٣
1.3 Review of Literature

Transit-based smart parking in the San Francisco, bay area: an assessment if


user demand and behavioral effects.

The parking guidance information component of this system uses loop


detectors to monitor available parking spaces in facilities and then transmits
messages via VMS signs. The software uses historical data by time to predict parking
facility occupancy status. Planned improvements include forecasts of available
metered on-street parking and a parking reservation system via the Internet, phone,
or in-car terminal.

Another example of an advanced smart parking system is the Frottmaning U-


Bahn station park-and-ride lot (with 1,270 parking spaces) in Munich, Germany, on
the A9 Autobahn.

This system boasts three dynamic VMS screens along the nearby highway,
which indicate the number of parking spaces, real-time transit schedules, and traffic
news. Once motorists enter the parking facility, they are guided to the closest empty
parking space by a real-time surveillance and control system. The smart “directing”
system uses laser-scan detectors at entrance and exit lanes and ultrasound detectors at
each parking space.

Smart parking management systems that provide real-time information to


motorists about the number of available parking spaces in park-and-ride lots, the
departure time of the next train, and downstream roadway traffic conditions (e.g.,
accidents and delays) have been implemented in many cities in Europe and Japan.
More recently, several transits based smart parking management programs have been
proposed in the U.S.

٤
1.4 Project Scheduling

The project activities here depend on each other, so the task durations and
dependencies are the following:-

T1: Preparing to the project: here we introduce to start in the project and discuss with
the advisor to initialize the project, and preparing the group and evaluate the project
tasks and levels. At this period choosing project.

T2: The project searching and analysis: at this period we start the first step to search
and analysis the project and allocate information and data about the project levels
and sublevels, tasks and subtasks, there are many resources to searching and
analyzing the concepts.

T3: The project requirements analysis: the project has many equipments must be
provided and explained to implement the final project to achieve the system
requirements. The system has a hardware and software requirements which must be
achieved through the prototype and final presentation.

T4: Introduction to project and study the 8051 microcontroller system.

T5: Study and find the type of sensor we want and other hardware we require it.

T6: Theory background.

T7: Design concept.

T8: Writing the software and the implementation of the project.

٥
T9: Test the project: we will test the project and implement it to insure that the
system and user requirements levels are achieved or not, to adjust the problems and
errors in the project and can maintain it, and then try to test and execute it again

T10: Re_analyse and re-implement the project

T11: Final Project and presentation: the final project will be display completely
without any problem and achieve the highest level objectives.

T12: Documentation writing: the writing begins with us from the first step to the last
one in parallel.

Table 1.1: Project Activity Bar Chart (First Semester)


Task / Week 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
T1
T2
T3
T4
T5
T12

Table 1.2: Project Activity Bar Chart (Second Semester)


Task / Week 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
T6
T7
T8
T9
T10
T11
T12

٦
1.5 Project Cost

We purchase as a work group all of its equipments to complete the project


architecting and designing.

The project need both of hardware equipments and software programs that
runs on the microcontroller, so we will purchasing all needed electronic components
and parts and software programs.

 The Hardware Components, there are many electrical Chips and equipments
have to be provided:-

1. Resistors.
2. Capacitors.
3. Diodes.
4. Wires (10$).
5. 2 Optocouplers (2$).
6. 2 DC Motor (100$).
7. 30 sensor (micro-switch) (60$).
8. 8051 microcontroller development kit (300$).
9. 3 LCDs (9000$).
10. 3 PPI (15$).

 Software programs:-

1. ِAssembly, C Program it cost and visual Basic (700$).


2. Windows 98version or more it cost (500$).
3. Microsoft PowerPoint, word and Visio (300$).

٧
 Human cost:-

The team of the project consists of three students, work in 27 week, 70 hour
at a day and the work's hour costs 10$. So, the human cost equal (3X27X50X10
= 40500$).

The total cost: The total cost contains the hardware equipments and software
programs, the total cost reach about approximately (51487$).

Note: the Electronic equipments price is varied depending on the component


efficiency and the purchasing source and as the performance of the project increase
the cost increase.

1.6 Road Map

Report consists of seven chapters; the following is a brief description of the


topics that are covered in each chapter.

Chapter 1: Introduction

This chapter present general idea about the project and its importance, and
also literature review, system requirement, group dependency, project scheduling,
estimated cost.

Chapter 2: Theoretical Back Ground

This chapter talks in more details about the basic component used in the
project and theoretical back ground.

٨
Chapter 3: Design Concepts

This chapter details the design concepts, introduces project objectives, shows
the general block diagram of the system and explains how system works.

Chapter 4: Hardware System Design

This chapter presented out lines formal procedure for design, discuss design
options and justify those chosen for the project.

Chapter 5: Software System Design

This chapter handles the software related to our system, depicts flowcharts
about system operation.

Chapter Six: System Implementation and Testing

This chapter includes the implementation phase with the testing of these
phase. General hardware and software component tested and shown in this chapter.

Chapter Seven: Conclusion and Future Work

This chapter will provides the conclusions that will be concluded after
working the system, and suggestion for future work.

٩
2
Theoretical Background

2.1 Preface
2.2 Project Component.

١٠
Chapter Two
Theoretical Background

2.1 Preface

This working relates to a general smart parking system and in particular an


intelligent and electrical parking system based on working many objects in that park
without any human employee in it. Such as, to open the gate of the park when any
customer want to enter, and to know exactly where he will park his car from LCDs at
the entrance.

Gate has a motor to open and close it, LCDs to tell the customer which floor,
number of available spaces and what the exact location to park the car. So, we will
use a microcontroller, many LCDs, sensors, motor for each gate, and other hardware
devices.

This chapter will illustrate theoretical background for our project applications
in general and for each component in particularly, and how each component
communicate with other components, like the communication between the
microcontroller, sensors and LCDs.

2.2. Project Components

As we have mentioned in chapter one before, this project is fully constructed


over a smart car parking, that behave in an intelligent system, we have used many
hardware devices, the input comes from sensor and the output to the gate at the
entrance and at exit and to the LCDs .The basic unit is that the unit to control all of

١١
the application that we will use, it will be the microcontroller. One need of a
microcontroller is to perform and control all of that application that will be needed in
our smart car parking system.

In the following sections we will give an explanation of each component


(hardware device) that we will use in smart car parking system.

2.2.1. 8051 Microcontroller

2.2.1.1. Introduction to Microcontroller

The microprocessor is the little (single) chip is the heart of a computer; it


does all the computations like adding, subtracting, multiplying, and dividing.

The microprocessor might be a Pentium, a K6, a PowerPC, a Sparc or any of


the many other brands and types of microprocessors, but they all do approximately
the same thing in approximately the same way.

A microcontroller is an entire computer manufactured on a single chip. The


I/O and a memory subsystems contained in a microcontroller specialize these devices
so that they can be interfaced with hardware and control functions of the
applications. Since microcontrollers are powerful digital processor, the degree of
control and programmability they provide significantly enhances the effectiveness of
the application. Microcontrollers usually dedicated devices embedded within an
application.

Single-chip microcomputer indicates that the complete microcomputer


system. Microcontrollers are capable of storing and running the program that was
written, complied and downloaded into it. The main parts of a microcontroller in

١٢
generally consist of the Central Processing Unit (CPU), Read Only Memory (ROM),
Random Access Memory (RAM), input/output lines, serial and parallel ports,
registers, peripherals such as timers and watchdog circuits and signal conversion
circuits, counters, digital (A/D) converter and others...

Figure (2.1): 8051

2.2.1.2. Advantages of a Microcontroller

A microcontroller is a computer-on-a-chip used to control electronic devices.


It is a type of microprocessor emphasizing self-sufficiency and cost-effectiveness, in
contrast to a general-purpose microprocessor. A typical microcontroller contains all
the memory and interfaces needed for a simple application, whereas a general
purpose microprocessor requires additional chips to provide these functions.

A microcontroller is a single integrated circuit. It can store and run unique


programs very flexible and capability to carry out mathematical and logic functions
allows it to imitate complicated logic and electronic circuits.

١٣
2.2.1.3 The Intel 8051

This section is specializing for 8051 and we will present it details. Next,
different tasks related to this microcontroller, plus the problems faced and how they
were solved will follow.

The 8051 is the first microcontroller of the family introduced by Intel


Corporation at the end of the 1970s. The 8051 family are 8_bit controllers capable of
addressing 64K of program memory and separate 64K of data memory.

In our project we will use the 8051 development board which the 8051
development board provides an easy and low-cost way to develop 8051 based
microcontroller projects, without purchasing any other equipment, such as IC
programmers or emulators. The board comes loaded with PAULMON2, (is available
as assembly language source code or ready-to-run binary object code). This provides
a simple menu-based system that enables to download code into the RAM or Flash
ROM on the board. So the board will then run application instead of booting into the
PAULMON2 menu system. A jumper is provided, should you need to erase the Flash
ROM to make any changes.

The board features two 82C55 chips that provide 50 I/O lines and 8 LEDs, in
addition to the 10 lines from the 8051's port #1, and the 8051's bus lines. A second
serial connector is available, with a simple switching circuit, to make it easier to
develop applications.

8051 Features

 Standard 87C52 CPU clocked at 22.1184 MHz.

١٤
 50 I/O lines, All I/O lines are clearly labeled and available at the edge of the
prototype construction area.
 32k SRAM, program variables and code (24k usable for code download).
 30k Flash ROM, non-volatile program storage and data logging.
 High speed baud rates: 115200, 75600, 38400, etc. All standard baud rates
are supported (except 300 baud).
 Display port, works with standard character-based LCDs.
 Eight LEDs, controlled by 8 dedicated I/O lines (not shared with the 50 I/O
lines).
 Bus expansion with 4 chip select signals, for adding UARTs, A/D converters
and other bus-based peripheral chips.
 Unregulated, polarity-protected DC voltage input with 2 position terminal
block.
 PAULMON2 monitor for easy code development without additional
equipment.
 LCD Display Port
 The 8051 development board's LCD port provides the 14 signals needed for
standard character based LCD modules. A 20x2 display is available from
PJRC.

All of these features make it ideal for more advanced level A/D applications
in automotive, industrial, appliances and consumer applications. Also we can collect
many of our needs for the project in one chip, since we need memory to hold
digitized identification data, and modulation to modulate the carrier signal with the
identification data.

١٥
2.2.1.3.1 Why we use choose 8051 microcontroller board?

The 8051 development board provides an easy-to-use to develop 8051 based


microcontroller projects, without purchasing any other special equipment, such as IC
programmers or emulators.

We choose 8051 after search and comparison between it and other


microcontrollers that can be used in our project.

Figure (2.2): The 8051 Microcontroller Kit

2.2.1.3.2 Programmable Peripheral Interface (PPI)

The 82C55A is a high performance version of the industry standard 8255A


and is manufactured using a self-aligned silicon gate process. It is a general purpose
programmable I/O device which may be used with many different microprocessors.

١٦
There are 24 I/O pins which may be individually programmed in 2 groups of
12 and used in 3 major modes of operation. The high performance and industry
standard configuration of the 82C55A make it compatible with the 80C86, 80C88
and other microprocessors.

We need to use it to connect the input and output, such as, sensors and LCDs,
devices to the 8051 microcontroller via its ports.

2.2.2 Sensor (Switch)

In this project we will use a kind of sensor, that is, a switch to sense in every
park that the car found or not, and to sense the car at the entrance or exit, for
controlling the open or close of the gates park, by make it as the input part to the
microcontroller.

Figure (2.3): Switch

The pin labeled ``+5v supply'' may be used to power an active sensor (e.g.,
the transmitter LED of a reflective optosensor). The pin labeled ``sensor signal'' is
the input to the Handy Board circuitry; this must be in the range of 0 to 5 volts. The
pin labeled ``ground'' is the system ground.

١٧
Figure (2.4): Switch Sensor

The above diagram shows how to wire a switch-style sensor to the Handy
Board. As indicated in the diagram, the switch terminals labeled ``C'' (common) and
``NO'' (normally open) should be connected to the sensor plug.

This wiring creates a switch sensor that is normally open, or disconnected,


except when the switch is pressed. The standard software for reading the state of a
switch interprets this logic high value as ``not pressed'' or false. When the switch is
closed, the sensor line is connected to ground, and the software reads a logic low
value, which is interpreted as ``pressed'' or true.

2.2.3 Motors

In this project we will use two DC motors for the two gates, to open the gate
for the park when the cars will enter, and close it when the cars leave.

١٨
Figure (2.5): Motor

The DC motor connector uses two male pins on 0.2 inch spacing; i.e., the
outer two of three pins. The center pin can be clipped away from the assembly.

We will use DC motor because it is give good speed for open the gate, on the
other hand, its price cheaper than other kind of motors.

2.2.4. LCD

LCD, A liquid crystal display (LCD) is a thin, flat display device made up of
any number of color or monochrome pixels arrayed in front of a light source or
reflector. It is prized by engineers because it uses very small amounts of electric
power, and is therefore suitable for use in battery-powered electronic devices.

We will use it to display if there is an empty location in the park for the
customer to put his car in it and to know exactly where to go form the main entrance,
for that, we need more than one LCD, the main LCD, and one for each floor.

In this project we will use LCD its size will be at least 34 inch and over,
because every one who at 10 meters distance will be able to see the data on the
LCDs, and below an option of 40 inch LCD.

١٩
Figure (2.6): LCD Display

We will take about SONY LCD. This LCD video performance advanced
networking options, or its 40" of display area. This large format LCD display.
Receive WXGA 1366 x 768 resolution paired with a 16:9 aspect ratio and forget
about blurry or imperfect images. Wide 178 degree viewing angles, with its 450
cd/m2 brightness. The FWD-40LX1/S has a minimum LCD panel life of 60,000
hours.

SONY LCD Features

1. Viewable Image Size: "40".


2. Resolution: WXGA 1366 x 768.
3. Aspect Ratio: 16:9.
4. Brightness (Typical): 450 cd/m2.
5. Connectivity: RGB/Component (HD-15), DVI-D HDCP, Composite (BNC),
YUV (Composite).
6. Cabinet Color(s): Silver.
7. Environments: PC Compatible.

٢٠
2.2.5. Gate

Gate, The combination of our proven and reliable electric motor with a lever
system represents a simple and extremely reliable drive solution. It permits short
opening and closing times without the barrier boom bouncing in the end positions.
The lever system locks the barrier boom at both end positions.

The motor at each gate use to open and close it, and use as the output to the
microcontroller.

Figure (2.7): The Gate

2.2.6. Spring

we will put a switch between two springs, each spring will be compressed by
200Kg, and over it a piece of iron, therefore, the switch will not closed until a 200Kg
over it like a car.

Springs are fundamental mechanical components which form the basis of


many mechanical systems. A spring can be defined to be an elastic member who
exerts a resisting force when its shape is changed. Most springs are assumed linear
and obey the Hooke's Law,

٢١
Where F is the resisting force, D is the displacement, and the k is the spring
constant. There are many basic spring types, the most plentiful of which are shown
as follows, we will use a compression spring.

Figure (2.8): The Springs

2.2.7 Force on Spring

The switch found between two springs. Each car location effected with the
mass of the car and the mass of the piece of iron. After searching and study we found
that the weight of the car is between 400_2000 Kg, the weight of the piece of iron
approximately 25 Kg and the weight of five person if the car approximately (5X70),
from that we must ensure that the switch become on when weight over it at least 400
Kg .

2.2.8 General Parking Diagram

The figure (2.9) shows the first floor of the park area, the cars are in blue
colors and this park contains a large number of cars, the circle in the bottom of the

٢٢
figure is the place from which the cars go to the second floor and from the left the
entrance of the park and the exit from the right.

In this park a piece of iron put in each location in the park, exactly, in the half
length, that is the first two wheels only press it, if the location length 5m the piece of
iron put after the first 2.5m form the location length.

Figure (2.9): The first floor

٢٣
The figure (2.10) shows the second floor of the park area, cars in blue like the
figure of the first floor, but the difference between this figure and the figure (2.9) that
this floor without an entrance and exit places but it has a circler for the cars to go to
the first floor and to leave the park.

Figure (2.10): The second floor

٢٤
3

Design Concepts

3.1 Project Objectives


3.2 Project main hardware components
3.3 General Block Diagram
3.4 Interfacing
3.5 Motors
3.6 How System Works

٢٥
Chapter Three
Design Concepts

3.1 Project Objective

 To design and implement a smart parking car system using 8051


microcontroller.
 Implement a charging system at the entrance to the parking.
 Implement a subsystem for each floor showing the available parking slots,
writing the necessary software.

3.2 Project Main Hardware Components

In this project we use a microcontroller 8051 to control the parking in our city
and to have more development, smart, security and easy to use parking.

This system consists of many basic components, as we mention in chapter


two, the main part of the system given below.

 8051 microcontroller development kit.


 Sensor (switch).
 Display (LCDs).
 Motor.
 Gate.

All of these component connected together to make smart parking, the 8051
connected to micro-switch as input and also connect it to the LCDs as output from

٢٦
the microcontroller, and the two gates will open when the car enters or leaves the
park according to the motor movement, its movement will happen when the sensor
(switch) has closed and so send signal to the microcontroller, so we have full system
to control all of the cars that enter, leave and in the parking. Therefore, every free
position is known to every customer who wants to put his car in that park.

The smart car parking system aim to make a full control system engineering
that control many details in this park, its control opening the gates and close it from
the motor movement that move according to the microcontroller signal. So, it is very
accurate system that open and close at specific time.

LCD displays free spaces in each floor and the exact location. Therefore, this
will be very organized, arranged park and comfortable to the customer use.

In this park the machine will be the employee not the human.

3.3 General Block Diagram

The general block diagram of our project (not including the charging system)
is shown in figure (3.1), there are two floor connected to the main system board.

٢٧
Figure (3.1): General Block Diagram

3.3.1 Floor Subsystems

The system consists of microcontroller 8051, sensors and display.

Figure (3.2): Floor Subsystem

3.3.2 Entrance System

Consist of 8051 microcontroller display and floors.

٢٨
Figure (3.3): Entrance System

3.3.3 8051 Microcontroller System

This block diagram show the 8051, RAM, ROM, Decoder, ALU and others.

٢٩
Figure (3.4): The 8051 Microcontroller

3.4 Interfacing

Here we will take about interfacing of the floor system with the entrance
main system. The main system makes interfacing between the two floors as input,
and the main LCD and the two motors as output. Figure (3.5)

The two subsystems for the two floors make interfacing between the switches
as input, and the LCD for each floor as output as shown in figure (3.6). We must
draw attention to the interfacing between the main system and the subsystems,

٣٠
therefore, the whole system share the data between the main and the sub which
explained at the end of this chapter in section (3.5) and in chapter two.

Figure (3.5): Interfacing Main System

Figure (3.6): Interfacing Floor 1

3.5 Motors

In this project we can use two options of two kinds of motors, AC motor or
DC motor. We preface to use DC as we mention before, figure (3.7).

٣١
Motors
12VDC
+5v
0.1 0.1

10K 10K 0

nc nc
InA OutA 0

GND VDD
InB OutB 2 M 1

MAX 4428 0 MOTOR DC


0

Figure (3.7): DC Motor

3.6 How system Works

3.6.1 Microcontroller with Switch, LCDs and Motors

The microcontroller system consists of hardware and firmware. The firmware


of general purpose experimental systems is usually a monitor program that lets users
inspect and modify system attributes such as memory and ports. In addition, a
monitor program should allow downloading and running other applications program.
Once the application software has been fully developed and tested, it may be placed
in ROM and the microcontroller system be used as an embedded controller.

The microcontroller system consists of three major blocks: CPU, memory,


and input /output ports.

Grouping the sub systems of microcontroller system into blocks is convenient


way to describe circuitry that is too large to be displayed on a single sheet. System
blocks diagrams also describe the important signals that connect the sub systems.

٣٢
A bus is a collection of several related signals. There are four buses: the
address bus, the data bus, and the two port buses. The buses are represented by
names, followed the range of indices. The address bus is given the name A with the
index range [0...15]. The individual lines of the address bus are therefore named A0,
A1… A15. The address bus is 16 bits wide, where as the data bus only 8 bits wide
Port. Bits are P1.0, P1.1… P1.7. Similarly P3 bits are connected to a bus, even
though only 4 bits, P3.2 to P3.5 are available as general-purpose input/output ports.

The 8051 microcontroller is at the center of the subsystem. The two


capacitors C1 and C11 and the crystal Y1 are used by the microcontroller to generate
the oscillator clock. The oscillator allows many popular Baud rates to be generated.
The jumper JP3, when installed, grounds the EA# signal to allow code to be fetched
from external memory. When pressed, pushbutton s2 connects the rest input to VCC.
Port0 and Port 2 are used for external memory access. Port0 first emits the low byte
of the address. The ALE signal is used to latch the address low byte. Then Port0
emits or receives the data byte. The octal latch is used to extract the address low
byte. The output of the latch is always enabled. Eight resistors are connected to port
0, and the ninth resistor is used as a pull-up resistor for the EA# input. The 5 volt
supply must be connected to the VCC pin, pin 40; similarly the ground of the power
supply, 0 volts, must be connected to the GND pin, pin 20.

The external code and data memory blocks overlap. The ANDed signal,
called READ#, is activated (made low) when ever PSEN# or RD# signals are low.
The WR# signal is generated by the microcontroller during external memory fetches.
Four of the bits of port 3 are used by the system. P3.0 and P3.1 are used for serial
communication, and P3.6 and P3.7 for the WR# and RD# signal. Port P1 and 4 bits
of port P3 are available as general purpose input/output bits. Port P3 bits are also
used in conjunction with the timers and as external interrupts.

٣٣
The 64K of system memory is organized in two 32K halves. One of the 32K
blocks is an EPROM and the other is a RAM device. The most significant bit of the
address bus A15 determines which half of memory is addressed. A15 and its
complement are used as the decoding signals to activate the two memory devices.
The complement of A15 is obtained by one of the NAND gate. The double-pole-
double-throw (DPDT) switch determines which memory device is decoded as the
low block of memory. With a monitor program in EPROM, the EPROM should be
selected as the low memory block so that upon reset, the monitor program initializes
and runs the system. An application program that is downloaded into the RAM is
executed by toggling S1 while the RESET button is pressed. The RESET button is
held pressed, no instructions are fetched. Toggling S1 decodes the RAM containing
the application program to be decoded as the low block of memory. Once the reset
button is released, the microcontroller starts fetching the instructions form location 0
know decoded as the first byte of the RAM, thus executing the downloaded program.
The digital input/output lines are connected to a terminal block. A separate two
terminal connecter JP2 is used to bring the supply voltage to the volt.

The output of the decoder such as Y0 pin 15 will be connected to the chip
select (CS) pin7 of the PPI, and the decoder takes the input from the microcontroller
port, and the output of the decoder will be connected to the chip select of RAM and
EPROM.

The unused ports of both PPI will be connected to another hardware device,
LCD takes bits from PPI ports to make interface between it and the system, the
motor will take 1 bit and since we have two motors we need 2 bits from ports. Each
micro switch need 1 bit from the ports to make interface between the switch and the
system.

In this system we will use a switches sensor for each location in the park and
the other for the entrance and exit place.

٣٤
And here the description steps of working system from the moment of car
entrance to the park until to leave. When the car reach our smart park entrance, the
sensor (switch) placed in that place will be closed, since the customer put his car in
the entrance, then the sensors sends signal to the microcontroller, which in turns
sends signal to the motor to open the gate, the same sensor after a delay like 5
seconds close the, this sensor will send a signal to the microcontroller, which in
reverse will send another signal to the motor to close the gate. After that, the
customer will choose the place where he wants to park his car from the main LCD,
which displays the floors (where the first or second floor has empty places or not),
which how many places are empty in it (10, 16 …). Then he chose the location from
a sub LCD, and then the car will be parked. Next, the switch at that location will be
closed and send a signal to the microcontroller, to change the LCDs display, the
location that the customer parks his car in it is not empty.

When the car leave the location, the circuit between the switch and the
microcontroller port open, so the LCDs to change its displays which show that this
location is empty for another car to use.

Therefore, when the car reaches the other gate to leave from the park, the
sensor which precedes the gate will be closed and send a signal to the
microcontroller, in respect the microcontroller sends a signal to the motor to open the
gate. Finally, the car leaves the park then, closes the gate after a required delay.

3.6.2 The Switch with Microcontroller

The switch connected to the microcontroller by PPI or microcontroller ports,


from one of its input (this called a signal terminal as we mention in chapter two),
when the signal pin become on (switch closed) it will sent a signal to microcontroller
port. The microcontroller receives the signal, and knows that there is a car in that

٣٥
place. And when a car left that place that port become zero, and because of that, the
microcontroller know that this place in the park is free for another car.

3.6.3 The LCDs with Microcontroller

The LCDs connected to the microcontroller with the output ports of PPI. It
works as an output of the processed data which come from the microcontroller.

The main LCD show how many free places in each floor. The other shows
the exactly free places in that floor. In every update the information changes
dependently to switch signal.

The LCDs work dependent to the micro-switches signals, when the micro-
switches closed send signals to the microcontroller as we mention before.

3.6.4 The Motor with Microcontroller

The two motors connected with two bits to the microcontroller, one bit for
each one, according to PPI. The motor of entrance gate open when the switch sends
signal to microcontroller, so the microcontroller sends another signal to motor to
open that gate. And the motor will close the gate when another signal the
microcontroller sends it.

The second motor (for the exit gate), as motor for entrance gate, except it will
open according to the signal send to the microcontroller from switch before the exit
gate.

٣٦
3.6.5 The spring with switch

In each location in the park there is two spring in the ground, between them
switch. When the car takes its place in the park, the wheel of that car will press a
piece of iron over the two springs. The switch after five centimeter below the iron.
This five centimeter become zero when the spring pressed by at lest 200Kg (the mass
of car). So the switch closed and sends a signal to microcontroller.

3.6.6 The gate with the motor

The gates will open and close according to the motors movement.

٣٧
4
Hardware System Design

4.1 Introduction
4.2 The units design
4.3 Overall System Design

٣٨
Chapter Four
Hardware System Design

4.1 Preface

After explaining the theoretical background, the general block diagram of the
system, and how the system works, there is a need to view what is the design of this
system in more specific, powerful and more formal terms. So this chapter describes
the final system design with all its features which are necessary to make the system
works well and achieves the objectives of the system. This chapter shows the
interfaces between the equipments of the theoretical background, and the more
suitable chips that advanced the design.

4.2 The Units Design

The park consists of five physical modules (sensors, LCDs, motors,


Microcontroller and power). All the components are assembled on a single board.

The system has mainly four parts; these parts must interface with each others to
achieve the project goals. The team has to deal with each one as separate unit, study
its features and prepare it to operate successfully with other units. These units are:

 Sensors.
 Control unit (8051 board).
 Display (LCDs).
 Motors.

٣٩
4.2.1 Sensors (Interlocking Push Buttons)

The reasons of choosing interlocking push buttons refer to:

 Two through used for entrance and leaving.


 Easy to use since External control circuit is unnecessary.
 Availability.
 Acceptable.

The sensors are used to:

 Sense the entrance of the car, to become closed and send signal to the
microcontroller ports (this will be explained later in control unit), and then
this location will become not available for another user. When the car leaves
the location, another new drivers can see that there is free really location in
the same place.

Figure (4.1): Switch

 The system needs to transfer data between the sensors (in all places) and the
microcontroller and in reverse.

٤٠
 The term "switch" typically refers to electrical power or electronic
telecommunication circuits. In applications where multiple switching options
are required, mechanical switches have long been replaced by electronic
variants which can be intelligently controlled and automated.

 Each sensor (push button switch) has two bits one for VCC and the other for
the ground, when the sensor pushed to the first time it becomes on, but on
the second push it becomes off.

 For this project, the sensor put between two springs, and above it a piece of
iron, when the driver parked his car in any location in the park and push the
button to the first time it give signal "1" or on, and send it to the
microcontroller and all of the time that the driver still in that location the
signal does not change, all the time stay on. And when the driver leaves the
location, the sensor will be pushed to the second time and becomes off or
"0", and stay off until another driver parked his car in this location.

 The project has to use many sensors; each location must have one sensor
plus the sensors at the entrance and at the exit of the park.

 The microcontroller has A, B, C, D, E, and F ports and each port has 8 bits,
we use port A (0..7) for the sensors in the first floor, and port B (0..7) for the
sensors in the second floor, and bit1, bit2 from port c for the sensors at the
entrance and exit, we connect each sensor (push button switch) from its VCC
port to the microcontroller I/O ports, each one to one bit of the
microcontroller as we say before.

٤١
4.2.2 DC_motor and H_Bridges

The H-bridge circuit consists of a set of four transistors in IC packages that


are arranged in an “H” orientation. This layout allows for current to flow bi-
directionally through the circuit thus allowing for directional control for our motors.
Additionally, logic inputs signals can be used to determine which direction the
motors are spinning. Depending on the paired combination of logic 1’s and 0’s the
motor shaft can turn left, turn right, and brake. Speed control is another feature of the
h-bridges, when given a pulse-width-modulated (PWM) input signals, depending on
the length of the duty cycle; the speed can be varied accordingly. H-Bridges that will
be used are Max4428. The H-bridges will act as interfaces between microcontroller
and the motors.

This IC (H_Bridges) used to control the DC motor at the gate of the park and
make the DC motor move forward (right) to open the gate of the park and backward
(left) to close the door of the park.

The DC_motor will receive signal from the microcontroller to open the gate
and another signal to close it.

4.2.3 LCDs

The M1632 is a low-power-consumption dot-matrix liquid crystal display


(LCD) module with a high-contrast wide-view TN LCD panel and a CMOS LCD
drive controller built in. The controller has a built-in character generator ROM/RAM,
and display data RAM. All the display functions are controlled by instructions and
the module can easily be interfaced with an MPU. This makes the module applicable
to a wide range of purposes including terminal display units for microcomputers and
display units for measuring gages.

٤٢
Properties of the LCD used in virtual project:

 16-character, two line TN liquid crystal display of 5 x 7 dot matrix + cursor.


 Duty ratio: 1/16.
 Character generator ROM for 192 character types (character font: 5 x 7 dot
matrix).
 Character generator RAM for 8 character types (program writes) (character
font: 5 x 7 dot matrix).
 80 x 8 bit display data RAM (80 character maximum).
 Interface with 4 bit and 8bit MPUs possible.
 Display data RAM and character generator RAM readable from MPU.
 Many instruction functions: Display Clear, Cursor Home, Display ON/OFF,
and Cursor ON/OFF.
 +5 volt single power supply.

There are three LCDs used to show the display data on the screen:

 The main LCD used to display the number of free places in each floor and
puts at the entrance of the park before the driver reach floor one.
 The first secondary LCD in floor one used to display the specific free places
in that floor like (floor one: A (1, 2), B (1, 3, 4)), this mean location A in
floor one has 1 and 2 free places; location B in floor two has 1, 3 and 4 free
places.
 The second secondary LCD in floor two used to display the specific free
places in that floor like (floor two: A (1, 2), B (1, 3, 4)), this mean location A
in floor two has 1 and 2 free places; location B in floor two has 1, 3 and 4
free places.

٤٣
4.2.4 Control Unit

The system need control unit to achieve all the operation of the design. The
control unit represented by two main parts; the first one represented by computer that
connect the units of project together by serial port and other hardware design such as
LCDs and sensors.

The second part represented by software driver programmed using C


programming Language that install from the computer to the microcontroller board
from serial port then decode and analyze it after that execute and perform the specific
task refer to it ( we will discuss this part in detailed at chapter five).

Now we will illustrate the ports that connect the project subsystem.

4.2.4.1 Serial Ports

We have to use the serial port on the computer receives asynchronous data at
suitable speeds for our data. The serial port expects asynchronous data; the serial port
can only accept words of length 5 or 7 bits. It also expects start and stop bits. The
serial port cable has to be used to connect the computer with the circuit board and
load programs into the 8051 microcontroller as shown in figure (4.2).

Figure (4.2): Serial Port Cable

٤٤
The serial port is an I/O (Input/Output) device. An I/O device is just a way to
get data into and out of a computer. Most PC's have one or two serial ports. Each has
a 9-pin connector (sometimes 25-pin) on the back of the computer. Computer
programs can send data (bytes) to the transmit pin (output) and receive bytes from
the receive pin (input). The other pins are for control purposes and ground.

The serial port is much more than just a connector. It converts the data from
parallel to serial and changes the electrical representation of the data. Inside the
computer, data bits flow in parallel (using many wires at the same time). Serial flow
is a stream of bits over a single wire (such as on the transmit or receive pin of the
serial connector). For the serial port to create such a flow, it must convert data from
parallel (inside the computer) to serial on the transmit pin and conversely.

4.2.4.1.1 Pins and Wires

Old PC's used 25 pin connectors but only about 9 pins were actually used so
today most connectors are only 9-pin. Each of the 9 pins usually connects to a wire.
Besides the two wires used for transmitting and receiving data, another pin (wire) is
signal ground. The voltage on any wire is measured with respect to this ground. Thus
the minimum number of wires to use for 2-way transmission of data is 3. Except that
it has been known to work with no signal ground wire but with degraded
performance and sometimes with errors. As shown in figure (4.3).

Figure (4.3): Serial port pins

٤٥
4.2.4.1.2 Data flow

Data flows into and out of your serial port. Flow rates (such as 56k (56000)
bits/sec) are (incorrectly) called "speed". But almost everyone says "speed" instead
of "flow rate".

It's important to understand that the average speed is often less than the
specified speed. Waits (or idle time) result in a lower average speed. These waits
may include long waits of perhaps a second due to flow control. At the other extreme
there may be very short waits (idle time) of several micro-seconds between bytes. If
the device on the serial port (such as a modem) can't accept the full serial port speed,
then the average speed must be reduced.

PC Com Port - EIA-574 RS-232/V.24 pin out on a DB-9 pin used for
asynchronous data shown in figure (4.4).

Figure (4.4): PC Com Port

Table(4.1): Serial Port Pins


Pin Signal
1 Data Carrier detector
2 Received Data
3 Transmitted Data
4 Data Terminal Ready
5 Signal Ground
6 Data Set Ready
7 Request to Send
8 Clear to Send
9 Ring Inductor

٤٦
4.2.4.2 Controlling the Motor

The following table indicates the operation of the circuit below:

Table (4.2): Operation of the DC motor driving circuit

PPI pins
P1 P2 A B motion
0 0 G G No motion
0 1 G 12v Left rotation
1 0 12v G Right rotation
1 1 12v 12v No motion

Motors
12VDC
+5v
0.1 0.1

10K 10K 0

nc nc
InA OutA 0

GND VDD
InB OutB 2 M 1

MAX 4428
0 MOTOR DC
0 H_Bridge

Figure (4.5): DC motor circuit

The DC_motor and H_bridge circuit used to open the gate of the park and
close it according DC_motor movements, when the motor move forward the gate
will be opened and when its move backward the gate will be closed, it will be
moved forward or backward according to the signal send to the H_bridge.

٤٧
4.2.4.3 Electrolytic Capacitor and Resistor

The capacitor we used is about 0.1 micro for the every IC to protect it as
shown in figure (4.6).

Resistor will be used in every IC in the project to give less current to the
circuits as shown in figure (4.6). We will be using 100KΩ for every IC used in push
button switch.

Figure (4.6): Single Capacitor

Figure (4.7): Resistors

4.2.4.4 (74244) Buffer

This buffer will be used as storage between the sensors and the
microcontroller ports take the input from the sensor and send it to the
microcontroller, as shown in figure (4.8).

٤٨
Feature:

1. State outputs drive bus lines or buffer memory address registers.


2. PNP inputs reduce DC loading.
3. Package options include both plastic and ceramic chip carriers in addition to
plastic and ceramic DIPs.

Figure (4.8): 74244 Buffer

4.2.5 Over All System Unit (Application Unit)

This unit is connected to the microcontroller unit, it consists of the circuit that
drive the DC motor; which control the gate, and the sensor as input. And control the
LCDs display as output.

4.2.5.1 Interfacing Circuits

The system consists of four parts, and each part has an important role in this
system. But to achieve the system objectives and operates as one unit, there’s a need
to integrate each unit with others through the interfacing circuits .The interfacing
circuits are:

٤٩
4.2.5.1.1 Interfacing Sensors with microcontroller (8051) board

The following circuit in figure (4.9) represents the interfacing sensors in the
floors with I/O ports of the microcontroller board using the PPI chip.

Sensors
+5v
10Kx8 SW9
Floor 1 1n
34 4 2 18
33 D0 PA0 3 4 A1 Y1 16
32 D1 PA1 2 6 A2 Y2 14 10K
31 D2 PA2 1 8 A3 Y3 12 SW6
D3 PA3 A4 Y4

74F244
30 40 11 9
29 D4 PA4 39 13 A5 Y5 7
28 D5 PA5 38 15 A6 Y6 5
27 D6 PA6 37 17 A7 Y7 3 SW7
D7 PA7 A8 Y8
Floor 2 10K
Microcontroller

9 18 1
8 A0 PB0 19 19 1OE
A1 PB1 20 2OE
35 PB2 21
5 RESET PB3 22 0
36 RD PB4 23
6 WR PB5 24
CS PB6 25 0
PB7
14 0
82C55 PC0 15
PC1 16
PC2 17 SW15
PC3 10Kx8
13 +5v
PC4 12
PC5 11
PC6 10 SW17
PC7 2 18
4 A1 Y1 16
6 A2 Y2 14
8 A3 Y3 12 SW14
A4 Y4
74F244

11 9
13 A5 Y5 7
15 A6 Y6 5
17 A7 Y7 3
A8 Y8 SW19
1
19 1OE
2OE

0 0
0

Figure (4.9): Interfacing Floors Sensors with 8051 Microcontroller

The following circuit represents the interfacing sensors of the gates with I/O
ports of the microcontroller board using the PPI chip. Then it will be buffered by
74F244 buffer. In this PPI we will use port A (0_7) and port B (0_7) connected with

٥٠
switches, for floor1 port A and for floor2 port B. Then, the signal will be received
through these ports A and B and know which switch is on and which is off.

34 4
D0 PA0
33
32 D1 PA1
3
2
Sensors of
31 D2 PA2 1 The Gates
30 D3 PA3 40
29 D4 PA4 39
28 D5 PA5 38
27 D6 PA6 37
D7 PA7
Microcontroller

9 18
8 A0 PB0 19
A1 PB1 20
35 PB2 21
5 RESET PB3 22
36 RD PB4 23
6 WR PB5 24 C1
CS PB6 25
PB7 +5v 10K
14 2 18
82C55 PC0 15 4 A1 Y1 16
PC1 16 6 A2 Y2 14
PC2 17 8 A3 Y3 12
PC3 A4 Y4

74F244
13 11 9
PC4 12 13 A5 Y5 7
PC5 11 15 A6 Y6 5
PC6 10 17 A7 Y7 3 0
PC7 A8 Y8
1
19 1OE
2OE

0 0

Figure (4.10): Interfacing Main entrance and Exit Gate Sensors with
8051 Microcontroller

4.2.5.1.2 Microcontroller 8051 Interfacing with LCD Display

The Microcontroller is interfaced with the LCD in figure (4.10). The


following circuit represents the interfacing LCDs with I/O ports of the
microcontroller board using the PPI chip. Then it will be buffered by 74F244 buffer.

In this PPI we will use port A (0_7) and port C (0_2) connected with first
LCD, and port B (0_7) and port C (3_5) connected with second LCD. Then, the
signal will be sending through these ports A and C to display the output data though
these ports.

٥١
+5v
2 18
LCDs DB7
A1 Y1
4
A2 Y2
16 DB6 1K
6
A3 Y3
14 DB5 Vo
8
A4 Y4
12 DB4
11
A5 Y5
9 DB3

74F 244
13
A6 Y6
7 DB2
15
A7 Y7
5 DB1
17
A8 Y8
3 DB0 0
16x2
34
D0 PA0
4 1 LCD
33 3 19 1OE E
D1 PA1 2OE
32
D2 PA2
2 R/W'
31
D3 PA3
1 RS
30
D4 PA4
40 VSS
29
D5 PA5
39 VDD
28 38
27 D6 PA6 37
D7 PA7 0
+5v
Microcontroller

9 18 2 18
8 A0 PB0 19 4 A1 Y1 16
A1 PB1 20 6 A2 Y2 14
35 PB2 21 8 A3 Y3 12
5 RESET PB3 A4 Y4
74F 244

22 11 9
36 RD PB4 23 13 A5 Y5 7 +5v
6 WR PB5 24 15 A6 Y6 5
CS PB6 A7 Y7
82C 55

PB7
25 17
A8 Y8
3 DB7
DB6 1K
PC0
14 1 DB5 Vo
15 19 1OE DB4
PC1 2OE
PC2
16 DB3
PC3
17 DB2
PC4
13 DB1
PC5
12 DB0 0
PC6
11 16x2
PC7
10 LCD
2
A1 Y1
18 E
4
A2 Y2
16 R/W'
6
A3 Y3
14 RS
8
A4 Y4
12 VSS
74F 244

11
A5 Y5
9 VDD
13 7
15 A6 Y6 5
17 A7 Y7 3
A8 Y8
1 0
19 1OE
2OE
+5v
0

Figure (4.11): Interfacing LCDs with 8051 Microcontroller

٥٢
4.2.5.1.3 Microcontroller 8051 Interfacing with Motors

The Microcontroller is interfaced with the motors during the PPI in figure
(4.10). The following circuit represents the interfacing motors with I/O ports of the
microcontroller board using the PPI chip. Then it will be buffered by 74F244 buffer.

In this PPI we will use three bits in port C connected with motors, 2 bits for
the first motor and 2 bits for the second motor. Then, the signal will be sending
through ports C to display the control the time when motor move and how (left or
right).

U1
+5v
34
D0 PA0
4 12VDC
33 3
32 D1 PA1 2 0.1 0.1
31 D2 PA2 1 10K
30 D3 PA3 40 10K
29 D4 PA4 39
28 D5 PA5 38 0
D6 PA6
27
D7 PA7
37 nc nc
InA OutA
Microcontroller

9 18
8 A0 PB0 19 0
A1 PB1
PB2
20 GND VDD
35 21 InB OutB 2 M 1
5 RESET PB3 22
36 RD PB4 23
6 WR PB5 24 MAX 4428 0
CS PB6 25 MOTOR DC
PB7 0
82C55

+5v
PC0
14 2
A1 Y1
18 12VDC
15 4 16
PC1 16 6 A2 Y2 14 0.1 0.1
PC2 17 8 A3 Y3 12 10K
PC3 13 11 A4 Y4 9 10K
PC4 A5 Y5
74F244

12 13 7
PC5 11 15 A6 Y6 5 0
PC6 A7 Y7
PC7
10 17
A8 Y8
3 nc nc
InA OutA
1
19 1OE 0
2OE
GND VDD
0 InB OutB 2 M 1

0
0
MOTOR DC

Figure (4.12): Interfacing Motors with 8051 Microcontroller

٥٣
4.2.5.1.4 Microcontroller System Interface

The system need microcontroller board unit to achieve all operations of the
design. The microcontroller is used since all the components that needed for the
system were built onto one chip.

This system contains the following main components:

 8051 Microcontroller.
 74ls373 latch.
 EPROM
 74ls138 Decoder.
 PPI (8255A).
 LCD.

The ports of the PPI are configured using control word that written to the
control registers as the following:

Port A input.
Port B out put.
Port C not used.

This configuration is specified in the control word as the shown in the


following table:

Table (4.3) control word of the PPI


BSR Mode PA PCH Mode PB PCL
1 0 0 1 0 0 0 0

٥٤
4.2.6 Parallel Ports

A problem occurred in the project. This is, the 8051 microcontroller burned
(for more information see chapter seven). That makes the team to find another
solution and then used the parallel port to continue the project.

In parallel port the control unit is the computer that connects the units of
project together by parallel. The second part represented by software driver
programmed using visual basic .net that install on computer to fetch the signals, after
that execute and perform the specific task refer to it ( we will discuss this part in
detailed at chapter five).

Parallel port is a simple and inexpensive tool for building computer controlled
devices and projects. The simplicity and ease of programming makes parallel port
popular in electronics world. The parallel port is often used in computer controlled
robots, Atmel/PIC programmers, etc.

The primary use of parallel port is to connect printers to computer and is


specifically designed for this purpose. Thus it is often called as printer Port. You can
see the parallel port connector in the rear panel of your PC. It is a 25 pin female
(DB25) connector. On almost all the PCs only one parallel port is present, but you
can add more by buying and inserting ISA/PCI parallel port cards.

4.2.6.1 Hardware

The pin outs of DB25 connector is shown in the figure (4.13).

٥٥
Figure 4.13: Parallel Port Register

The lines in DB25 connector are divided in to three groups:

 Data lines (data bus).


 Control lines.
 Status lines.

As the name refers, data is transferred over data lines, control lines are used to
control the peripheral and of course, the peripheral returns status signals back
computer through Status lines. These lines are connected to Data, Control and Status
registers internally. The details of parallel port signal lines are given in table (4.4)

Table 4.4: Parallel Port Signal Line


Pin No Signal Direction Register Inverted
(DB25) name - bit
1 nStrobe Out Control- Yes
0
2 Data0 In/Out Data-0 No

٥٦
3 Data1 In/Out Data-1 No
4 Data2 In/Out Data-2 No
5 Data3 In/Out Data-3 No
6 Data4 In/Out Data-4 No
7 Data5 In/Out Data-5 No
8 Data6 In/Out Data-6 No
9 Data7 In/Out Data-7 No
10 nAck In Status-6 No
11 Busy In Status-7 Yes
12 Paper- In Status-5 No
Out
13 Select In Status-4 No
14 Linefeed Out Control- Yes
1
15 nError In Status-3 No
16 nInitialize Out Control- No
2
17 nSelect- Out Control- Yes
Printer 3
18-25 Ground - - -

4.6.3 Parallel Port Registers

The Data, Control and status lines are connected to there corresponding
registers inside the computer. So by manipulating these registers in program, one can
easily read or write to parallel port with programming languages like 'C' and BASIC.
The registers found in standard parallel port are:
 Data register

٥٧
 Status registers
 Control register

As there names specifies, Data register is connected to Data lines, Control


register is connected to control lines and Status register is connected to Status lines.
So what ever writes to these registers, will appear in corresponding lines as voltages,
by measure it with a millimeter. And what ever give to parallel port as voltages can
be read from these registers. For example, if we write '1' to Data register, the line
Data0 will be driven to +5v. We can programmatically turn on and off any of the
data lines and Control lines.

4.6.3.1 Where these registers?

In an IBM PC, these registers are IO mapped and will have unique address.
We have to find these addresses to work with parallel port. For a typical PC, the base
address of LPT1 is 0x378 and of LPT2 is 0x278. The data register resides at this base
address, status register at base address + 1 and the control register is at base address
+ 2. So once we have the base address, we can calculate the address of each registers
in this manner. The table (4.4) below shows the register addresses of LPT1 and
LPT2.

Table 4.5: Register Addresses of LPT1 and LPT2


Register LPT1 LPT2
data register(base address + 0) 0x378 0x278
Status register (base address + 1) 0x379 0x279
control register (base address + 2) 0x37a 0x27a

٥٨
4.3 Overall System Design

The system design represents the complete interface between the units
designed using 8051 kit.

In this system the inputs is the switches (sensors) that connected to the first PPI
after it's buffered, the switches of the floors and gates take port A (0_7), port B (0_7)
and two bits from port C (0_1).

The outputs will send to the motors in the first PPI, port C (2_5). Also to the
LCDs for the floors in the second PPI, port A (0_7) and port C (0_2) for the first
LCD, port B (0_7) and port C (3_5) for the second LCD.

Note: The third LCD is internally found on the 8051 development kit itself.
The complete characteristic of the system is shown below in figure (4.14) (not
implemented).

The system design represents the complete interface between the units
designed using parallel port. There for, to control parking system the following
design had been built and tested carefully to achieve the needed objectives. The
complete characteristic of the system is shown below in figure (4.15).

٥٩
Overall System Design
+5v 0.1 10Kx8 SW9
+5v Floor 1
2 18
A1 Y1
+5V 4
A2 Y2
16
GND 6
A3 Y3
14 10K
8 12 SW6
A4 Y4

74F 244
D0 0 11
A5 Y5
9
32 D2 13 7
13 A6 Y6
21
P2.0/A8 P0.0/AD0
39 3
D1 Q1
2 12 A0 D0 D4 INT0 15
A7 Y7
5
22 38 4 5 11 A1 D1 14 D6 17 3 SW7
P2.1/A9 P0.1/AD1 D2 U10 Q2 10 15 A8 Y8
23
P2.2/A10 P0.2/AD2
37 7
D3 Q3
6 A2 D2 LCD INT1 Floor 2 10K
Single

24 36 8 9 9 A3 D3 17 D7 1
P2.3/A11 P0.3/AD3 D4 Q4 19 1OE

74H C 373
25 35 13 12 8 A4 D4 18 D5
P2.4/A12 P0.4/AD4 D5 Q5 7 19 2OE
26
P2.5/A13 P0.5/AD5
34 14
D6 Q6
15 A5 D5 D3 P1.0
27 33 17 16 6 A6 D6 20 D1 P1.1
P2.6/A14 P0.6/AD6 D7 Q7 5 21
0
28
P2.7/A15 P0.7/AD7
32 18
D8 Q8
19 A7 D7 P1.2 0
Step

27 A8 P1.3

39F512
J1 10 1 11 26 A9 P1.4
11 P3.0/RXD P1.0/T2 2 1 LE 23 A10 P1.5 0
P3.1/TXD P1.1/T2EX OE 10 25
1 12
P3.2/INT0 P1.2
3 A11 P1.6 0
2 13 4 4 A12 P1.7
P3.3/INT1 P1.3 28
3 14
P3.4/T0 P1.4
5 0 0 +5v
A13
87C52

4 15 6 29 A14 +5v
P3.5/T1 P1.5 3
16
P3.6/WR P1.6
7 A15 3.3K 10Kx8 SW15
17 8 R8 0
P3.7/RD P1.7
Flash

22pF 1 +5v 0.1


29 19 1M 2
PSEN X1 18 24 OE 30
X2
2K SW17
30 22.11MHZ 31 WR 2 18
ALE/PROG 22pF A1 Y1
Erase

31 1K 22 CE 4 16
EA/VPP 9 6 A2 Y2 14
RST 0.1MF 8 A3 Y3 12 SW14
A4 Y4

74F 244
40 16 11 9
VCC 0 13 A5 Y5 7
0 0 0 15 A6 Y6 5
+5v 2 0 17 A7 Y7 3
U39A 1 A8 Y8 SW19
1 3 74HC02 34 4 1
U26A 3 33 D0 PA0 3 19 1OE
1 2 74HC00 32 D1 PA1 2 2OE
U25A 3 31 D2 PA2 1
D3 PA3
2 74HC00 28 30
D4 PA4
40
10 A0 D0 11 29 39 0
9 A1 D1 12 28 D5 PA5 38 +5v 0
8 13 D6 PA6
1 A2 D2 27
D7 PA7
37
0
12VDC
2 7 A3 D3 15
7420 6 6 A4 D4 16 9 18 10K 0.1 0.1
2

5x330 4 U36A 5 A5 D5 17 8 A0 PB0 19 10K


4 18 A1 PB1
5 A6 D6 PB2
20 10K 10K
U28A U30A 5 3 A7 D7 19 35 21
RESET PB3 0
62256

74HC00 74HC00 4 25 A8 5 22
24 RD PB4
U42A
6 U35A A9 10K 36
WR PB5
23 nc nc
7420 2 21 A10 6 24 InA OutA
D4 23 CS PB6
1 1 A11 PB7
25 0
82C 55

3 2 A12 0
3

2 26 A13 14 2 18 GND VDD


1 PC0 A1 Y1
A14 PC1
15 4
A2 Y2
16 InB OutB 2 M 1
7426 TX LED 16 6 14
1 D8 D14 0 PC2 17 8 A3 Y3 12
PC3 A4 Y4
74F 244

U34A 3 PWR LED 22 RD 13 11 9 MAX 4428 0


2 74AC08 27 WR PC4 12 13 A5 Y5 7 MOTOR DC
PC5 A6 Y6 0
20 CS 14 11 15 5 +5v
PC6 A7 Y7
RX LED
0 PC7
10 17
A8 Y8
3 12VDC
1 +5v
U31A 3 1 0.1 0.1
2 74HC00 19 1OE 10K
0 2OE 10K

10MF 0
1 SW1 0 nc nc
7426 3 InA OutA
2 U37A
0
GND VDD
InB OutB 2 M 1
1 15 34 4
2 A Y0 14 33 D0 PA0 3 2 18
3 B U32 Y1 13 32 D1 PA1 2 4 A1 Y1 16 MAX 4428 0
C Y2 12 D2 PA2 A2 Y2
74H C 138

31 1 6 14 0 MOTOR DC
6 Y3 11 30 D3 PA3 40 8 A3 Y3 12
3 4 G1 Y4 10 29 D4 PA4 39 11 A4 Y4 9 +5v
5 G2A Y5 9 D5 PA5 A5 Y5
74F 244

1 U40A
G2B Y6 7
28
D6 PA6
38 13
A6 Y6
7 DB7
74HC02 2
Y7
+5v BUS +5v 27
D7 PA7
37 15
A7 Y7
5 DB6
82C 55

3
0
17
A8 Y8
3 DB5 1K
1 U41A A1 9 18 DB4 Vo
MAIN 74HC02 2 A2 A5 8 A0 PB0 19 1 DB3
A1 PB1 19 1OE
P2
3 A0 A3 PB2
20
2OE
DB2
1 U38A A6 A7 35 21 DB1
1 74HC02 2 A4 A8 5 RESET PB3 22 DB0 16x2
6 +5v A12 A10 36 RD PB4 23 LCD 0
820 WR PB5
2 +5v LED E0 A13 A9 6
CS PB6
24
7
PB7
25 E
3
820
R/W'
8 LED E1 A1 PC0
14 RS
4 A11 A14 A0 PC1
15 VSS
9 13 16 12 A15 16 VDD
5 8 R1IN R1OUT 9 LED 820 E2 PC2 17
R2IN R2OUT PC3 13
11 14 PC4 12 2 18 0
10 T1IN T1OUT 7 LED 820 E3 PC5 11 4 A1 Y1 16 +5v
0 0.1 T2IN T2OUT PC6 10 6 A2 Y2 14
1 U43 PC7 8 A3 Y3 12 +5v
C1+ 820 A4 Y4
AUX 3
C1- MAX232
LED E4 11
A5 Y5
9 DB7
74F 244

P3
+5v 4
C2+
13
A6 Y6
7 DB6
C2 5
C2- 820
15
A7 Y7
5 DB5 1K
1 2
V+ 15
LED E5 17
A8 Y8
3 DB4 Vo
6 6
V- 0
DB3
2 1 DB2
7 LED 820 E6 19 1OE DB1
2OE
3 DB0 16x2
8 C4
0 820
LCD 0
4 C1 LED E7
9 E
5 0 0 R/W'
2
A1 Y1
18 RS
4
A2 Y2
16 VSS
0
6
A3 Y3
14 VDD
8 12
A4 Y4
74F 244

+5v 11 9
A5 Y5
+8to 15V DC 1N5819 13
A6 Y6
7
7805 +5v +5v +5v +5v +5v +5v +5v +5v 15
A7 Y7
5
IN OUT 17
A8 Y8
3

GND 1 0
19 1OE
0.1 0.1 0.1 0.1 C17 C8 C10 C9 C11 C13 C16 C14 2OE
+5v

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Figure (4.14): The System Design Circuit 1

٦٠
Ib0

LCDs +5v
DB7
DB6 1K
DB5 Vo
DB4
DB3
Parallel Port DB2
DB1
13 1 DB0 0
14 2 16x2
15 3 LCD
16 4 E
17 5 34 4 R/W'
18 6 33 D0 PA0 3 RS
19 7 32 D1 PA1 2 VSS
20 8 31 D2 PA2 1 VDD
21 9 30 D3 PA3 40
22 10 29 D4 PA4 39 0
23 11 28 D5 PA5 38 +5v
24 12 27 D6 PA6 37
D7 PA7 +5v
9 18
0 8 A0 PB0 19 DB7
A1 PB1 20 DB6 1K
35 PB2 21 DB5 Vo
5 RESET PB3 22 DB4
36 RD PB4 23 DB3
6 WR PB5 24 DB2
CS PB6 DB1

82C55
25
PB7 DB0 0
14 16x2
+5v PC0 15 LCD
PC1 16 E
PC2 17 R/W'
PC3 13 RS
0 PC4 12 VSS
PC5 11 VDD
PC6 10
PC7

0
+5v
+5v
DB7
34 4 DB6 1K
33 D0 PA0 3 DB5 Vo
32 D1 PA1 2 DB4
31 D2 PA2 1 DB3
30 D3 PA3 40 DB2
29 D4 PA4 39 DB1
28 D5 PA5 38 DB0 0
27 D6 PA6 37 16x2
D7 PA7 LCD
9 18 E
8 A0 PB0 19 R/W'
Y0 A1 PB1 20 RS
A0 Y1 35 PB2 21 VSS
Y2 5 RESET PB3 22 VDD
A1 Y3 36 RD PB4 23
WR PB5
74139

1 2 6 24
CS PB6
82C55

25
PB7 0
+5v 0 14 +5v
PC0 15 +5v
PC1 16 12VDC
PC2 17
10Kx8 SW15 PC3 13 0.1 0.1
PC4 12 10K
PC5 11 10K
+5v PC6 10
PC7 0
nc nc
Za Ia0 2 18 InA OutA
Ia1 4 A1 Y1 16
Zb Ib0 6 A2 Y2 14 SW14 0
Ib1 8 A3 Y3 12 GND VDD
A4 Y4 InB OutB 2 M 1
74F244

Zc Ic0 11 9
Ic1 13 A5 Y5 7
Zd Id0 15 A6 Y6 5
Id1 17 A7 Y7 3 SW19 MAX 4428 0
S A8 Y8 0 MOTOR DC
1 +5v
19 1OE 12VDC
Mux 2OE
0.1 0.1
74257 0 10K
0 10K
0 0
nc nc
10Kx8 SW15 InA OutA
+5v 0
GND VDD
InB OutB 2 M 1

Za Ia0 2 18 0
Ia1 4 A1 Y1 16 0 0
Zb Ib0 6 A2 Y2 14 MOTOR DC
Ib1 8 A3 Y3 12
A4 Y4
74F244

Zc Ic0 11 9
Ic1 13 A5 Y5 7
Zd Id0 15 A6 Y6 5
Id1 17 A7 Y7 3
S A8 Y8
1
19 1OE
Mux 2OE
74257 0

Figure (4.15): The System Design Circuit 2

٦١
5
Software System Design

5.1 Preface
5.2 Software Requirements Specifications
5.3 Function description
5.4 Serial Interface between the Microcontroller and PC
5.5 General System Flowchart
5.6 System Operational Flowchart

٦٢
Chapter Five
Software System Design

5.1 Preface

In this chapter, we are going to describe the software system design which
includes an explaining of the programming environment, programming tools, and to
describe some of the using methods and algorithm design as followed.

And it contains the flowchart for all processes in this project from first step in
the project, to the final step.

The overall software is programming in C programming language.

5.2 Software Requirements Specifications

After analyzing all software requirements, the following software functions


and modules are needed:

5.2.1 Win 95/98/ME/NT/2000/XP Compatible Software

This system needs these types of windows in order to write all assembly and
C codes on Text Editor Program, e.g. Notepad, also to used HyperTerminal as a
program for transfer the assembly and C code, where these programs are already
found on these windows.

٦٣
5.2.2 HyperTerminal

HyperTerminal, which comes with Windows95, 98, Me, NT, 2K and XP can
be used to obtain information from any external device such as microcontroller or
modem, or to send any data or information to these external device .Also it can be
Set up ,format, memory access and erase memory for any external device.

In this system there is a need for this program to make the connection
between PC and the 8051 microcontroller, where this program is used to transfer all
programs that will be writing in C language via serial cable to the 8051
microcontroller ,but first the procedure of setup this program on PC according to
8051 microcontroller must be understood.

To setup the connection of the HyperTerminal, the following procedure


should be performed:

1. Click on HyperTerminal icon, which found in the program file on PC then


Connection description screen will appear as shown in figure (5.1).

Figure (5.1): Connection Description Screen

٦٤
2. Put the name of the connection and choose COM1 or COM2 dependent
where serial cable is connected then you will see the Connect to screen as
shown in the figure (5.2).

Figure (5.2): Connect to Screen

3. Type any country/region, area code, phone number, and connection in the
previous screen then you will see the COM1 properties screen as shown in
the figure (5.3).

٦٥
Figure (5.3):COM1 Properties

4. Choose 115200 for bits per second, 8 bit for data bits, 1 bit for stop bits and
none for flow control also press on OK icon in the previous screen then you
will see the HyperTerminal empty screen.

5. Press enter to dial up connection between the HyperTerminal program and


the 8051 microcontroller then you will see the following screen, in figure
(5.4).

٦٦
Figure (5.4): Dial up Screen

After performing all the previous procedures, the connection will be ready
between the PC and the 8051 microcontroller.

5.2.3 Standard serial cable (straight through)

In this system, the serial cable is needed to make the connection between the
PC and 8051 microcontroller, this cable is used to send data between PC and 8051
microcontroller, and this can be connected either with COM1 or with COM2 for both
PC and microcontroller.

٦٧
5.2.4 Assembler or 'C' Compiler, usually AS31 or SDCC.

The 8051 microcontroller deals with the hexadecimal code of the C language
or assembly language, so that there is a need for the 'C' Compiler to convert the
program from language code to machine code (hexadecimal code).

The system had been programmed in C language related to the requirements


of the project, where the SDCC and AS31 compilers are used to covert from the
assembly and C code into the hexadecimal code.

The following steps are explaining how to convert from assembly code to
machine code using AS31 compilers:

1. First, install SDCC and AS31 compilers into PC on a specific directory like C
Directory.
2. Install the autostart program into PC on the same specific directory like D
directory.
3. Go to CMD screen "black screen" then go to the specific directory which the
SDCC compiler is found.
4. Type cd sdcc then press enter.
5. Type cd bin then press enter.
6. Type as31 c:\name of the assembly program .ASM then press enter.

After performed all the previous procedures successfully you will see (Begin
Pass1 and Pass2) as the result in the black screen.

The following steps are explaining how to convert from C code to machine
code using SDCC compiler:

٦٨
1. First, install SDCC and AS31 compilers into PC on a specific directory like C
Directory.
2. Install the autostart program into PC on the same specific directory like D
directory.
3. Go to CMD screen "black screen" then go to the specific directory which the
SDCC compiler is found.
4. Type path=c:\xilinx\bin\nt;c:\windows;c:\windows\command;c:\sdcc\bin
then press enter
5. Type cd <folder name> (in which program file as .c and make file is exist)
then press enter.
6. Type make then press enter.

Figure (5.5): MS_DOS

٦٩
5.2.5 Text Editor Program, e.g. notepad

The Editor Program like notepad is necessary in order to write all assembly
and C programs. The assembly program should be saved with extension .ASM on a
specific directory or as .C if the program is written in C language and after compiling
the program, the hexadecimal program will be saved automatically on the same
specific directory.

5.3 Function description

Function description included the code needed to perform the following tasks.

5.3.1 To Use PPI Set ports and system parameters

xdata at 0xF900 unsigned char p82c55_port_d;


xdata at 0xF901 unsigned char p82c55_port_e;
xdata at 0xF902 unsigned char p82c55_port_f;
xdata at 0xF903 unsigned char p82c55_def_config;
xdata at 0xF800 unsigned char p82c55_port_a;
xdata at 0xF801 unsigned char p82c55_port_b;
xdata at 0xF802 unsigned char p82c55_port_c;
xdata at 0xF803 unsigned char p82c55_abc_config;
// the following function are written to all over the system
void putchar(char c); // for char written to LCD
void motor1_right(void); // to move the motor1 write
void motor1_left(void); // to move the motor1 left
void motor2_right(void);
void motor2_left(void);

٧٠
void timer0_isr(void) interrupt 1; // to initialize the timer
void switch_gates (void); // to take data from gates switches
void floor1_switch (void); // to take data from floors switches
void floor2_switch (void);
volatile unsigned char hours; // definitions for timer
volatile unsigned char minutes;
volatile unsigned char seconds;
volatile bit time_change_flag;
unsigned char a,aa,c1;
unsigned char b,bb,c2;
unsigned char cc;
bit print_to_lcd=0; // to print data on LCD

5.3.2 Timer initialization

The 87C52 chip on the development board includes three built in timers, two
of which can you easily. (Timer 1 generates the serial port baud rate and usually
cannot be used). Here the total time of the system must be less than 1 sec.

 How to configured Timer 0

Timer 0 usually configured using these basic steps:


1. Stop the timer and clear the overflow flag
2. Set the mode of operation
3. Write the timer's initial starting value
4. Enable the interrupt (if interrupt also be used)
5. Start the timer

٧١
5.3.2.1 Code for Enable Timer

IE = 0; // turn off all interrupts


hours = minutes = seconds = 0; // zero hours, minutes, seconds
TR0 = 0; // make sure timer 0 is stopped
TF0 = 0; // clear the overflow flag
TMOD &= 0xF0; // set to mode 0 (timer1 unchanged)
TL0 = TH0 = 0; // clear the timer 0 value
time_changed_flag = 0;
TR0 = 1; // start the timing
IP = 0; // set interrupt priorities (all low)
IE = 0x82; // enable timer0 interrupt

while (1) {
hours = minutes = seconds = 0;
while (seconds!y){
}
if (time_changed_flag) {
time_changed_flag = 0;
print_fast(",");
}
}

5.3.3 Display data on LCD

Finally, the system will display data on LCD through serial interface.

lcd_ init();
lcd_clear();

٧٢
lcd_home();
print_to_lcd=1;
lcd_set_xy(1, 1);
print_fast(" FLOOR ONE: FREE PLACES %d",count1); // for main lcd
floor1
lcd_set_xy(2, 1);
print_fast(" FLOOR TWO: FREE PLACES %d",count2); //for main lcd floor2
print_to_lcd=0;

5.4 Serial Interface between the Microcontroller and PC

The microcontroller become able to make a serial connection with external


PC, so the user can see the system variables and store data to analyze it. This can
achieve by doing the following steps:

1. Connect the PC to the microcontroller using serial cable.


2. Open the HyperTerminal and set it to com1 and 11520 bit/sec.
3. Press Enter, now you can see system variable.

5.5 General System Flowchart

 The general flowchart for the system can be described in following steps:
 The switches will send signals to the microcontroller via its ports.
 The microcontroller will takes these signals, and process them to perform the
action related with it.
 The action will be sent to the LCDs and motor to take the action required. For
more details see the flowchart (figure 5.6).

٧٣
Figure (5.6): General Flowchart

٧٤
5.6 System Operational Flowchart

These flowcharts shows the functions of the programs and algorithms written
to make the system work properly, for each part of the system there is an algorithm
written to control the function of this part and all these algorithms are joined in one
program to control the overall behavior of the system. In this section, we will show
the system operational flowchart as following.

5.6.1 Sensors of Gates Flow Chart

٧٥
Read port c

Yes No
If port
c==01h

Motor1_right
(open the
entrance gate ) Yes If port No
c==02h

Motor2_right
(open the exit
gate) Yes If port No
Delay
c==03h
Motor1_left
(close entrance
gate)
Delay
Motor1_right
Motor2_left
Motor2_right
(close exit gate )

Delay
Motor1_left
Delay
Motor2_left

Figure (5.7): Sensors of Gates Flow Chart

As shown in previous (figure 5.7) the remote control initialization consists of


many steps such as:

 Set port c as input port.


 Check port c reading and anding it with the value 0xff.

٧٦
 If the resulting value was 0x01, the sensor at entrance gate is pressed after the
first two wheels of the car passed over it and gives signal to the
microcontroller to open the gate (motor1_right), then after a period of time
(delay) the sensor become off after the back wheels of the car passed over it
and then close the gate (motor1_left).
 If the resulting value was 0x02, the sensor at exit gate is pressed after the first
wheels of the car passed over it and gives signal to the microcontroller to
open the gate (motor2_right), then after a period of time (delay) the sensor
becomes off after the second wheels of the car passed over it , and then close
the gate (motor2_left).
 If the resulting value was 0x03, the sensors at entrance and exit gates are
pressed and give signals to the microcontroller to open both of the gates
(motor1_right, motor2_right), then after a period of time (delay) close both of
the gates (motor1_left, motor2_left).

5.6.2 Floor One Flow Chart

٧٧
Set port a as
input ports

Read port a

If
Yes sensor 1 or 2 or 3 or No
4 or 5 or 6 or 7 or 8
on
Decrease No. of Increase No of
available places avaialble places
Counter1-- Counter1++

Display on Main
Display on main
LCD the number of
LCD number of
available placs in
available places
floor1

Display on floor1
LCD the available
places in this floor

Figure (5.8): Floor One Sensors Flow Chart

As shown in previous (figure 5.8) floor one has many signals which perform
specific operation and the previous (figure 5.7) demonstrate how the signal perform
its specific action, and consist of many steps such as:

 Initialize port a as input port.

٧٨
 Read the signal from port a, then anding the reading with the value 0xff.
 If the reading signal was 0x01 or 0x02 or 0x03 or 0x04 or 0x05 or 0x06 or
0x07, sensors at location (1 or 2 or 3 or 4 or 5 or 6 or 7 or 8) are on, and this
means that one or more of these places is reserved or not available, and
according to this decreasing the number of free places in this floor, and then
display on the main LCD the number of available places in floor1, and
display on floor1 LCD the available places in this floor.
 If the reading signal was not any of 0x01 or 0x02 or 0x03 or 0x04 or 0x05 or
0x06 or 0x07, sensors at location (1 or 2 or 3 or 4 or 5 or 6 or 7 or 8) are off,
and this means that one or more of these places is available, and according to
this increasing the number of free places in this floor, and then display on the
main LCD the number of available places in floor1, and display on floor1
LCD the available places in this floor.

5.6.3 Floor Two Flow Chart

Floor two is the same as floor one instead of using port b as input port.

٧٩
Set port b as
input port

Read port b

Yes If No
sensor 1 or 2 or 3 or
4 or 5 or 6 or 7 or 8
on

Decrease no. of Increase no. of


available places avaiialable places
Counter2-- Counter2++

Display on main Display on Main


LCD number of LCD the number of
available places in available placs in
floor2 floor2

Display on floor1
LCD the available
places in this floor

Figure (5.9): Floor Two Sensors Flow Chart

٨٠
5.6.4 Main LCD Flow Chart

Initialize LCD

Clear LCD

Set curser at home


position

Check LCD Status

Yes If No
print_to_lcd=1

Print to serial
Print to LCD
screen

Figure (5.10): Main LCD Flow Chart

٨١
As shown in previous (figure 5.10) the LCD has many signals to perform its
operation, and the previous (figure 5.9) demonstrate how the LCD perform its
specific action, and consist of many steps such as:

 Initialize main LCD, to turn the LCD and cursor on.


 Clear the LCD to write to it.
 Set the cursor of the LCD at home position or at the beginning of line one of the
LCD.
 Then check if print_to_lcd 1 display on the LCD, and if print_to_lcd 0 then
display on the serial port.

5.6.5 Motor1 and Motor2 Flow Chart

Motor needed to open and close the entrance and exit gates. Motor function gets
its information from the sensors of the gates and according to them decides what to
do, as shown in figure (5.11) when sensors at entrance or exit gates become on, the
motors will be turn right to open the gates, and after a delay time it will turn left to
close the gate.

٨٢
Set port c upper as
output port

Out on port c the


value 20h
(open entrance
gate)

Delay
Motor1_left
(close entrance gate)

Figure (5.11) Motor1 Flow Chart

Set port c upper as


output port

Out on port c the


value 80h
(open exit gate)

Delay
Motor2_left
(close exit gate)

Figure (5.12):Motor2 Flow Chart

٨٣
5.7 Algorithms and Pseudocode

Public Class Form1


Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Timer1.Interval = 30000 'set the timer to check the sensors each 30 second
Timer1.Start() 'initialization of timer 1
Gates_Sensors() 'sensor of the gate initialization
Floor1_Sensors() 'sensor of floor1 initialization
Floor2_Sensors() 'sensor of floor2 initialization
End Sub

Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
End Sub

Sub Gates_Sensors() 'gate of sensor sub code


Dim c As Short
Out(&H37AS, 8S) 'h=hex, s=short, 37A=control register
c = Inp(&H379) 'read parallel port status register

If c And 8 Then 'if entrance gate sensor pressed


Motor1_Right() 'open the gate move the motor to the right
delay(50) 'delay after gate close
Motor1_left() 'close the gate
ElseIf c = 16 Then 'if exit gate sensor pressed
Motor2_Right() 'open the gate
delay(50) 'delay after gate close

٨٤
Motor2_left() 'close the gate move the motor to the left
ElseIf c = 24 Then 'if both entrance and exit gates sensors pressed
Motor1_Right() 'open entrance and exit gates
Motor2_Right()
delay(50)

Motor1_left() 'close entrance and exit gates


Motor2_left()
End If
End Sub

Sub Motor1_Right() 'sub code for movement the motor to the right=open
Out(&H37AS, 0) 'write control word to set ports a,b,c as output ports
Out(&H378, 128)
Out(&H37A, 1)
Out(&H378, 1)
Out(&H37AS, 3)
' delay(10)

'Motor1_left()
End Sub

Sub Motor1_left() 'left movement to the motor


Out(&H37A, 1)
Out(&H378, 0)
Out(&H37AS, 3)
End Sub

Sub Motor2_Right() 'right movement for the motor


Out(&H37AS, 0)

٨٥
Out(&H378, 128)
Out(&H37A, 1)
Out(&H378, 2)
Out(&H37AS, 2)
'delay(50)
'Motor2_left()
End Sub

Sub Motor2_left() 'left movement to the motor


Out(&H37A, 1)
Out(&H378, 0)
Out(&H37AS, 2)
End Sub

Sub Floor1_Sensors() 'read the signal in eavh sensor in floor 1


Dim a As Short
Dim c1 As Integer
c1 = 0

Out(&H37AS, 8S)
a = Inp(&H379S)
If (a And 32) Then
' c1 -= 1
Main1_lcd(c1) 'put the number of free places in the main LCD

Else
c1 += 1
Main1_lcd(c1)
Floor1_lcd(1) 'put the exactly free location in sub LCD
End If

٨٦
If (a And 64) Then
c1 -= 1
Main1_lcd(c1)

Else
c1 += 1
Main1_lcd(c1)
Floor1_lcd(2)
End If

If (a And 128) Then


c1 -= 1
Main1_lcd(c1)

Else
c1 += 1
Main1_lcd(c1)
Floor1_lcd(1)
End If

Out(&H37AS, 4S)

If (a And 8) Then
c1 -= 1
Main1_lcd(c1)

Else
c1 += 1
Main1_lcd(c1)

٨٧
Floor1_lcd(2)
End If
End Sub

Sub Floor2_Sensors() 'the same as floor1

Dim b As Short
Dim c2 As Integer = 0
Out(&H37AS, 4)
b = Inp(&H379S)

If (b And 16) Then

Main2_lcd(c2)

Else
c2 += 1
Main2_lcd(c2)
Floor2_lcd(1)
End If

If (b And 32) Then


c2 -= 1
Main2_lcd(c2)

Else
c2 += 1
Main2_lcd(c2)
Floor2_lcd(2)
End If

٨٨
If (b And 64) Then
c2 -= 1
Main2_lcd(c2)

Else
c2 += 1
Main2_lcd(c2)
Floor2_lcd(1)
End If

If (b And 128) Then


c2 -= 1
Main2_lcd(c2)

Else
c2 += 1
Main2_lcd(c2)
Floor2_lcd(2)
End If
End Sub

Sub Main1_lcd(ByVal c11 As Integer)


Dim s As String
Dim arr1 As String() = New String() {"F", "L", "O", "O", "R", "1", ":",
"c11"}

Dim j As Integer

Main1_lcd_init() 'initialization to main LCD

٨٩
'Main1_lcd_cursor(1, 0) 'put the cursor in the first position
For j = 0 To arr1.Length
Main1_lcd_write(arr1(j))
Next
End Sub

Sub Main1_write_control(ByVal control As Short)


Out(&H37AS, 0) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 2) 'port b
Out(&H378S, 0) 'clear Rs
Out(&H37AS, 1)
Out(&H37AS, 3) 'port a
Out(&H378S, control)
Out(&H37AS, 1)
Out(&H37AS, 2)
Out(&H378S, 1)
Out(&H37AS, 1)
delay(600)
Out(&H37AS, 2)
Out(&H378S, 0)
Out(&H37AS, 1)
End Sub

Public Sub Main1_lcd_init() 'sub LCD initialization


Main1_write_control(1)
delay(60000)
Main1_write_control(56)
delay(60000)
Main1_write_control(14)

٩٠
delay(6000)
Main1_write_control(6)
delay(6000)
Main1_write_control(128)
End Sub

Sub Main1_lcd_write(ByVal out1 As String)


'Write character on LCD
Out(&H37AS, 0) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 2) 'port B
Out(&H378S, 4) 'set Rs
Out(&H37AS, 1)
Out(&H37AS, 3) 'port a
Out(&H378S, Asc(out1))
Out(&H37AS, 1)
Out(&H37AS, 2)
Out(&H378S, 5)
Out(&H37AS, 1)
delay(600)
Out(&H37AS, 2)
Out(&H378S, 4)
Out(&H37AS, 1)
End Sub

'Sub Main1_lcd_cursor(ByVal row As Short, ByVal column As Short)


' If (row = 1) Then
' Main1_write_control(128 + column)
' Else
' Main1_write_control(192 + column)

٩١
'End If
'
' End Sub
'Sub Main1_lcd_home()

Sub Main2_lcd(ByVal c22 As Integer)


'Sub LCD initialization
Dim j1 As Integer
Dim arr2 As String() = New String() {"F", "L", "O", "O", "R", "2", ":",
"c22"}

Main2_lcd_init()
' Main2_lcd_cursor(2, 0)
'Main2_lcd_home()
For j1 = 0 To arr2.Length
Main2_lcd_write(arr2(j1))
Next
End Sub

Sub Main2_write_control(ByVal control As Short)


Out(&H37AS, 0) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 2) 'port b
Out(&H378S, 0) 'clear Rs
Out(&H37AS, 1)
Out(&H37AS, 3) 'port a
Out(&H378S, control)
Out(&H37AS, 1)
Out(&H37AS, 2)
Out(&H378S, 1)

٩٢
Out(&H37AS, 1)
delay(600)
Out(&H37AS, 2)
Out(&H378S, 0)
Out(&H37AS, 1)
End Sub

Public Sub Main2_lcd_init()


Main2_write_control(1)
delay(60000)
Main2_write_control(56)
delay(60000)
Main2_write_control(14)
delay(6000)
Main2_write_control(6)
delay(6000)
Main2_write_control(192)
End Sub

Sub Main2_lcd_write(ByVal out1 As String)

Out(&H37AS, 0) 'control register


Out(&H378S, 128) 'control Word
Out(&H37AS, 2) 'port B
Out(&H378S, 4) 'set Rs
Out(&H37AS, 1)
Out(&H37AS, 3) 'port a
Out(&H378S, Asc(out1))
Out(&H37AS, 1)
Out(&H37AS, 2)

٩٣
Out(&H378S, 5)
Out(&H37AS, 1)
delay(600)
Out(&H37AS, 2)
Out(&H378S, 4)
Out(&H37AS, 1)
End Sub

'Sub Main2_lcd_cursor(ByVal row As Short, ByVal column As Short)


' If (row = 1) Then
' Main2_write_control(128 + column)
' Else
' Main2_write_control(192 + column)
'End If
'
' End Sub

Sub Floor1_lcd(ByVal aa1 As Short)

Floor1_lcd_init()

If (aa1 = 1 Or aa1 = 2) Then


Floor1_lcd_write("A")
Floor1_lcd_write(":")
Floor1_lcd_write(aa1)
Else
Floor1_lcd_write("B")
Floor1_lcd_write(":")
Floor1_lcd_write(aa1)
End If

٩٤
End Sub

Sub Floor1_write_control(ByVal control As Short)


Out(&H37AS, 12) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 13) 'port c
Out(&H378S, 0) 'clear Rs
Out(&H37AS, 14)
Out(&H37AS, 15) 'port a
Out(&H378S, control)
Out(&H37AS, 14)
Out(&H37AS, 13)
Out(&H378S, 1)
Out(&H37AS, 14)
delay(600)
Out(&H37AS, 13)
Out(&H378S, 0)
Out(&H37AS, 14)
End Sub

Public Sub Floor1_lcd_init()


Floor1_write_control(1)
delay(60000)
Floor1_write_control(56)
delay(60000)
Floor1_write_control(14)
delay(6000)
Floor1_write_control(6)
delay(6000)
End Sub

٩٥
Sub Floor1_lcd_write(ByVal out1 As String)
If (out1 = 1 Or out1 = 2) Then
Floor1_lcd_cursor(1, out1 + 2)
Else
Floor1_lcd_cursor(2, out1 + 2)
End If

Out(&H37AS, 12) 'control register


Out(&H378S, 128) 'control Word
Out(&H37AS, 13) 'port B
Out(&H378S, 4) 'set Rs
Out(&H37AS, 14)
Out(&H37AS, 15) 'port a
Out(&H378S, Asc(out1))
Out(&H37AS, 14)
Out(&H37AS, 13)
Out(&H378S, 5)
Out(&H37AS, 14)
delay(600)
Out(&H37AS, 13)
Out(&H378S, 4)
Out(&H37AS, 14)
End Sub

Sub Floor1_lcd_cursor(ByVal row As Short, ByVal column As Short)


If (row = 1) Then
Floor1_write_control(128 + column)
Else
Floor1_write_control(192 + column)

٩٦
End If
End Sub

Sub Floor2_lcd(ByVal bb1 As Short)

Floor2_lcd_init()
Floor2_lcd_cursor(1, 0)
'Floor2_lcd_home()
If (bb1 = 1 Or bb1 = 2) Then
Floor2_lcd_write("A:" & bb1)
Floor1_lcd_write(":")
Floor1_lcd_write(bb1)

Else
Floor2_lcd_write("B:" & bb1)
Floor1_lcd_write(":")
Floor1_lcd_write(bb1)
End If
End Sub

Sub Floor2_write_control(ByVal control As Short)


Out(&H37AS, 12) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 13) 'port c
Out(&H378S, 0) 'clear Rs
Out(&H37AS, 15)
Out(&H37AS, 14) 'port a
Out(&H378S, control)
Out(&H37AS, 15)
Out(&H37AS, 13)

٩٧
Out(&H378S, 16)
Out(&H37AS, 15)
delay(600)
Out(&H37AS, 13)
Out(&H378S, 0)
Out(&H37AS, 15)
End Sub

Public Sub Floor2_lcd_init()


Floor2_write_control(1)
delay(60000)
Floor2_write_control(56)
delay(60000)
Floor2_write_control(14)
delay(6000)
Floor2_write_control(6)
delay(6000)
End Sub

Sub Floor2_lcd_write(ByVal out2 As String)


If (out2 = 1 Or out2 = 2) Then
Floor1_lcd_cursor(1, out2 + 2)

Else
Floor1_lcd_cursor(2, out2 + 2)
End If

Out(&H37AS, 12) 'control register


Out(&H378S, 128) 'control Word
Out(&H37AS, 13) 'port c

٩٨
Out(&H378S, 64) 'set Rs
Out(&H37AS, 15)
Out(&H37AS, 14) 'port b
Out(&H378S, Asc(out2))
Out(&H37AS, 15)
Out(&H37AS, 13)
Out(&H378S, 80)
Out(&H37AS, 15)
delay(600)
Out(&H37AS, 13)
Out(&H378S, 64)
Out(&H37AS, 15)
End Sub

Sub Floor2_lcd_cursor(ByVal row As Short, ByVal column As Short)


If (row = 1) Then
Floor2_write_control(128 + column)

Else
Floor2_write_control(192 + column)
End If

delay(60)
End Sub

'Sub Floor2_lcd_home()
' Floor2_write_control(2)
'End Sub
Sub delay(ByVal time As Integer)
Dim i As Integer

٩٩
For i = 0 To time
Next
End Sub
End Class

١٠٠
6
Implementation and Testing

6.1 Preface.
6.2 Implementation.
6.3 Testing.
6.4 Implementation and testing for Integrated System.

١٠١
Chapter Six
Implementation and Testing

6.1 Preface

In this chapter shows the implementation and testing processes for our system.
And demonstrates the methods and procedures used for testing and examine the
system operation and behavior.

The implementation and testing was done by using the following tools and
components:

 Connectors with different colors.


 All the ICs that are depicted in the design chapter (see chapter 4).
 Wrapper tool for wrapping the connectors on the ICs stands.
 A wire grabber and a wire cutter.
 A digital Millimeter for testing.

This system has more than one issue to be tested. Some testing parts reflect a
software, hardware .Also, testing procedures concentrate on a single device
independent from the over whole system. Here are the testing issues.

6.2 Implementation

The implementation process is done synchronized with the testing operation,


because each implementation phase will take many testing to ensure that there are no
errors.

١٠٢
6.3 Testing

In this section we will demonstrate the testing of each subsystem separately.

6.3.1 Testing 8051 Downloading Programs:

Testing the ability to download a program on the 8051 development kit.

Figure (6.1): Port Testing Example (LEDs)

We test this circuit by C program language that reads the signal and store it,
this circuit had been tested many times to emphasize better results, and we use this
program to testing this circuit.

We tested the port E and the LEDs by using the fpllowing C program, the port
E was acts as output port.

#include "delay_ms.h"
#include "paulmon2.h"
/* these are the memory-mapped locations used to access */
/* the two 82C55 chips */
xdata at 0xF800 unsigned char p82c55_port_a;
xdata at 0xF801 unsigned char p82c55_port_b;

١٠٣
xdata at 0xF802 unsigned char p82c55_port_c;
xdata at 0xF803 unsigned char p82c55_abc_config;
xdata at 0xF900 unsigned char p82c55_port_d;
xdata at 0xF901 unsigned char p82c55_port_e;
xdata at 0xF902 unsigned char p82c55_port_f;
xdata at 0xF903 unsigned char p82c55_def_config;

#define VERBOSE
code unsigned char pattern_table[] = {
0x7F, /* 01111111 */
0x3F, /* 00111111 */
0x1F, /* 00011111 */
0x8F, /* 10001111 */
0xC7, /* 11000111 */
0xE3, /* 11100011 */
0xF1, /* 11110001 */
0xF8, /* 11111000 */
0xFC, /* 11111100 */
0xFE, /* 11111110 */
0xFC, /* 11111100 */
0xF8, /* 11111000 */
0xF1, /* 11110001 */
0xE3, /* 11100011 */
0xC7, /* 11000111 */
0x8F, /* 10001111 */
0x1F, /* 00011111 */
0x3F, /* 00111111 */
255};
code unsigned char delay_table[] = {
90, 70, 50, 40, 40, 40, 40, 50, 70, 90, 70, 50, 40, 40, 40, 40, 50, 70, 0};

١٠٤
/* zero marks end of table */
void main()
{
unsigned char i =0;
p82c55_abc_config = 128; /* all ports outputs */
p82c55_def_config = 128;
while (1) {
if (delay_table[i] > 0) {
p82c55_port_e = pattern_table[i];
delay_ms(delay_table[i]);
#ifdef VERBOSE
pm2_pstr("Pattern=0x");
pm2_phex(pattern_table[i]);
pm2_pstr(" for delay=");
pm2_pint8u(delay_table[i]);
pm2_newline();
#endif
i++;
} else {
i = 0;
}
if (pm2_esc()) pm2_restart();
}
}

This C program can use for other ports and test them.

١٠٥
6.3.2 Motors and H-Bridges Testing

Testing the motors and H-Bridges are implemented by connecting them to


shown in figure (6.2), and applying the following code to activate the motors in
forward and reverse direction.

Figure (6.2): Motor circuit

We test this circuit by C program language, and we use this program to testing
this circuit. See sample (1.a) written in C language and sample (1.b) written in
VB.net at Appendix A.

6.3.2.1 Option One Using C Language for Motor Testing

See sample (1.a) at Appendix A.

١٠٦
6.3.2.2 Option Two Using VB.net for Motor Testing

See sample (1.a) at Appendix A.

6.3.3 Switches Testing

Testing the switches is implemented by connecting them to as shown in


figure (6.3) and applying the following software.

Figure (6.3.a): Switch circuit off

١٠٧
Figure (6.3.b): Switch circuit on

We test this circuit by C program language, this circuit had been tested many
times to emphasize better results, and we use this program to testing this circuit.

6.3.3.1 Option One Using C Language for Switch Testing

See sample (2.a) at Appendix A.

6.3.3.2 Option Two Using VB.net for Switch Testing

See sample (2.b) at Appendix A.

١٠٨
6.3.4 LCDs Testing

Testing the LCDs is implemented by connecting them with the parallel port.
The LCD circuit tested by C program and VB.net program.

Figure (6.4): LCD Testing

6.3.4.1Option One Using C Language for LCD Testing

See sample (3.a) at Appendix A.

6.3.4.2 Option Two Using Vb.net for LCD Testing

See sample (3.b) at Appendix A.

6.3.5 Access the parallel port using VB.net

To access the parallel port using the VB.net we get an input.dll library, which
must add to system32, and then we define a parallel port that will be used as an
object to open and access the ports, as the followed:

6.3.5.1 Testing Output Ports in VB.net

١٠٩
Testing the output on parallel port implemented by connecting them as shown
in figure (6.4), and applying code. See sample (4.a) at Appendix A.

Figure (6.5): Output Port Testing

6.3.5.2 Testing input ports in VB.net

Testing the input on parallel port implemented by connecting them as shown


in figure (6.5), and applying program. See sample (4.b) at Appendix A.

Figure (6.6): Input Port Testing

١١٠
6.4 Implementation and Testing for Integrated System

As we mentioned previously after completing any circuit that we described it in


chapter four we use the C language And VB.net language to test each subsystem and
test every input and output with different cases and speed.

After completing VB.net program with test the whole system on the program,
the finally results are successfully on software and hardware control.

١١١
7
Conclusion and Future Work

7.1 Preface
7.2 Conclusion
7.3 Future work

١١٢
Chapter Seven
Conclusion and Future Work

7.1 Preface

This chapter represents the conclusions extracted during designing and


implementing it and illustrates the system implementation achievements and output.

• Team spent 30-40 hours a week in the university lab working on this project. We
learned a lot and used everything we had to solve the problems. We had many
limitations on this project that made it even more challenging.
• Building this system was a great way of combining all of the knowledge that we
have learned over the five years at university. We were able to create a project and
build it. Building the system taught us how to accomplish a goal. We really wanted
to have our system completed before handing this documentation, but unfortunately
things didn't go as we wanted.
• This project proved that our ideas are available for implementation in a project that
resembles a real-life.
• Our system is smart car parking system. This system aims to make Smart Park
controlled electrically.
• The main device in the system is the 8051 microcontroller; all other devices are
controlled through programming it. While the other devices are maintained in
various subsystems which are:
- Sensor subsystem: contains interlocking push buttons for each location.
- LCDs subsystem: contains three LCDs (main LCD and two LCDs for one each
floor).
- Motors Subsystem: contains the motors and their H-Bridges circuits.

١١٣
• For programming the 8051 microcontroller, we used C++ program language and
VB.NET program language.
• Each device was tested individually in its own circuit to study its behavior and
make sure it works properly and can do its expected job.

The Smart Car Parking System has achieved the main ideas prepared to. It is
now ready to be applied on the pc. The main features that achieved are:-

1- The team enables to control the hardware applications connected with pc


through parallel port.
2- The team enables to make the system ease to use by everyone.
3- Controlling the hardware applications connected with pc through a parallel
port, the team enables to send data from switches connected with pc through
parallel port, then analyze the data and send the related voltage signal to the
parallel port to run the application related to that signal and then set the
specified data on LCDs.
4- The team enables to send signal to motors connected with pc through parallel
port and controlling its movements.

7.2 Conclusions

After the team finish the design and implementation of the project and
integrated overall system.
The team concludes that, there is ability to control a park through parallel
port connected with PC or microcontroller like 8051.

١١٤
7.2.1 Problems

Here are problems faced the project team during the system implementation:

7.2.1.1 Hardware Problems

• The basic problem is that the 8051 microcontroller in 8051 development kit was
burned and another one is not available in this country, so the team was bought
through the internet from the main company in Germany, and it was sent by the
buyer to the Palestinian in Bethlehem.
• A problem occurred in programming the 8051 microcontroller, there is no
programmer to program this microcontroller.
• The team took an 8051 from another team to continue the team project work but
unfortunately was burned.
• The last choice is to use the parallel port in PC and because of that we covert all our
software from C programming Language to VB.net to solve the problem.
• Internal damage in some devices because of wrong connections, or high voltages or
currents supplied to the devices during the implementation.

7.2.1.2 Software problems

In 8051 programming a lot of considerations should be taken in using this kit


to connect it with PC through serial port and during writing and running the
programs on the microcontroller we faced some initializations and declarations
problems.

In parallel port lot of initialization and declaration problems during writing


LCD code.

١١٥
7.3 Future work

During the system period the team enables to achieve the main goals he started
to do them. Although there are sum techniques that could be used to reach the objects
in less time but we started our system from the zero and we used the most available
and simple equipments to emphasize the result and prove this of controlling the
hardware application connected with pc.

1. Use a robot that follows a particular line and determines whether there is
any availability of space. Like a watchman.
2. Use cameras for each location (not sensors), to give information a bout
free places.
3. To wireless technology in this system to connects all over the system.
4. Use charging system for every customer enters the park, to control the
hours for each customer put his car in the park and its related cost.

١١٦
References

Books

 Sencer Yeralan and Ashutosh Ahluwalia, Programming Interfacing 8051


Microcontroller, Addison Wesly, 1995.
 David M Calcutt and Frederick J Cowan and G Hassan Parchizadeh, 8051
Microcontroller, A member of the Hodder Headline Group,1998.
 Hans_Peter Messmer, The Independence PC Hardware Book 3rd Edition,
Addison Wesly, 1997.

Internet

 http://www.hillelectronics.com/html/pro_hiltron_HM810R.htm
 http://www.winpicprog.co.uk
 http://www.ptc2.com/vb/showthread.php?t=93
 http://www.plcs.net/
 http://rapidshare.de/files/22449655/GR2-CPACImagingPro.rar.html
 http://www.ptc2.com/vb/showthread.php?t=118
 http://chaokhun.kmitl.ac.th/~kswichit/rtc/rtc.htm
 http://chaokhun.kmitl.ac.th/~kswichit/
 http://www.epanorama.net/links/microprocessor.html#8051
 http://www.tkne.net/vb/register.php
 http://www.pjrc.com/
 http://www.Interfacing the Standard Parallel Port.htm
 http://www.Interfacing the LCD module to PC parallel port
ElectroSOfts_com.htm

١١٧
Appendix

١١٨
Appendix A
Code Samples

١
1. Motor

(1.a) Option One Using C Language for Motor Testing

void motor1_right()
{
p82c55_abc_config=146; // set port c output
p82c55_port_c=0x08; // open entrance gate
delay_ms(5);
motor1_left()
}
void motor1_left()
{
p82c55_port_c=0x00; // close entrance gate
}

void motor2_right()
{
p82c55_abc_config=146; // set port c output
p82c55_port_c=0x20; // open exit gate
delay_ms(5);
motor2_left()
}

void motor2_left()
{
p82c55_port_c=0x00; // close exit gate
}

٢
(1.b) Option Two Using VB.net for Motor Testing

Sub Motor1_Right()
Out(&H37AS, 0) 'write control word to set ports a,b,c as output ports
Out(&H378, 128)
Out(&H37A, 1)
Out(&H378, 2)
Out(&H37AS, 3)
delay(10)
Motor1_left()
End Sub

2. Switch

(2.a) Option One Using C Language for Switch Testing

void floor1_switch ()
{
p82c55_abc_config=155;
aa=p82c55_port_a;
a=(aa & 0x01);
if(a==0x01)
c1--;
Main1_Lcd(c1);
floor_lcd();
else c1++;
Main1_lcd(c1);
floor1_lcd();
a=(aa & 0x02);

٣
if(a==0x02)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);
floor1_lcd();
a=(aa & 0x03);
if(a==0x03)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);
floor1_lcd();
a=(aa & 0x04);
if(a==0x04)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);
floor1_lcd();
a=(aa & 0x05);
if(a==0x05)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);

٤
floor1_lcd();
a=(aa & 0x06);
if(a==0x06)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);
floor1_lcd();
a=(aa & 0x07);
if(a==0x07)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);
floor1_lcd();
a=(aa & 0x08);
if(a==0x08)
c1--;
Main1_lcd(c1);
floor1_lcd()
else c1++;
Main1_lcd(c1);
floor1_lcd();
}

٥
(2.b) Option Two Using VB.net for Switch Testing

Sub Floor1_Sensors()

Dim a As Short
Dim c1 As Integer

a = Inp(&H379)
Out(&H37AS, 9)

If (a And 0) Then
c1 -= 1
Main1_lcd(c1)

Else : c1 += 1
Main1_lcd(c1)
Floor1_lcd(1)
End If

If (a And 1) Then
c1 -= 1
Main1_lcd(c1)

Else : c1 += 1
Main1_lcd(c1)
Floor1_lcd(2)
End If

If (a And 2) Then
c1 -= 1

٦
Main1_lcd(c1)

Else : c1 += 1
Main1_lcd(c1)
Floor1_lcd(3)
End If

If (a And 3) Then
c1 -= 1
Main1_lcd(c1)

Else : c1 += 1
Main1_lcd(c1)
Floor1_lcd(4)

End If

If (a And 4) Then
c1 -= 1
Main1_lcd(c1)

Else : c1 += 1
Main1_lcd(c1)
Floor1_lcd(5)

End If

If (a And 6) Then
c1 -= 1
Main1_lcd(c1)

٧
Else : c1 += 1
Main1_lcd(c1)
Floor1_lcd(6)
End If

End Sub

3. LCD

(3.a) Option One Using C Language for LCD Testing

#include "lcd_driver.h"
#include <stdio.h>
#include <8051.h>
#include <paulmon2.h>
#include "delay_ms.h"
/***********************************/
void initial_lcd();
void clear_lcd();
void lcd_write(char cc);
void lcd_cursor(char row,char column);
void write_control(char control );
xdata at 0xF900 unsigned char p82c55_port_d;
xdata at 0xF901 unsigned char p82c55_port_e;
xdata at 0xF902 unsigned char p82c55_port_f;//E, R/W, RS
xdata at 0xF903 unsigned char p82c55_def_config;
void main(){
p82c55_def_config=128;

٨
initial_lcd();
clear_lcd();
lcd_write('H');
}
void write_control(char control){
p82c55_port_f=0x00;
p82c55_port_d=control;
p82c55_port_f=0x01;
p82c55_port_f=0x00;
delay_ms(5);
}
void initial_lcd(){
write_control(0x38)
delay_ms(5);
write_control(0x0e);
delay_ms(5);
write_control(0x06);
delay_ms(5);
}

void clear_lcd(){
write_control(0x01);
delay_ms(5);
}

void lcd_write( char cc){


lcd_cursor(1,1);
p82c55_port_f=0x04;
p82c55_port_d=cc;
p82c55_port_f=0x01;

٩
p82c55_port_f=0x00;
delay_ms(5);
}

void lcd_cursor(char row,char column){


if (row==1)
write_control(0x80+column);
else
write_control(0xc0+column)
delay_ms(5);
}

(3.b) Option Two Using VB.net for LCD Testing

Public Class Form1


Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As String
lcd_init()
lcd_cursor(1, 0)
' write_control(192)
lcd_write("A")
'lcd_write("I")
'lcd_write("H")
'lcd_write("A")
'lcd_write("N")
End Sub
Sub write_control(ByVal control As Short)

١٠
Out(&H37AS, 8) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 10) 'port B
Out(&H378S, 0) 'clear Rs
Out(&H37AS, 9)
Out(&H37AS, 11) 'port a
Out(&H378S, control)
Out(&H37AS, 9)
Out(&H37AS, 10)
Out(&H378S, 1)
Out(&H37AS, 9)
delay(50000)
Out(&H37AS, 10)
Out(&H378S, 0)
Out(&H37AS, 9)
End Sub

Public Sub lcd_init()


write_control(1)
delay(60000000)
write_control(56)
delay(60000000)
write_control(14)
delay(60000000)
write_control(6)
delay(60000000)
End Sub

' Sub write_char(ByVal c As String)


' Dim i As Integer

١١
' For i = 0 To c.length
'' lcd_write(Asc(c))
'Next
'End Sub

Sub lcd_write(ByVal out1 As String)


Out(&H37AS, 8) 'control register
Out(&H378S, 128) 'control Word
Out(&H37AS, 10) 'port B
Out(&H378S, 4) 'set Rs
Out(&H37AS, 9)
Out(&H37AS, 11) 'port a
Out(&H378S, Asc(out1))
Out(&H37AS, 9)
Out(&H37AS, 10)
Out(&H378S, 5)
Out(&H37AS, 9)
delay(50)
Out(&H37AS, 10)
Out(&H378S, 4)
Out(&H37AS, 9)
End Sub

Sub lcd_cursor(ByVal row As Short, ByVal column As Short)


If (row = 1) Then
write_control(128 + column)
Else
write_control(192 + column)
End If
End Sub

١٢
Sub delay(ByVal time As Integer)
Dim i As Integer = 0
For i = 0 To time
Next
End Sub
End Class

(4.a) Output Ports in VB.net Using Parallel Port

Public Class Form1


Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Out(&H37AS, 8) 'control register
Out(&H378S, 128) 'control Word
out(&H37AS, 11) 'port a
Out(&H378S, 255)
Out(&H37AS, 9)
End Sub
End Class

(4.b) Input ports in VB.net Using Parallel Port

Public Class Form1


Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

١٣
TextBox1.Text = Inp(&H379S)
End Sub
End Class

١٤
8051 Development Board Data Sheet

The 8051 development board provides an easy-to-use and low-cost


way to develop your 8051 based microcontroller projects, without purchasing
any other special equipment, such as IC programmers or emulators. All
required software is available as a free download, including a C compiler !

Features:
 Standard 87C52 CPU clocked at 22.1184 MHz
 50 I/O lines!! All I/O lines are clearly labeled and available at the edge of the
prototype construction area.
 32k SRAM, program variables and code (24k usable for code download)
 30k Flash ROM, non-volatile program storage and data logging

١
 High speed baud rates: 115200, 75600, 38400, etc. All standard baud rates
are supported (except 300 baud)
 Display port, works with standard character-based LCDs. A 16x2 display will
be available from PJRC (see photo below)
 Eight LEDs, controlled by 8 dedicated I/O lines (not shared with the 50 I/O
lines)
 Bus expansion with 4 chip select signals, for adding UARTs, A/D converters
and other bus-based peripheral chips.
 Unregulated, polarity-protected DC voltage input with 2 position terminal
block.
 PAULMON2 monitor for easy code development without additional
equipment.

LCD Display Port

The 8051 development board's LCD port provides the 14 signals needed for
standard character based LCD modules. A 20x2 display is available from PJRC :

٢
Requirements

 DC Voltage, 8 to 15 volts (regulated), 50 mA or 300 mA with LCD.


 PC Computer with Serial Port, Linux or Microsoft Windows 95-OSR2, 98,
98SE, NT4, 2000.
 Assembler or Compiler, usually AS31 or SDCC
 Terminal Emulation Program, e.g. HyperTerminal (windows), Minicom
(linux)
 Text Editor Program, e.g. Notepad, Vi, Emacs
 Standard 9 pin serial cable (straight through, not null-modem!).

٣
Schematic

٤
Ports

٥
1. LCD Port

The LCD port provides the 14 standard signals required to interface to


nearly all standard alpha-numeric character mode displays from 8 to 80
characters. VDD provides +5 volt regulated power to the display (VSS is
Ground). VEE ranges from 0 (maximum intensity) to 2 volts (minimum
intensity) with the adjustment of the variable resistor located just above
next to the power input.

The E signal is an active high enable, which is asserted when the processor
makes a memory access within the address range of 0xFE00 to 0xFEFF. RS and
R/W are control lines for the display. In order to meet the timing requirements for all
standard LCD displays, these are connected to the processor's address lines so they
are asserted and remain stable while E is asserted. Because of this, separate locations
are used to read and write to the LCD. See the memory map page for details.

2. I/O Lines

The 8051 development board provides 50 dedicated I/O lines, which are
accessible along the top edge of the board's prototype construction area. Together
with the 50 I/O lines, 4 pads provide easy access to the regulated +5 volt power from
the board's voltage regulator.

The P1.0 through P1.7 are connected directly to the 87C52's port #1. These pins are
the easiest to use as single bits. In assembly, they are written using "CLR P1.4" or
"SETB P1.4", and they are read using "MOV C, P1.4" (moves the bit value into the
carry bit). In C (using SDCC, with #include <8051.h>), they are accessed using

٦
names such as "P1_4". For example: if (!P1_3) printf("pin P1.3 is low"); The 8051
port pins are quasi-bidirectional, which essentially means that you must write a 1
(which is the default) to the pin to cause it to act as an input.

Signals INT0 and INT1 connect to the 87C52's two interrupt pins. The 87C52
can be configured to execute and interrupt routine associated with each pin when it is
low or when a falling edge occurs. In the low level sensitive setting, the interrupt
service code usually takes some action which causes the hardware to stop driving the
pin low, so that another interrupt does not immediately occur when the interrupt
service code returns to the main program. If interrupt are not enabled, these pins can
be accessed as ordinary P3.2 and P3.3 port pins. INT1 is also connected to the
SINGLE STEP jumper and will be shorted to ground if that jumper is installed.

PA.0 to PA.7, PB.0 to PB.7, and PC.0 to PC.7 are connected to a 82C55 chip
mapped at 0xF800. PD.0 to PD.7 and PF.0 to PF.7 are connected to a second 82C55
chip mapped at 0xF900, and they correspond to ports A and C on that second chip,
but that second chips ports are labeled D, E, and F to avoid confusion with the ports
from the first 82C55 chip (port E connects to the 8 LEDs). Each 82C55 chip is
controlled with 4 memory mapped locations, one to read or write each 8-bit port, and
a 4th register to configure the 82C55 chip. See the memory map page for details. The
82C55 must first be configured by writing a byte to its config register, and then the
three locations which access the ports may be used.

Jumpers

٧
A 4-pin header may be used for two optional jumpers. The upper two pins
may be shorted to erase the flash rom, and the lower two pins may be
shorted to enable the single-step feature.

The FLASH ERASE jumper causes T1 (also P3.5, pin 17 on the 82C52) to
be shorted to ground. During normal operation, this does not erase the flash. When
PAULMON2 boots, it reads this pin and if it remains shorted for 256 consecutive
reads, the PAULMON2 will erase the flash rom chip. Normally the flash rom is
erased from the PAULMON2 menu using the 'Z' command. However, if you have
loaded a program into the flash rom and used and "auto-start" header on it,
PAULMON2 will jump to your code instead of presenting the normal menus on the
serial port. If your code does not return back to the monitor, then you will be unable
to get to the normal PAULMON2 menus and this pin will allow you to erase the chip
you can return to the menus and download a new version of your program.

The SINGLE STEP jumper shorts the INT1 interrupt pin to ground. This is
required to use PAULMON2's single-step feature. The single-step operates by
enabling interrupt #1 and using the 8051's feature where 1 instruction is always
executed after and interrupt. This can be a nice way to "see" your code run,
particularly if you are learning assembly. Due to the interrupt usage, it is rarely
useful for debugging sophisticated applications.

Bus Expansion Signals

٨
The 8051 bus signals are available on 34 pins in the center of the
board. These signals are intended to be used with bus- style
peripherals, such as UARTs and A/D converters. All 16 address and 8
data signals are provided. Two GND and two 5V pins provide 5 volt
regulated power from the board's voltage regulator.
The WR and RD signals are active low strobes for write and read. WR
is connected directly to the 87C52's WR pin, but RD is connected to
the 74AC08 AND gate. RD is asserted low with either the 87C52's
PSEN or RD signal is asserted. This means that either MOVX or
MOVC may be used to read your connected peripheral chips. Some
peripheral chips call their read pin OE (output enable). Typically, the RD pin can
connect directly to the peripheral's OE pin.

Four chip select signals, CS2, CS3, CS4, and CS5 are provided to allow easy
connection of most bus-style peripheral chips. Each of these signals is asserted low
when and access is made within its 256 byte range. See the memory map page for
details.

Power Input

The board accepts unregulated DC voltage, between 8 to 12


volts. A terminal block with screws allows a wide range of
wires sizes to easily attach to the board without the need for
a connector. A 1N5819 diode protects against reverse
polarity, and a standard 7805 linear voltage regulator creates the regulated 5 volts
needed by the board's circuitry.
Though the printed maximum voltage is only 12 volts, the board can actually accept
up to 30 volts DC. Higher voltages will cause the 7805 voltage regulator to become

٩
hot. The 7805 includes automatic thermal shutdown, but it can become very hot
before this upper limit is reached, so caution should be observed if a higher input
voltage is used.

The board requires approximately 50 mA when executing code from the flash
rom and communicating with a PC on the serial port. Each LED adds about 4 mA. If
a LCD with a backlight is used, the backlight will consume considerable current. The
16x2 LCD from PJRC uses approximately 250 mA for its backlight. Additional
current also causes the 7805 to heat up, so the board should not be run with more
than 12 volts if a LCD backlight is used.

8051 Software Tools Overview

To develop your 8051-based project, you will need three PC-based programs,
and a development board with a monitor ROM. Here is the typical data flow using
these tools:

For each tool, there you may choose on of several options. The basic tools are:
1. Text Editor
This is where you will compose the code that ultimately will run on
your 8051 board and make you project function. All PC operating

١٠
systems include a text editor, and there are many free text editors
available on the internet. PJRC does not provide a text editor. All
Microsoft Windows systems have NOTEPAD, which is a very
simple editor. Linux systems usually have VI and EMACS installed,
as well as several others.

2. Compiler or Assembler
Your source code will be turned into a .HEX file by either an
Assembler or Compiler, depending on your choice of programming
language. PJRC provides free downloads of the AS31 assembler and
SDCC C Compiler. These free tools are available for Linux-based
Systems and Microsoft Windows. It is also possible to use other
compilers, such as the Keil C compiler.

3. Terminal Emulator
To communicate with your 8051 board, you must run a terminal
emulator program. You will be able to transmit your .HEX file to
the board and run its code, observe its results and information it may
send to the serial port, and you can also use the terminal emulator to
examine and manipulate memory with the Monitor ROM. Microsoft
provides HyperTerminal with windows (often it must be installed
from the windows cdrom using "add/remove programs"). Linux
distributions usually provide minicom.

4. Monitor ROM
The Monitor ROM is 8051 code that runs when your board boots. It
provides interactive menus that allow you to download code, run it,
manipulate memory and perform other functions. All 8051
development boards from PJRC come with PAULMON2 loaded in

١١
the non-erasable internal memory of the 87C52 chip. Using the
monitor, you can cause your code to run on the board. It is also
possible to download your code to non-volatile memory on the
board together with a "auto-start header" that causes PAULMON2
to run your code automatically when the board boots.

١٢
DM74LS244 Octal 3-STATE Buffer/Line Driver/Line Receiver
August 1986
Revised March 2000

DM74LS244
Octal 3-STATE Buffer/Line Driver/Line Receiver
General Description Features
These buffers/line drivers are designed to improve both the ■ 3-STATE outputs drive bus lines directly
performance and PC board density of 3-STATE buffers/ ■ PNP inputs reduce DC loading on bus lines
drivers employed as memory-address drivers, clock driv-
■ Hysteresis at data inputs improves noise margins
ers, and bus-oriented transmitters/receivers. Featuring 400
mV of hysteresis at each low current PNP data line input, ■ Typical IOL (sink current) 24 mA
they provide improved noise rejection and high fanout out- ■ Typical IOH (source current) −15 mA
puts and can be used to drive terminated lines down to
■ Typical propagation delay times
133Ω.
Inverting 10.5 ns
Noninverting 12 ns
■ Typical enable/disable time 18 ns
■ Typical power dissipation (enabled)
Inverting 130 mW
Noninverting 135 mW

Ordering Code:
Order Number Package Number Package Description
DM74LS244WM M20B 20-Lead Small Outline Integrated Circuit (SOIC), JEDEC MS-013, 0.300 Wide
DM74LS244SJ M20D 20-Lead Small Outline Package (SOP), EIAJ TYPE II, 5.3mm Wide
DM74LS244N N20A 20-Lead Plastic Dual-In-Line Package (PDIP), JEDEC MS-001, 0.300 Wide
Devices also available in Tape and Reel. Specify by appending the suffix letter “X” to the ordering code.

Connection Diagram Function Table


Inputs Output
G A Y
L L L
L H H
H X Z
L = LOW Logic Level
H = HIGH Logic Level
X = Either LOW or HIGH Logic Level
Z = High Impedance

© 2000 Fairchild Semiconductor Corporation DS008442 www.fairchildsemi.com


DM74LS244
Absolute Maximum Ratings(Note 1)
Note 1: The “Absolute Maximum Ratings” are those values beyond which
Supply Voltage 7V the safety of the device cannot be guaranteed. The device should not be
operated at these limits. The parametric values defined in the Electrical
Input Voltage 7V Characteristics tables are not guaranteed at the absolute maximum ratings.
Operating Free Air Temperature Range 0°C to +70°C The “Recommended Operating Conditions” table will define the conditions
for actual device operation.
Storage Temperature Range −65°C to +150°C

Recommended Operating Conditions


Symbol Parameter Min Nom Max Units
VCC Supply Voltage 4.75 5 5.25 V
VIH HIGH Level Input Voltage 2 V
VIL LOW Level Input Voltage 0.8 V
IOH HIGH Level Output Current −15 mA
IOL LOW Level Output Current 24 mA
TA Free Air Operating Temperature 0 70 °C

Electrical Characteristics
over recommended operating free air temperature range (unless otherwise noted)
Min Typ Max
Symbol Parameter Conditions Units
(Note 2)
VI Input Clamp Voltage VCC = Min, II = −18 mA −1.5 V
HYS Hysteresis (VT+ − VT−) VCC = Min 0.2 0.4 V
Data Inputs Only
VOH HIGH Level Output Voltage VCC = Min, VIH = Min
2.7
VIL = Max, IOH = −1 mA
VCC = Min, VIH = Min
2.4 3.4 V
VIL = Max, IOH = −3 mA
VCC = Min, VIH = Min
2
VIL = 0.5V, IOH = Max
VOL LOW Level Output Voltage VCC = Min IOL = 12 mA 0.4
VIL = Max IOL = Max 0.5 V
VIH = Min
IOZH Off-State Output Current, VCC = Max VO = 2.7V 20 µA
HIGH Level Voltage Applied VIL = Max
IOZL Off-State Output Current, VIH = Min VO = 0.4V −20 µA
LOW Level Voltage Applied
II Input Current at Maximum VCC = Max VI = 7V 0.1 mA
Input Voltage
IIH HIGH Level Input Current VCC = Max VI = 2.7V 20 µA
IIL LOW Level Input Current VCC = Max V I = 0.4V −0.5 −200 µA
IOS Short Circuit Output Current VCC = Max (Note 3) −40 −225 mA
ICC Supply Current VCC = Max, Outputs HIGH 13 23
Outputs Open Outputs LOW 27 46 mA
Outputs Disabled 32 54
Note 2: All typicals are at VCC = 5V, TA = 25°C.
Note 3: Not more than one output should be shorted at a time, and the duration should not exceed one second.

www.fairchildsemi.com 2
DM74LS244
Switching Characteristics
at VCC = 5V, TA = 25°C
Symbol Parameter Conditions Max Units

tPLH Propagation Delay Time CL = 45 pF


18 ns
LOW-to-HIGH Level Output RL = 667Ω
tPHL Propagation Delay Time CL = 45 pF
18 ns
HIGH-to-LOW Level Output RL = 667Ω
tPZL Output Enable Time to CL = 45 pF
30 ns
LOW Level RL = 667Ω
tPZH Output Enable Time to CL = 45 pF
23 ns
HIGH Level RL = 667Ω
tPLZ Output Disable Time CL = 5 pF
25 ns
from LOW Level RL = 667Ω
tPHZ Output Disable Time CL = 5 pF
18 ns
from HIGH Level RL = 667Ω
tPLH Propagation Delay Time CL = 150 pF
21 ns
LOW-to-HIGH Level Output RL = 667Ω
tPHL Propagation Delay Time CL = 150 pF
22 ns
HIGH-to-LOW Level Output RL = 667Ω
tPZL Output Enable Time to CL = 150 pF
33 ns
LOW Level RL = 667Ω
tPZH Output Enable Time to CL = 150 pF
26 ns
HIGH Level RL = 667Ω

3 www.fairchildsemi.com
DM74LS244
Physical Dimensions inches (millimeters) unless otherwise noted

20-Lead Small Outline Integrated Circuit (SOIC), JEDEC MS-013, 0.300 Wide
Package Number M20B

www.fairchildsemi.com 4
DM74LS244
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)

20-Lead Small Outline Package (SOP), EIAJ TYPE II, 5.3mm Wide
Package Number M20D

5 www.fairchildsemi.com
DM74LS244 Octal 3-STATE Buffer/Line Driver/Line Receiver
Physical Dimensions inches (millimeters) unless otherwise noted (Continued)

20-Lead Plastic Dual-In-Line Package (PDIP), JEDEC MS-001, 0.300 Wide


Package Number N20A

Fairchild does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and
Fairchild reserves the right at any time without notice to change said circuitry and specifications.
LIFE SUPPORT POLICY

FAIRCHILD’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT
DEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT OF FAIRCHILD
SEMICONDUCTOR CORPORATION. As used herein:
1. Life support devices or systems are devices or systems 2. A critical component in any component of a life support
which, (a) are intended for surgical implant into the device or system whose failure to perform can be rea-
body, or (b) support or sustain life, and (c) whose failure sonably expected to cause the failure of the life support
to perform when properly used in accordance with device or system, or to affect its safety or effectiveness.
instructions for use provided in the labeling, can be rea-
sonably expected to result in a significant injury to the www.fairchildsemi.com
user.

www.fairchildsemi.com 6
This datasheet has been downloaded from:

www.DatasheetCatalog.com

Datasheets for electronic components.


MIC4426/4427/4428 Micrel, Inc.

MIC4426/4427/4428
Dual 1.5A-Peak Low-Side MOSFET Driver

General Description Features


The MIC4426/4427/4428 family are highly-reliable dual low- • Bipolar/CMOS/DMOS construction
side MOSFET drivers fabricated on a BiCMOS/DMOS process • Latch-up protection to >500mA reverse current
for low power consumption and high efficiency. These drivers • 1.5A-peak output current
translate TTL or CMOS input logic levels to output voltage • 4.5V to 18V operating range
levels that swing within 25mV of the positive supply or ground. • Low quiescent supply current
Comparable bipolar devices are capable of swinging only 4mA at logic 1 input
to within 1V of the supply. The MIC4426/7/8 is available in 400µA at logic 0 input
three configurations: dual inverting, dual noninverting, and • Switches 1000pF in 25ns
one inverting plus one noninverting output. • Matched rise and rall times
The MIC4426/4427/4428 are pin-compatible replacements • 7Ω output impedance
for the MIC426/427/428 and MIC1426/1427/1428 with im- • <40ns typical delay
proved electrical performance and rugged design (Refer to • Logic-input threshold independent of supply voltage
the Device Replacement lists on the following page). They • Logic-input protection to –5V
can withstand up to 500mA of reverse current (either polarity) • 6pF typical equivalent input capacitance
without latching and up to 5V noise spikes (either polarity) • 25mV max. output offset from supply or ground
on ground pins. • Replaces MIC426/427/428 and MIC1426/1427/1428
• Dual inverting, dual noninverting, and inverting/
Primarily intended for driving power MOSFETs, MIC4426/7/8
noninverting configurations
drivers are suitable for driving other loads (capacitive, resistive,
• ESD protection
or inductive) which require low-impedance, high peak current,
and fast switching time. Other applications include driving Applications
heavily loaded clock lines, coaxial cables, or piezoelectric • MOSFET driver
transducers. The only load limitation is that total driver power • Clock line driver
dissipation must not exceed the limits of the package. • Coax cable driver
Note See MIC4126/4127/4128 for high power and narrow • Piezoelectic transducer driver
pulse applications.

Functional Diagram
VS

0.6mA INVERTING
0.1mA

OUTA
INA 2kΩ

NONINVERTING

INVERTING
0.6mA
0.1mA

OUTB
INB 2kΩ

NONINVERTING

GND

Micrel, Inc. • 2180 Fortune Drive • San Jose, CA 95131 • USA • tel + 1 (408) 944-0800 • fax + 1 (408) 474-1000 • http://www.micrel.com

February 2007 1 M9999-022307


MIC4426/4427/4428 Micrel, Inc.

Ordering Information

Part Number Temperature


Standard Pb-Free Range Package Configuration
MIC4426AM* Contact Factory –55ºC to +125ºC 8-Pin SOIC Dual Inverting
MIC4426BM MIC4426YM –40ºC to +85ºC 8-Pin SOIC Dual Inverting
MIC4426CM MIC4426ZM –0ºC to +70ºC 8-Pin SOIC Dual Inverting
MIC4426BMM MIC4426YMM –40ºC to +85ºC 8-Pin MSOP Dual Inverting
MIC4426BN MIC4426YN –40ºC to +85ºC 8-Pin PDIP Dual Inverting
MIC4426CN MIC4426ZN –0ºC to +70ºC 8-Pin PDIP Dual Inverting
MIC4427AM* Contact Factory –55ºC to +125ºC 8-Pin SOIC Dual Non-Inverting
MIC4427BM MIC4427YM –40ºC to +85ºC 8-Pin SOIC Dual Non-Inverting
MIC4427CM MIC4427ZM –0ºC to +70ºC 8-Pin SOIC Dual Non-Inverting
MIC4427BMM MIC4427YMM –40ºC to +85ºC 8-Pin MSOP Dual Non-Inverting
MIC4427BN MIC4427YN –40ºC to +85ºC 8-Pin PDIP Dual Non-Inverting
MIC4427CN MIC4427ZN –0ºC to +70ºC 8-Pin PDIP Dual Non-Inverting
MIC4428AM* Contact Factory –55ºC to +125ºC 8-Pin SOIC Inverting + Non-Inverting
MIC4428BM MIC4428YM –40ºC TO +85ºC 8-Pin SOIC Inverting + Non-Inverting
MIC4428CM MIC4428ZM –0ºC to +70ºC 8-Pin SOIC Inverting + Non-Inverting
MIC4428BMM MIC4428YMM –40ºC to +85ºC 8-Pin MSOP Inverting + Non-Inverting
MIC4428BN MIC4428YN –40ºC to +85ºC 8-Pin PDIP Inverting + Non-Inverting
MIC4428CN MIC4428ZN –0ºC to +70ºC 8-Pin PDIP Inverting + Non-Inverting
*Special order, contact factory.

MIC426/427/428 Device Replacement MIC1426/1427/1428 Device Replacement


Discontinued Number Replacement Discontinued Number Replacement
MIC426CM MIC4426BM MIC1426CM MIC4426BM
MIC426BM MIC4426BM MIC1426BM MIC4426BM
MIC426CN MIC4426BN MIC1426CN MIC4426BN
MIC426BN MIC4426BN MIC1426BN MIC4426BN
MIC427CM MIC4427BM MIC1427CM MIC4427BM
MIC427BM MIC4427BM MIC1427BM MIC4427BM
MIC427CN MIC4427BN MIC1427CN MIC4427BN
MIC427BN MIC4427BN MIC1427BN MIC4427BN
MIC428CM MIC4428BM MIC1428CM MIC4428BM
MIC428BM MIC4428BM MIC1428BM MIC4428BM
MIC428CN MIC4428BN MIC1428CN MIC4428BN
MIC428BN MIC4428BN MIC1428BN MIC4428BN

M9999-022307 2 February 2007


MIC4426/4427/4428 Micrel, Inc.

Pin Configuration
MIC4426 MIC4426 MIC4427 MIC4427 MIC4428 MIC4428
NC 1 8 NC NC 1 8 NC NC 1 8 NC
2 A 7 2 A 7 2 A 7
INA 2 7 OUTA INA 2 7 OUTA INA 2 7 OUTA

GND 3 6 VS GND 3 6 VS GND 3 6 VS


4 B 5 4 B 5 4 B 5
INB 4 5 OUTB INB 4 5 OUTB INB 4 5 OUTB
Dual Dual Inverting+
Inverting Noninverting Noninverting

Pin Description
Pin Number Pin Name Pin Function
1, 8 NC not internally connected
2 INA Control Input A: TTL/CMOS compatible logic input.
3 GND Ground
4 INB Control Input B: TTL/CMOS compatible logic input.
5 OUTB Output B: CMOS totem-pole output.
6 VS Supply Input: +4.5V to +18V
7 OUTA Output A: CMOS totem-pole output.

February 2007 3 M9999-022307


MIC4426/4427/4428 Micrel, Inc.

Absolute Maximum Ratings(1) Operating Ratings(2)


Supply Voltage (VS) ..................................................... +22V Supply Voltage (VS) ...................................... +4.5V to +18V
Input Voltage (VIN) .......................... VS + 0.3V to GND – 5V Temperature Range (TA)
Junction Temperature (TJ) ......................................... 150°C (A) ......................................................... –55°C to +125°C
Storage Temperature ................................ –65°C to +150°C (B) ........................................................... –40°C to +85°C
Lead Temperature (10 sec.) ...................................... 300°C Package Thermal Resistance
ESD Rating(3) PDIP θJA .......................................................................... 130°C/W
PDIP θJC ............................................................................ 42°C/W
SOIC θJA ........................................................... 120°C/W
SOIC θJC ............................................................ 75°C/W
MSOP θJA ......................................................... 250°C/W

Electrical Characteristics(4)
4.5V ≤ Vs ≤ 18V; TA = 25°C, bold values indicate full specified temperature range; unless noted.
Symbol Parameter Condition Min Typ Max Units
Input
VIH Logic 1 Input Voltage 2.4 1.4 V
2.4 1.5 V
VIL Logic 0 Input Voltage 1.1 0.8 V
1.0 0.8 V
IIN Input Current 0 ≤ VIN ≤ VS –1 1 µA
Output
VOH High Output Voltage VS–0.025 V
VOL Low Output Voltage 0.025 V
RO Output Resistance IOUT = 10mA, VS = 18V 6 10 Ω
8 12 Ω
IPK Peak Output Current 1.5 A
I Latch-Up Protection withstand reverse current >500 mA
Switching Time
tR Rise Time test Figure 1 18 30 ns
20 40 ns
tF Fall Time test Figure 1 15 20 ns
29 40 ns
tD1 Delay Tlme test Flgure 1 17 30 ns
19 40 ns
tD2 Delay Time test Figure 1 23 50 ns
27 60 ns
tPW Pulse Width test Figure 1 400 ns
Power Supply
IS Power Supply Current VINA = VINB = 3.0V 1.4 4.5 mA
1.5 8 mA
IS Power Supply Current VINA = VINB = 0.0V 0.18 0.4 mA
0.19 0.6 mA
Notes:
1. Exceeding the absolute maximum rating may damage the device.
2. The device is not guaranteed to function outside its operating rating.
3. Devices are ESD sensitive. Handling precautions recommended.
4. Specification for packaged product only.

M9999-022307 4 February 2007


MIC4426/4427/4428 Micrel, Inc.

Test Circuits

VS = 18V VS = 18V

6
0.1µF 4.7µF 6
0.1µF 4.7µF

2 7 2 7
INA A OUTA INA A OUTA
1000pF 1000pF
MIC4426 MIC4427
4 5 4 5
INB B OUTB INB B OUTB
1000pF 1000pF

Figure 1a. Inverting Configuration Figure 2a. Noninverting Configuration

5V 5V
2.5V 2.5V
90% 90%
INPUT INPUT
10% 10%
0V 0V
tP W tP W
tD1 tF tD2 tR tD1 tR tD2 tF
VS VS
90% 90%

O U TPU T O U TPU T
10% 10%
0V 0V

Figure 1b. Inverting Timing Figure 2b. Noninverting Timing

February 2007 5 M9999-022307


MIC4426/4427/4428 Micrel, Inc.

Electrical Characteristics
Rise and Fall Time vs. Delay Time vs. Rise and Fall Time vs.
Supply Voltage Supply Voltage Temperature
70 35 40
CL = 1000pF CL = 1000pF CL = 1000pF
60 TA = 25°C 30 TA = 25°C VS = 18V

50 25 30
t D2 tF
40 20
TIME (ns)

TIME (ns)
TIME (ns)
tR
30 15 t D1 20
tR
20 10
tF
10 5 10

0 0
0 5 10 15 20 0 5 10 15 20 -75 -50 -25 0 25 50 75 100 125 150
SUPPLY VOLTAGE (V) SUPPLY VOLTAGE (V) TEMPERATURE (°C)

Delay Time vs. Supply Current vs. Rise and Fall Time vs.
Temperature Capacitive Load Capacitive Load
35 80 1k
CL = 1000pF T A = 25°C 400kHz T A = 25°C
30 VS = 18V 70 VS = 18V VS = 18V
SUPPLY CURRENT (mA)

t D2
60 tR
25
100
50

TIME (ns)
20
TIME (ns)

t D1 40 tF
15
30
10
10 200
20
kHz
5 10 20kHz
0 0 1
-75 -50 -25 0 25 50 75 100 125 150 10 100 1000 10000 10 100 1000 10000
TEMPERATURE (°C) CAPACITIVE LOAD (pF) CAPACITIVE LOAD (pF)

Supply Current vs. Frequency High Output vs. Current Low Output vs. Current
30 1.20 1.20
TA = 25°C VS = 18V TA = 25°C VC = 5V TA = 25°C VS = 5V
CL = 1000pF
SUPPLY CURRENT (mA)

0.96 0.96
OUTPUT VOL AGE (V)
| VS – VOUT | (V)

20
10 V 0.72 10 V 0.72 10 V

0.48 0.48
10
15 V 15 V
5V
0.24 0.24

0 0 0
1 10 100 1000 0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
FREQUENCY (kHz) CURRENT SOURCED (mA) CURRENT SUNK (mA)

Quiescent Power Supply Current Quiescent Power Supply Current Package Power Dissipation
vs. Supply Voltage vs. Supply Voltage
2.5 400 1250
POWER DISSIP TION (mW)

300
SUPPLY CURRENT (mA)

2.0 1000
SUPPLY CURRENT (A)

MAXIMUM PACKAGE

200
SOIC
1.5 750
150
1.0 NO LOAD NO LOAD 500
BOTH INPUTS LOGIC "1" 100 BOTH INPUTS LOGIC "0" PDIP
TA = 25°C TA = 25°C
0.5 250
50

0 0 0
0 5 10 15 20 0 5 10 15 20 25 50 75 100 125 150
SUPPLY VOLTAGE (V) SUPPLY VOLTAGE (V) AMBIENT TEMPERATURE (°C)

M9999-022307 6 February 2007


MIC4426/4427/4428 Micrel, Inc.

Applications Information Power Dissipation


Supply Bypassing Power dissipation should be calculated to make sure that the
driver is not operated beyond its thermal ratings. Quiescent
Large currents are required to charge and discharge large
power dissipation is negligible. A practical value for total
capacitive loads quickly. For example, changing a 1000pF
power dissipation is the sum of the dissipation caused by the
load by 16V in 25ns requires 0.8A from the supply input.
load and the transition power dissipation (PL + PT).
To guarantee low supply impedance over a wide frequency
Load Dissipation
range, parallel capacitors are recommended for power supply
bypassing. Low-inductance ceramic MLC capacitors with short Power dissipation caused by continuous load current (when
lead lengths (< 0.5”) should be used. A 1.0µF film capacitor driving a resistive load) through the driver’s output resistance
in parallel with one or two 0.1µF ceramic MLC capacitors is:
normally provides adequate bypassing. PL = IL2 RO
Grounding For capacitive loads, the dissipation in the driver is:
When using the inverting drivers in the MIC4426 or MIC4428, PL = f CL VS2
individual ground returns for the input and output circuits or Transition Dissipation
a ground plane are recommended for optimum switching
In applications switching at a high frequency, transition power
speed. The voltage drop that occurs between the driver’s
dissipation can be significant. This occurs during switching
ground and the input signal ground, during normal high-cur-
transitions when the P-channel and N-channel output FETs
rent switching, will behave as negative feedback and degrade
are both conducting for the brief moment when one is turning
switching speed.
on and the other is turning off.
Control Input
PT = 2 f VS Q
Unused driver inputs must be connected to logic high (which
Charge (Q) is read from the following graph:
can be VS) or ground. For the lowest quiescent current
(< 500µA) , connect unused inputs to ground. A logic-high 1×10-8
signal will cause the driver to draw up to 9mA. 8×10-9

The drivers are designed with 100mV of control input hys- 6×10-9

CHARGE (Q)
teresis. This provides clean transitions and minimizes output
4×10-9
stage current spikes when changing states. The control input
voltage threshold is approximately 1.5V. The control input 3×10-9

recognizes 1.5V up to VS as a logic high and draws less than 2×10-9


1µA within this range.
The MIC4426/7/8 drives the TL494, SG1526/7, MIC38C42,
TSC170 and similar switch-mode power supply integrated 1×10-9
4 6 8 10 12 14 16 18
circuits. SUPPLY VOLTAGE (V)

Crossover Energy Loss per Transition

February 2007 7 M9999-022307


MIC4426/4427/4428 Micrel, Inc.

Package Information

MAX ) PIN 1

0.150 (3.81) INCHES (MM)

0.013 (0.33)
TYP 45°
0.010 (0.25)
0.0040 (0.102) 0.007 (0.18)

0°–8°
0.189 (4.8) 0.016 (0.40)
0.045 (1.14) PLANE
0.228 (5.79)

8-Pin SOIC (M)

0.112 (2.84) 0.187 (4.74) INCH (MM)

0.116 (2.95)

0.032 (0.81) 0.038 (0.97) 0.007 (0.18)


0.012 (0.30) R 0.005 (0.13)

0.012 (0.03) 5° 0.012 (0.03) R


0.004 (0.10) 0° MIN
0.0256 (0.65) TYP
0.035 (0.89)
0.021 (0.53)

8-Pin MM8™ MSOP (MM)

8-Pin Plastic DIP (N)

M9999-022307 8 February 2007


MIC4426/4427/4428 Micrel, Inc.

MICREL INC. 2180 FORTUNE DRIVE SAN JOSE, CA 95131 USA


TEL + 1 (408) 944-0800 FAX + 1 (408) 474-1000 WEB http://www.micrel.com
This information furnished by Micrel in this data sheet is believed to be accurate and reliable. However no responsibility is assumed by Micrel for its use.
Micrel reserves the right to change circuitry and specifications at any time without notification to the customer.
Micrel Products are not designed or authorized for use as components in life support appliances, devices or systems where malfunction of a product can
reasonably be expected to result in personal injury. Life support devices or systems are devices or systems that (a) are intended for surgical implant into
the body or (b) support or sustain life, and whose failure to perform can be reasonably expected to result in a significant injury to the user. A Purchaser’s
use or sale of Micrel Products for use in life support appliances, devices or systems is a Purchaser’s own risk and Purchaser agrees to fully indemnify
Micrel for any damages resulting from such use or sale.
© 2003 Micrel, Incorporated.

February 2007 9 M9999-022307


8051 board

+5v

+5V
U27
D0 GND
32 D2
21 39 3 2 12 A0 D0 13 D4
P2.0/A8 P0.0/AD0 D1 Q1 11 14
22
P2.1/A9 P0.1/AD1
38 4
D2 U10 Q2
5 A1 D1 D6
23 37 7 6 10 A2 D2 15 LCD
P2.2/A10 P0.2/AD2 D3 Q3 0
Single Step

24 36 8 9 9 A3 D3 17 D7
P2.3/A11 P0.3/AD3 D4 Q4

74HC373
25 35 13 12 8 A4 D4 18 D5
P2.4/A12 P0.4/AD4 D5 Q5 7 19
26
P2.5/A13 P0.5/AD5
34 14
D6 Q6
15 A5 D5 D3 INT0
27 33 17 16 6 A6 D6 20 D1
P2.6/A14 P0.6/AD6 D7 Q7 5 21
0
28
P2.7/A15 P0.7/AD7
32 18
D8 Q8
19 A7 D7 INT1
27 A8

39F512
J1 10 1 11 26 A9
P3.0/RXD P1.0/T2 LE 23
11
P3.1/TXD P1.1/T2EX
2 1
OE 10
A10 P1.0
1 12 3 25 A11 P1.1
P3.2/INT0 P1.2 4
2 13
P3.3/INT1 P1.3
4 A12 P1.2
87C52

3 14 5 0 28 A13 P1.3
4 15 P3.4/T0 P1.4 6 0 +5v 29 A14 +5v P1.4
P3.5/T1 P1.5 3
16
P3.6/WR P1.6
7 A15 3.3K P1.5
17
P3.7/RD P1.7
8 R8 0 P1.6
Flash Erase

22pF 1 P1.7
29 19 1M 2
PSEN X1 24 30
X2
18 OE 2K
30 22.11MHZ 31 WR
ALE/PROG 22pF 22
EA/VPP
31 1K CE
9
RST 0.1MF
40 16
VCC
+5v 0 0 0
2 0
U39A 1
1 3 74HC02 34
D0 PA0
4 PA0
U26A 3 33
D1
3 PA1
1 2 74HC00 32 U4 PA1 2 PA2
D2 PA2
U25A 3 31
D3 PA3
1 PA3
2 74HC00 28 30
D4 PA4
40 PA4
10 A0 D0 11 29 39 PA5
9 12 D5 PA5
A1 D1 28
D6 PA6
38 PA6
1 8 A2 D2 13 27 37 PA7
D7 PA7

82C55
2 7 A3 D3 15
7420 6 6 A4 D4 16 9 18 PB0
2

5 17 A0 PB0
5x330 4 U36A A5 D5 8
A1 PB1
19 PB1
5 4 A6 D6 18 20 PB2
3 19 PB2
U28A U30A 5 A7 D7 35
RESET PB3
21 PB3

62256
74HC00 74HC00 4 25 A8 5 22 PB4
24 RD PB4
U42A
6 U35A A9 10K 36
WR PB5
23 PB5
7420 2 21 A10 6 24 PB6
D4 23 CS PB6
1 1 A11 PB7
25 PB7
3 2 A12
3

2 26 A13 14 PC0
1 PC0
A14 PC1
15 PC1
7426 TX LED
D8 0 PC2
16 PC2
1 D14
PC3
17 PC3
U34A 3 PWR LED 22 RD 13 PC4
27 PC4
2 74AC08 WR PC5
12 PC5
20 CS 14 11 PC6
PC6
RX LED
0 PC7
10 PC7
1
U31A 3 +5v
2 74HC00 +5v
0

10MF +5V
1 SW1 GND
7426 3
2 U37A

U7 0
1
A Y0
15 34
D0 PA0
4 PD0
2
B Y1
14 33
D1 PA1
3 PD1
3
C Y2
13 32
D2 PA2
2 PD2
74HC138

Y3
12 31
D3 PA3
1 PD3
6
G1 Y4
11 30
D4 PA4
40 PD4
3 4
G2A Y5
10 29
D5 PA5
39 PD5
1 U40A 5 9 +5v +5v 28 38 PD6
G2B Y6 D6 PA6
74HC02 2
Y7
7 BUS 27
D7 PA7
37 PD7
82C55

3
1 U41A 0 A1 9 18
A0 PB0
MAIN 74HC02 2 A2 A5 8
A1 PB1
19
P2
3 A0 A3 PB2
20
1 U38A A6 A7 35
RESET PB3
21
1 74HC02 2 A4 A8 5
RD PB4
22
6 +5v
820
A12 A10 36
WR PB5
23
2 +5v LED E0 A13 A9 6
CS PB6
24
7 25
3 PB7
8 LED 820 E1 A1 14 PF0
PC0
4 A11 A14 A0 PC1
15 PF1
9 13 16 12 A15 16 PF2
R1IN R1OUT 820 PC2
5 8
R2IN R2OUT
9 LED E2 PC3
17 PF3
PC4
13 PF4
11
T1IN T1OUT
14
820 PC5
12 PF5
0
10
T2IN T2OUT
7 LED E3 PC6
11 PF6
0.1
PC7
10 PF7
1 U43
C1+ 820
AUX +5v 3
C1- MAX232
LED E4
4
P3 C2 5 C2+
C2- 820
1 2
V+
LED E5
6 6 15
2 V- 0
7 LED 820 E6
3
8 C4
4 C1 0 LED 820 E7
9
5 0 0

0
+5v
+8to 15V DC 1N5819
7805 +5v +5v +5v +5v +5v +5v +5v +5v
IN OUT
GND
0.1 0.1 0.1 0.1 C17 C8 C10 C9 C11 C13 C16 C14 C12

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

You might also like