Smart Car Parking System
Smart Car Parking System
Graduation Project
Project Team
Riham Walled Zalloum Maysa Al_Mohtaseb
Jihan Khamayseh
Project Supervisor
Eng. Mazen Zalloum
Hebron-Palestine
June-2007
ﺟﺎﻣﻌﺔ ﺑﻮﻟﯿﺘﻜﻨﻚ ﻓﻠﺴﻄﯿﻦ
اﻟﺨﻠﯿﻞ – ﻓﻠﺴﻄﯿﻦ
ﻛﻠﯿﺔ اﻟﮭﻨﺪﺳﺔ واﻟﺘﻜﻨﻮﻟﻮﺟﯿﺎ
داﺋﺮة اﻟﮭﻨﺪﺳﺔ اﻟﻜﮭﺮﺑﺎﺋﯿﺔ واﻟﺤﺎﺳﻮب
ﺑﻨﺎء ﻋﻠﻰ ﻧﻈﺎم ﻛﻠﯿﺔ اﻟﮭﻨﺪﺳﺔ واﻟﺘﻜﻨﻮﻟﻮﺟﯿﺎ وإﺷﺮاف وﻣﺘﺎﺑﻌ ﺔ اﻟﻤﺸ ﺮف اﻟﻤﺒﺎﺷ ﺮ ﻋﻠ ﻰ اﻟﻤﺸ ﺮوع و ﻣﻮاﻓﻘ ﺔ أﻋﻀ ﺎء
اﻟﻠﺠﻨﺔ اﻟﻤﻤﺘﺤﻨﺔ ﺗﻢ ﺗﻘﺪﯾﻢ ھ ﺬا اﻟﻤﺸ ﺮوع إﻟ ﻰ داﺋ ﺮة اﻟﮭﻨﺪﺳ ﺔ اﻟﻜﮭﺮﺑﺎﺋﯿ ﺔ واﻟﺤﺎﺳ ﻮب وذﻟ ﻚ ﻟﻠﻮﻓ ﺎء ﺑﻤﺘﻄﻠﺒ ﺎت درﺟ ﺔ
اﻟﺒﻜﺎﻟﻮرﯾﻮس ﻓﻲ اﻟﮭﻨﺪﺳﺔ ﺗﺨﺼﺺ أﻧﻈﻤﺔ ﺣﺎﺳﻮب.
ﺗﻮﻗﯿﻊ اﻟﻤﺸﺮف
.................................................
ii
Dedication
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
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
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
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
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.
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
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.
٤
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.
T5: Study and find the type of sensor we want and other hardware we require it.
٥
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
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.
٦
1.5 Project Cost
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:-
٧
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$).
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.
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.
This chapter presented out lines formal procedure for design, discuss design
options and justify those chosen for the project.
This chapter handles the software related to our system, depicts flowcharts
about system operation.
This chapter includes the implementation phase with the testing of these
phase. General hardware and software component tested and shown in this chapter.
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
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.
١١
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.
١٢
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...
١٣
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.
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
١٤
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?
١٦
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.
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.
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.
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.
٢٠
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.
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.
٢١
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.
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 .
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.
٢٣
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.
٢٤
3
Design Concepts
٢٥
Chapter Three
Design Concepts
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.
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.
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
٢٨
Figure (3.3): Entrance 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.
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
٣٢
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 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.
٣٥
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.
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.
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.
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.
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)
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.
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
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
٤٢
Properties of the LCD used in virtual project:
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.
Now we will illustrate the ports that connect the project subsystem.
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).
٤٤
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.
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).
٤٥
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).
٤٦
4.2.4.2 Controlling the Motor
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
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.
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:
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.
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
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
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
٥٢
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
٥٣
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.
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.
٥٤
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.
4.2.6.1 Hardware
٥٥
Figure 4.13: Parallel Port Register
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)
٥٦
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 - - -
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
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.
٥٨
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
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
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
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
٦٠
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
٦١
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.
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.
٦٤
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).
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.
٦٦
Figure (5.4): Dial up Screen
After performing all the previous procedures, the connection will be ready
between the PC and the 8051 microcontroller.
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 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.
٦٩
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.
Function description included the code needed to perform the following tasks.
٧٠
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
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.
٧١
5.3.2.1 Code for Enable Timer
while (1) {
hours = minutes = seconds = 0;
while (seconds!y){
}
if (time_changed_flag) {
time_changed_flag = 0;
print_fast(",");
}
}
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;
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.
٧٥
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
٧٦
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).
٧٧
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
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:
٧٨
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.
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
Display on floor1
LCD the available
places in this floor
٨٠
5.6.4 Main LCD Flow Chart
Initialize LCD
Clear LCD
Yes If No
print_to_lcd=1
Print to serial
Print to LCD
screen
٨١
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:
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
Delay
Motor1_left
(close entrance gate)
Delay
Motor2_left
(close exit gate)
٨٣
5.7 Algorithms and Pseudocode
٨٤
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)
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
٨٥
Out(&H378, 128)
Out(&H37A, 1)
Out(&H378, 2)
Out(&H37AS, 2)
'delay(50)
'Motor2_left()
End Sub
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
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
Dim b As Short
Dim c2 As Integer = 0
Out(&H37AS, 4)
b = Inp(&H379S)
Main2_lcd(c2)
Else
c2 += 1
Main2_lcd(c2)
Floor2_lcd(1)
End If
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
Else
c2 += 1
Main2_lcd(c2)
Floor2_lcd(2)
End If
End Sub
Dim j As Integer
٨٩
'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
٩٠
delay(6000)
Main1_write_control(6)
delay(6000)
Main1_write_control(128)
End Sub
٩١
'End If
'
' End Sub
'Sub Main1_lcd_home()
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
٩٢
Out(&H37AS, 1)
delay(600)
Out(&H37AS, 2)
Out(&H378S, 0)
Out(&H37AS, 1)
End Sub
٩٣
Out(&H378S, 5)
Out(&H37AS, 1)
delay(600)
Out(&H37AS, 2)
Out(&H378S, 4)
Out(&H37AS, 1)
End Sub
Floor1_lcd_init()
٩٤
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
٩٦
End If
End Sub
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
٩٧
Out(&H378S, 16)
Out(&H37AS, 15)
delay(600)
Out(&H37AS, 13)
Out(&H378S, 0)
Out(&H37AS, 15)
End Sub
Else
Floor1_lcd_cursor(2, out2 + 2)
End If
٩٨
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
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:
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
١٠٢
6.3 Testing
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
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.2 Option Two Using VB.net for Motor Testing
١٠٧
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.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.
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:
١٠٩
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.
١١٠
6.4 Implementation and Testing for Integrated System
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
• 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:-
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:
• 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.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
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
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
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
#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);
}
٩
p82c55_port_f=0x00;
delay_ms(5);
}
١٠
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
١١
' For i = 0 To c.length
'' lcd_write(Asc(c))
'Next
'End Sub
١٢
Sub delay(ByVal time As Integer)
Dim i As Integer = 0
For i = 0 To time
Next
End Sub
End Class
١٣
TextBox1.Text = Inp(&H379S)
End Sub
End Class
١٤
8051 Development Board Data Sheet
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.
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
٣
Schematic
٤
Ports
٥
1. LCD Port
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.
٨
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
٩
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.
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.
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
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)
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
MIC4426/4427/4428
Dual 1.5A-Peak Low-Side MOSFET Driver
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
Ordering Information
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
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.
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.
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
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
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)
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
Package Information
MAX ) PIN 1
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)
0.116 (2.95)
+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