Академический Документы
Профессиональный Документы
Культура Документы
This report is submitted in partial fulfillment of the requirement for the award of BSc. Degree in Electronics and Computer Engineering of Jomo Kenyatta University of Agriculture and Technology.
MARCH 2009
2009
I, George Ngugi Kibia, registration number E26-0668/03, do hereby declare that this is my original work and that it has neither been submitted nor transferred by any other student for a degree or any other course in this institution or any other institution of learning.
Signature.Date
CERTIFICATION This project has been proposed, developed supervised and submitted for examination with my approval as the University supervisor.
Signature. Lecturer,
Date..
George N Kibia
E26-0668/03
Page 2
2009
I thank God, the Almighty for the gift of life and for enabling me to pursue my undergraduate studies with good health both mentally and physically. I also kindly thank and acknowledge the efforts of the people who have helped me from the onset to the completion of my course and project.
First of all I am grateful to my supervisor, Mr. Baariu A.M for his insight, professional assistance, kind guidance and constructive criticism regarding my work. This was a driving force and immensely contributed to completion of my project.
I also thank my parents and siblings whose constant support and encouragement steered me through the development of my project. It is through their help too that Im able to finish the course.
Lastly, I express my heart felt gratitude to the lecturers in the Electrical and Electronics Department who parted helpful knowledge to me and thus enabled me to successfully develop my project. To my friends THANK YOU GUYS. Thank you all and may God bless us all and grant us long life.
George N Kibia
E26-0668/03
Page 3
2009
Dedication
To my loving parents and siblings: For your unconditional love, support and encouragement throughout my education.
George N Kibia
E26-0668/03
Page 4
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) TABLE OF CONTENTS Declaration...............................................................................................................2 Certification..............................................................................................................2 Acknowledgment......................................................................................................3 Dedication................................................................................................................4 Abstract....................................................................................................................7
1. CHAPTER INTRODUCTION.................................................................................................8 1.1 Background information..................................................................................................8 1.2 Problem statement...8 1.3 Goals and objectives8 1.4 Justification......................................................................................................................9 1.4.1 Advantages.............................................................................................................9 2. CHAPTER: LITEATURE REVIEW......................................................................................10 2.1 Types of parking.............................................................................................................10 2.2 General information on Road Side parking lots..............................................................10 2.3 Shortcomings of roadside parking..................................................................................13 2.4 Improvements......................................................................................................14
2009
3. CHAPTER 3: METHODOLOGY............................................................................................15 3.1 Microcontroller..................................................................................................................15 3.1.1 Introduction..............................................................................................................15 3.1.2 Description...............................................................................................................16 3.1.3 Features...................................................................................................................16 3.1.4 Pin Description.........................................................................................................18 3.1.5 Oscillator Characteristics.........................................................................................20 3.2 The 8255 Programmable Peripheral Interface.................................................................20 3.2.1 Introduction...............................................................................................................20 3.2.2 Uses..........................................................................................................................20 3.2.3 Pin Description..........................................................................................................22 3.2.4 Operational Description............................................................................................24 3.3 Light Dependent Resistor (LDR)........................................................................................25 3.3.1 Introduction...............................................................................................................25 3.3.2 Uses of light dependent Resistors............................................................................26 3.3.3 Light dependent resistors circuits.............................................................................26 3.4 NE555 Timer......................................................................................................................27 3.4.1 Introduction...............................................................................................................27 3.4.2 Monostable mode.....................................................................................................28 3.4.2.1 Monostable circuit..........................................................................................28 3.4.2.2 Doing the Calculations...................................................................................29 3.4.2.3 Varying the Time Period................................................................................29 3.5 LED Seven Segment Display.............................................................................................31 3.5.1 Introduction...............................................................................................................31 3.5.2 Types of Seven Segment LEDS...............................................................................32 3.5.3 Using Lookup Table ...............................................................................................33 3.6 Liquid Crystal Display (LCD)..............................................................................................36 3.6.1 LCD Pin Descriptions.................................................................................................36 3.7 Motors................................................................................................................................39 3.7.1 Introduction................................................................................................................39 3.7.2 Stepper Motor............................................................................................................40 3.7.2.1 Fundamentals of Operation...........................................................................40 3.7.2.2 Stepper Motor Characteristics........................................................................41 3.7.3 Unipolar Stepper Motor.............................................................................................42
George N Kibia
E26-0668/03
Page 5
2009
4. CHAPTER FOUR: CIRCUIT DESIGN.................................................................................46 4.1 Hardware Description..................................................................................................46 4.1.1 Display Section....................................................................................................47 4.1.2 Lift Section...........................................................................................................48 4.1.3 Motor Section.......................................................................................................49 4.1.4 Floor Sensor Section...........................................................................................50 4.1.5 LCD Section........................................................................................................51 4.2 Software Development................................................................................................53 4.3 Program Flow chart.....................................................................................................54 5. CHAPTER FIVE CONCLUSION AND RECOMMENDATIONS.............................55 5.1 Experimental Results......................................................................................55 5.2 System Application..........................................................................................55 5.3 Problems Encountered....................................................................................56 5.4 Recommendations ..........................................................................................56 6. CHAPTER SIX BUDGET ESTIMATE.....................................................................58 7. CHAPTER SEVEN TIME SCHEDULE...................................................................59 REFERENCES......................................................................................................60
APPENDIX A Terms and Abbreviations APPENDIX B List of figures and tables APPENDIX C Project Program code APPENDIX D Pin configuration of parts APPENDIX E Project Circuit Diagram
George N Kibia
E26-0668/03
Page 6
2009
ABSTRACT
The problem of the increasing number of vehicles is receiving considerable attention with the construction of new parking lots in major cities around the world including Nairobi: Kenya. The theoretical and practical modeling of the Microcontroller Based Vehicle Parking System will improve the management of multistoried parking lots. In the Microcontroller Based Vehicle Parking System (MICROBVPS) I have developed an embedded system that manages a multistory parking using digital integrated circuits. The system incorporates the following major sections: Microcontroller, Display section, Sensor section, Motor and lift section which are interconnected in a logical way to perform the control with greater flexibility and reliability. A software program is written in assembly language and a hardware interface developed to implement the controller. It also involves the use of modern sensor devices to bring about the detection intelligence.
The system is controlled by sensors which are activated by LDRs placed in the lift and on each floor. The sensors send a signal to the microcontroller which uses an internally stored program is to detect what floor the car is at and decrement/ increments a counter at the ground floor on exit/entrance. The system uses a stepper motor to move vehicles among the different floors of a multistory building.
The system when implemented in a real multistoried parking, it will help in managing the parking lot in an efficiency and less costly way at the same time saving time and fuel cost spent by motorists when looking for a place to park.
George N Kibia
E26-0668/03
Page 7
2009
CHAPTER ONE
1. INTRODUCTION
1.1 BACKGROUND INFORMATION
Owning and driving a car should not only be a luxury but also an enjoyable thing. This is not encouraged by the constant hustle and headaches one goes through when trying to get a parking space in a congested town or city. Parking lots should be well managed and provide relevant information to motorist in the shortest time possible. This information could be the number of available parking spaces and the location.
1.2 PROBLEM STATEMENT Due to the limited number of parking spaces in Nairobi Central Business District (NCBD) and major cities around the world, it has become necessary to have car parks in office blocks and at times multistory buildings used exclusively for car parks. Its for this reason that a system that can manage the car park efficiently using lifts instead of the traditional concrete ramp needs to be developed and implemented.
George N Kibia
E26-0668/03
Page 8
2009
1.4 JUSTIFICATION
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM will help to minimize the car parking time in places where many vehicles need to be parked; this system proves to be useful in reducing wastage of space and provide a well coordinated parking system. This MICROCONTROLLER BASED VEHICLE PARKING SYSTEM enables the parking of vehicles, floor after floor and thus reducing the space used. Here any number of cars can be parked according to specific requirement and a system provided to show number of cars parked and those remaining. For example you can have different floors with different requirements for access e.g. carwash parking, members parking, VIP parking where you are required to enter a password for entry etc. This makes the system modernized and even saves space.
2. Speed
Parking time is reduced unlike the case where we have a single one way ramp and the driver drives in different floors looking for an empty parking space. This wastes a lot of time which can be saved by the driver knowing in advance which floor has an available parking. 3. Fewer Emissions
The Park System takes ecological and social aspects into consideration as well, and creates additional parking space for the future. Fewer emissions (up to 35% less CO2 and 44% less Benzene) and the total elimination of traffic caused by people looking for a space in a roadside car park have a positive impact on the environment. The smaller footprint of a Park System compared to a roadside car park will save precious real estate which can be used for other purposes.
George N Kibia
E26-0668/03
Page 9
2009
CHAPTER TWO
LITERATURE REVIEW
2.1TYPES OF PARKING
Parking lot (called a car park) is a cleared area that is more or less level and is intended for parking vehicles. Usually, the term refers to a dedicated area that has been provided with a durable or semi-durable surface. See Fig 1.1
In most countries where cars are the dominant mode of transportation, parking lots are a feature of every city and suburban area. Shopping malls, sports stadiums, mega churches and similar venues often feature lots of immense area.
George N Kibia
E26-0668/03
Page 10
2009
At places where most visitors and employees use their car to access place, the parking lot usually takes up more land area than the buildings. This is at least true for shopping centres and office buildings, unless a multi-storey park is used. In most cases, especially in areas where parking is scarce, one must pay to park in a parking lot. Entry and exit access is often controlled at these types of lots to ensure those parking pay the required fee. In many congested areas where some businesses lack their own parking areas, there are parking lots where practically any driver can pay a fee to park. These types of parking lots are often effectively businesses in themselves. Some parking lots have parking meters into which coins must be paid to park in the adjacent space. Some spaces in a parking lot may be marked as "reserved" for certain people, including those who are handicapped. There are often one or more parking spaces for handicapped people, which may be slightly wider, close to the point of entry for the corresponding store or building. Vehicles with handicapped tags may park there, but the non-handicapped are not allowed to. Although many parking lots are rectangular-shaped, there are parking lots of all sorts of shapes. A parking lot can be in front or back, on the side of the building it services, or any combination of these, including all around the building, often depending on local building codes. In a very large parking field, it is easy to get lost or have trouble finding one's vehicle. Such large parking lots often have various sections marked, for example by numbers or letters, to help identify the location. The area in parking lots is organized into parking spaces, which are generally marked with paint lines for each vehicle and often contain a turtarrier, and driving lanes in between so that vehicles can drive into and out of the spaces. The arrangement of the parking spaces relative to the driving lanes can feature perpendicular parking spaces, angle parking (most common in North America, especially in large lots), or parallel parking (least common in parking lots, and usually only for a few spaces), or possibly some combination of these. Large parking lots have multiple lanes with rows of parking spaces between each one. Except for rather small lots, the location of the parking spaces for each vehicle are usually indicated with pavement markings or lines, similar to center lines on streets. A very common arrangement in large parking lots is angle parking for two rows of vehicles between driving lanes, with the parked vehicles facing front to front between the two rows. At the sides of the parking lot, other driving lanes connect these lanes perpendicularly so that a vehicle can drive into and out of the parking lot at designated locations.
George N Kibia
E26-0668/03
Page 11
2009
Fig 1.3: Parking lot layout with angle parking as seen from above. White arrows show direction of allowed travel in each lane (for right-hand-drive countries; vice versa in left-hand-drive countries). Several parking spaces closest to the building entrance are reserved for the handicapped. Cars of various colors are shown parked in some of the spaces. The obtusely pointed end indicates the front end of each car. There may be speed limits, stop signs and crosswalks for pedestrians in large parking lots. Tall overhead lights may illuminate some parking lots at night. Most spaces in normal parking lots available to the public are sized for vehicles about the size of a car. The spaces are usually arranged assuming the vehicle can back out of the parking space. In many rest areas on highways, long parking spaces are also available for trucks or other vehicles with trailers, into which they can enter at one end and leave at the opposite end to avoid potentially cumbersome reverse driving. A common arrangement in paid parking lots is to have a vehicle entry point with a cross gate where an entering driver presses a button to take a stub with the entry time and to open the cross gate for access to the lot. When leaving, the driver would pay at an exit point according to how much time was spent in the lot as determined from the stub. In order to keep unauthorized people from parking in lots, towing crews sometimes patrol parking lots after business closing hours, especially at night, to tow away vehicles which should not be parked there.
George N Kibia
E26-0668/03
Page 12
2009
2. Water pollution
Parking lots also tend to be subject to contamination with concentrated spots of pollutants such as motor oil. While motor vehicles on roadways may drip oil, they do so over a large area. Oil drips on parking lots are concentrated enough that they can have a deleterious effect on the water quality of the runoff. Other pollutants, even brake-lining dust, rust particles, and other particulate materials that settle on the parking lot surface, can be a similar problem. Therefore, an important second function of the retention basin for parking lots is to act as a temporary storage impoundment to allow particulate materials to settle out and to slow or even prevent the release of other pollutants into waterways.
3. Alternative paving
An alternative solution today is to use permeable paving surfaces, such as brick, stone, special paving blocks, or tire-tread woven mats. The intent of these is to allow rain to soak into the ground through the spaces inherent in the parking lot surface. The ground then may become contaminated in the surface of the parking lot, but this tends to stay in a small area of ground, which effectively filters water before it seeps away. This can however create problems if contaminants seep into groundwater, especially where there is groundwater abstraction 'downstream' for potable water supply.
4. Landscaping
Many areas today also require minimum landscaping in parking lots. This usually principally means the planting of trees to provide shade. Customers have long preferred shaded parking spaces in the summer, but parking lot providers have long been antagonistic to planting trees because of the extra cost of cleaning the parking lot.
George N Kibia
E26-0668/03
Page 13
2009
However, parking lots represent significant heat islands and, indeed, heat sinks in urban areas. The heat from paved areas in urban zones has been shown to even have the power to change the weather locally. By providing trees or other means of shading parking lots, the heat and glare resulting from them can be significantly reduced.
3. REDUCED POLLUTION
These systems reduce fuel wasted while searching for empty spaces and helps in the reduction of carbon emissions. The city council can build a special drainage for the parking lot to remove spilt oil in the parking
4. REDUCED CONGESTION
Reduction in congestion in the city due to fewer cars driving around searching for spaces
George N Kibia
E26-0668/03
Page 14
2009
CHAPTER THREE
3.0 METHODOLOGY
3.1 MICROCONTROLLER: 3.1.1 INTRODUCTION
In this project AT89C51-24 microcontroller was used which is an 8051 derivative. The first task faced when learning to use a new microcontroller was to become familiar with the capability of the machine. The features of the microcontroller was best learned by studying the internal hardware design, also called the architecture of the device, to determine the type, number, and size of the registers and other circuitry. The hardware is manipulated by an accompanying set of program instructions, or software. Once familiar with hardware and software, the microcontroller was applied to the problem at hand. I.e. to develop the microcontroller based vehicle parking system The 8051 microcontroller generic part number actually includes a whole family of microcontrollers that have numbers ranging from 8031 to 8751.The block diagram of the 8051 shows all of the features unique to microcontrollers: Internal ROM and RAM I/O ports with programmable pins Timers and counters Serial Data communication
The block diagram below shows the usual CPU components program counter, ALU, working registers, and the clock circuits. The 8051 architecture consists of these specific features: 8 bit CPU with registers A and B 16 bit PC & data pointer (DPTR) 8 bit program status word (PSW 8 bit stack pointer (SP) Internal ROM or EPROM (8751)of 0(8031)to 4k(8051) Internal RAM of 128 bytes. 4 register banks , each containing 8 registers 80 bits of general purpose data memory 32 input/output pins arranged as four 8 bit ports:P0-P3 two 16 bit timer/counters:T0-T1 Two external and three internal interrupt sources
George N Kibia
E26-0668/03
Page 15
2009
3.1.2 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
3.1.3 FEATURES
Compatible with MCS51 product 4K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 128 x 8-bit Internal RAM 32 Programmable I/O Lines Two 16-bit Timer/Counters Six Interrupt Sources Programmable Serial Channel/full duplex Low-power Idle and Power-down Modes
George N Kibia
E26-0668/03
Page 16
2009
Fig 3.1: Block diagram showing the usual CPU components program counter, ALU, working registers, and the clock circuits.
George N Kibia
E26-0668/03
Page 17
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) A pin out of the AT89C51-24 packaged in a 40 pin DIPS * Appendix 3.1
2009
GND
Ground
PORT 0
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. Port 0 may also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification.
PORT 1
Port 1 is an 8-bit bi-directional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification.
PORT 2
Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification
PORT 3
Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current because of the pullups. Port 3 also serves the functions of various special features of the AT89C51 as listed below:
George N Kibia
E26-0668/03
Page 18
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) PORT 3 PIN ALTERNATE FUNCTIONS P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) P3.6 WR (external data memory write strobe) P3.7 RD (external data memory read strobe) Port 3 also receives some control signals for Flash programming and verification.
2009
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
ALE/PROG
Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 of the oscillator frequency, and may be used for external timing or clocking purposes. Note however, that one ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.
PSEN
Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VP P) during Flash programming, for parts that require 12-volt VP_P.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) Output from the inverting oscillator amplifier
2009
3.2.2 USES
This chip is used to give the CPU access to programmable parallel I/O. The 8255 is used in home computers such as SV-328 and all MSX . The 8255 chip is used together with a micro controller to expand its I/O capabilities. The 82C55A is a very powerful tool for interfacing peripheral equipment to the microcomputer system. It represents the optimum use of available pins and flexible enough to inter face almost any I/O device without the need for additional external logic. Each peripheral device in a microcomputer system usually has a service routine associated with it. The routine manages the software interface between the device and the CPU. The functional definition of the 82C55A is programmed by the I/O service routine and becomes an extension of the system software. By examining the I/O devices interface characteristics for both data transfer and timing, and matching this information to the examples and tables in the detailed operational description, a control word can easily be developed to initialize the 82C55A to exactly fit the application.
George N Kibia
E26-0668/03
Page 20
2009
+5V
GROUP A CONTROL GROUP A PORT A (8) PA7-0
PC7-4
RD WR
A1
A0 RESET
GROUP B CONTROL
George N Kibia
E26-0668/03
Page 21
2009
Read (RD).
A low on this input pin enables 8255A to send data or status information to the CPU on the data bus. In essence, it allows the CPU to read from the 8255A.
Write (WR).
A low on this input pin enables the CPU to wr ite data or control words into the 82C55A.
A1 0 0
A0 0 1
George N Kibia
E26-0668/03
2009
1 1 A1 0 0 1 1 A1 x x
0 1 A0 0 1 0 1 A0 X X
0 0
1 1
0 0
RD WR CS OUTPUT OPERATION 1 1 1 1 0 0 0 O 0 0 0 0 Port A-Data BUS Port A-Data BUS Port A-Data BUS Control Word-Data bus
(RESET) Reset.
A high on this input initializes the control register to 9Bh and all ports (A, B, C) are set to the input mode. Bus hold devices internal to the 82C55A will hold the I/O port inputs to a logic 1 state with a maximum hold current of 400A.
George N Kibia
E26-0668/03
Page 23
2009
Port A, B, and C
The 82C55A contains three 8-bit ports (A, B, and C). All can be configured to a wide variety of functional characteristics by the system software but each has its own special features or personality to further enhance the power and flexibility of the 82C55A.
Port B One 8-bit data input/output latch/buffer and one 8-bit data input buffer. Port C One 8-bit data output latch/buffer and one 8-bit data input buffer (no latch for input). This port
can be divided into two 4-bit ports under the mode control. Each 4-bit port contains a 4-bit latch and it can be used for the control signal output and status signal inputs in conjunction with ports A and B.
George N Kibia
E26-0668/03
Page 24
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) Any Port can be input or output Outputs are latched Input are not latched 16 different Input/ Output configurations possible
2009
The functional configuration provides a means for communicating with a peripheral device or structure on a single 8-bit bus for both transmitting and receiving data (bi-directional bus I/O). Hand shaking signals are provided to maintain proper bus discipline similar to Mode 1. Interrupt generation and enable/disable functions are also available.
George N Kibia
E26-0668/03
Page 25
2009
jump into the conduction band. The resulting free electron (and its hole partner) conduct electricity, thereby lowering resistance. A photoelectric device can be either intrinsic or extrinsic. In intrinsic devices, the only available electrons are in the valence band, and hence the photon must have enough energy to excite the electron across the entire band gap. Extrinsic devices have impurities added, which have a ground state energy closer to the conduction band since the electrons don't have as far to jump, lower energy photons (i.e. longer wavelengths and lower frequencies) are sufficient to trigger the device.
George N Kibia
E26-0668/03
Page 26
2009
In the circuit diagram above, the LED lights up whenever the LDR is in darkness. The 10K variable resistor is used to fine-tune the level of darkness required before the LED lights up. The 10K standard resistor can be changed as required to achieve the desired effect, although any replacement must be at least 1K to protect the transistor from being damaged by excessive current. 2. Light activated
Fig 3.4: Light activated LDR By swapping the LDR over with the 10K and 10K variable resistors (as shown above), the circuit will be activated instead by light. Whenever sufficient light falls on the LDR (manually fine-tuned using the 10K variable resistor), the LED will light up.
George N Kibia
E26-0668/03
Page 27
2009
Astable Free Running mode: the 555 can operate as an oscillator. Uses include LED and lamp flashers, pulse generation, logic clocks, tone generation, security alarms, pulse position modulation, etc Bistable mode or Schmitt trigger: the 555 can operate as a flipflop, if the DIS pin is not connected and no capacitor is used. Uses include bounce free latched switches, etc
George N Kibia
E26-0668/03
Page 28
2009
FIG 3.6 The 555 monostable circuit 3.4.2.2 Doing the Calculations
Here is a step-by-step guide to calculating the value of resistor R - an example is given in curly braces {}. 1. Firstly, decide the time period T that you require. This can be very small (milliseconds) or large (minutes), but it must be expressed in seconds. {I choose T = 10 seconds} 2. Next, guess a value for the capacitor C, expressed in Farads. For starters, try 100F. {I choose C = 100F} 3. Put the values of T and C into the equation below and calculator resistor R...
If the resistor value you calculated is smaller than 1k or larger than 1M, you should re-do the calculation with a different value for capacitor C until you get a resistor value within the acceptable range.
George N Kibia
E26-0668/03
Page 29
2009
If your chosen variable resistor has three connections, it is a potentiometer, and you should connect to the centre connection and either of the end connections.
FIG 3.7 Varying the time period with a variable resistor The Trigger Input
As you can see from figure 3.5, the 555's Trigger input must be taken low to trigger the monostable. This is achieved in figure 3.6 by placing a button in series with a resistor across the power supply. Normally, the 10k resistor keeps the Trigger input high, at the voltage Vs, and the monostable is in its steady state. When the button is pushed, the Trigger input is directly connected to 0V and the time period T starts.
George N Kibia
E26-0668/03
Page 30
2009
Nr. Name
Purpose
GND
Ground, low level (0V) A short pulse high low on the trigger starts the timer
TR
CV
Control voltage allows access to the internal voltage divider (2/3 V CC) The threshold at which the interval ends (it ends if U.thr 2/3 V CC)
THR
DIS
Connected to a capacitor whose discharge time will influence the timing interval
V+, VCC The positive supply voltage which must be between 3 and 15 V
George N Kibia
E26-0668/03
Page 31
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) Here is the block diagram of the Seven Segment LED arrangement.
2009
FIG 3.8 Pin configuration of a seven segment display: 3.5.2 TYPES OF SEVEN SEGMENT LEDS LEDs are basically of two types
Common Cathode (CC) All the 8 anode legs uses only one cathode, which is common.
Common Anode (CA) The common leg for all the cathode is of Anode type.
For discussion purpose, we use CC LED, where by just reversing the logical voltages we can implement the same for CA LED also. In a CC LED, all the 8 legs ('a' through 'h') are of anode type and the common cathode will be connected to the GND of the supply. By energizing any of the legs with +5 Volts will lead to switch the correspondent segment ON. In the microprocessor binary system, 0Volts will be considered as Binary 0, and 5Volts will be considered as Binary1. Considering these two condition, we can make an arrangement as the microcontroller gives OUT the 0s and 1s through its ports, which is connected to
George N Kibia
E26-0668/03
Page 32
2009
the 8 legs of the LED. Of course, we can control the Port Output; implicitly we can Switch-ON required legs of the display. Here we discuss 2 methods of interfacing LED with the Microcontroller Intel 8051/8951. 1. Using lookup table. This uses 7 output pins of microcontroller 2. Using 7447 decoder. This method uses 4 output pins of microcontroller The difference between the two main methods is simple and clear. In both the cases, microcontroller communicates with external world through its ports. But, in the 1st case, we connect all the 8 pins of the port directly to the LED and control the voltage through the ports manually to display the desired number. But, in the second case, we send the BCD of the number that we wanted to display to a middleware IC 7447, the BCD to LED code converter, which by itself gives out the correspondent 7 segment codes to the LED.
George N Kibia
E26-0668/03
Page 33
2009
FIG 3.10: Circuit diagram for Common CATHODE 7-Segment Display interfaced to 8951
George N Kibia
E26-0668/03
Page 34
2009
The lookup table contains the input pattern for the LED legs, to display the corresponding digits. The table shows the seven segment requirement pattern to display the Hex number, with the seven segment conversion. For example, Let us consider the display of the number 0, where we need to switch ON all the LEDs which are there at the boundary. I.e. for a CC LED, we should supply 5 volts to these LEDs. The 6 LEDs ('a' through 'f') should get binary 1, the dot and the (middle) hyphen segment should get 0Volts or the binary Zero. Effectively the Seven segment pattern code will be (0011 1111) 3Fh. That is what we OUT through the port pins. For a Common Anode LED, the display pattern will be the complement of that of Common Cathode pattern.
Table 3.3: For common Cathode (the seven segment requirement pattern to display the Hex number, with the seven segment conversion) Seven Segment conversion Hex Number dot 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 0 g 0 0 1 1 1 1 1 0 1 1 f 1 0 0 0 1 1 1 0 1 1 e 1 0 1 0 0 0 1 0 1 0 d 1 0 1 1 0 1 1 0 1 0 c 1 1 0 1 1 1 1 1 1 1 b 1 1 1 1 1 0 0 1 1 1 a 1 0 1 1 0 1 1 1 1 1
George N Kibia
E26-0668/03
Page 35
2009
Table 3.4: For common Anode: (the seven segment requirement pattern to display the Hex number, with the seven segment conversion.) Seven Segment conversion Hex Number dot 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 g 1 1 0 0 0 0 0 1 0 0 f 0 1 1 1 0 0 0 1 0 0 e 0 1 0 1 1 1 0 1 0 1 d 0 1 0 0 1 0 0 1 0 1 c 0 0 1 0 0 0 0 0 0 0 b 0 0 0 0 0 1 1 0 0 0 a 0 1 0 0 1 0 0 0 0 0
3.6 LIQUID CRYSTAL DISPLAY (LCD) 3.6.1 LCD PIN DESCRIPTIONS: The LCD discussed in this section has 16 pins. The function of each pin is given in table.
George N Kibia
E26-0668/03
Page 36
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) Pin 1 2 3 4 5 6 7-14 Symbol GND Vcc VEE RS R/W E DB0-7 I/O I I I/O I/O Ground +5V power supply Contrast control command/data register selection write/read selection Enable The 8-bit data bus Description
2009
Vcc, Vss, and VEE While Vcc and Vss provide +5V and ground, respectively, VEE is used for controlling LCD contrast. RS - register select: There are two very important registers inside the LCD. The RS pin is used for their selection as follows. If RS = 0, the instruction command code register is selected, allowing the user to send a command such as clear display, cursor at home, etc. If RS = 1 the data register is selected, allowing the user to send data to be displayed on the LCD. R/W - read/write: R/W input allows the user to write information to the LCD or read information from it. R/W = 1 when reading; R/W =0 when writing. E - enable: The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450 ns wide.
George N Kibia
E26-0668/03
Page 37
2009
The 8 bit data pins, D0 D7, are used to send information to the LCD or read the contents of the LCDs internal registers. To display letters and numbers, we send ASCII codes for the letters A Z, a z, and numbers 0 9 to these pins while making RS = 1. There are also instructions command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the cursor. Table 3.6: List of LCD display instruction command codes. Code (hex) 1 2 4 5 6 7 8 A C E F 10 14 18 1C 80 C0 38 Command to LCD Instruction Register Clear display screen Return home Shift cursor to left Shift display right Shift cursor to right Shift display left Display off, Cursor off Display off, Cursor on Display on, cursor off Display on, cursor blinking Display on, cursor blinking Shift cursor position to left Shift cursor position to right Shift the entire display to the left Shift the entire display to the right Force cursor to beginning of 1st line Force cursor to beginning of 2nd line 2 lines and 5x7 matrix
We also use RS = 0 to check the busy flag bit to see if the LCD is ready to receive information. The busy flag is D7 and can be read when R/W =1 and RS = 0, as follows: if R/W =1, RS =0. When D7 = 1(busy flag = 1), the LCD busy taking care of internal operations and will not accept any new
George N Kibia
E26-0668/03
Page 38
2009
information. When D7 = 0, the LCD is ready to receive new information. Note: It is recommended to check the busy flag before writing any data to the LCD.
George N Kibia
E26-0668/03
Page 39
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) electric motor low maintenance High efficiency Brushed DC electric motor Low initial cost Simple speed control (Dynamo) Requires a controller High maintenance (brushes) Low lifespan CD/DVD players electric vehicles Treadmill exercisers automotive starters
2009
DC
Direct (PWM)
George N Kibia
E26-0668/03
Page 40
2009
Working
Fig 3.12 Description of rotation of a stepper motor The top electromagnet (1) is turned on, attracting the nearest teeth of a gear-shaped iron rotor. With the teeth aligned to electromagnet 1, they will be slightly offset from electromagnet 2. The top electromagnet (1) is turned on, attracting the nearest teeth of a gear-shaped iron rotor. With the teeth aligned to electromagnet 1, they will be slightly offset from electromagnet 2.
Fig 3.13.Step rotation a stepper motor The bottom electromagnet (3) is energized; another 3.6 rotation occurs. The left electromagnet (4) is enabled, rotating again by 3.6. When the top electromagnet (1) is again enabled, the teeth in the sprocket will have rotated by one tooth position; since there are 25 teeth, it will take 100 steps to make a full rotation in this example.
George N Kibia
E26-0668/03
Page 41
2009
Steppers exhibit more vibration than other motor types, as the discrete step tends to snap the rotor from one position to another. This vibration can become very bad at some speeds and can cause the motor to lose torque. The effect can be mitigated by accelerating quickly through the problem speed range, physically damping the system, or using a micro-stepping driver. Motors with a greater number of phases also exhibit smoother operation than those with fewer phases.
These three things just depends on applied pulses. Now there are three different modes to rotate a unipolar stepper motor 1. Single coil excitation 2. Double coil excitation 3. Half step excitation The table given below gives the complete idea of how pulses are given in each mode
George N Kibia
E26-0668/03
Page 42
2009
Table 3.8: Pulses for stepper motor module Note:- In half step excitation mode motor will rotate at half the specified given step resolution. Means if step resolution is 1.8 degree then in this mode it will be 0.9 degree. Step resolution means on receiving on 1 pulse motor will rotate that much degree. If step resolution is 1.8 degree then it will take 200 pulses for motor to compete 1 revolution (360 degree). The specification of the stepper motor that I have used are. Max rated voltage: 5V
Max rated current per coil: - 0.5 Amp Step resolution: Max RPM: 1.8 degree / pulse
RPM calculation:One can calculate the exact RPM at which motor will run. We know that motor needs 200 pulses to complete 1 revolution. Means if 200 pulses applied in 1 second motor will complete 1 revolution in 1 second. Now 1 rev. in 1 sec means 60 rev. in 1 minute. That will give us 60 RPM. Now 200 pulses in 1 sec means the PRF is 200 Hz. And delay will be 5 millisecond (ms). Now lets see it reverse. * If delay is 10 ms then PRF will be 100 Hz. * So 100 pulses will be given in 1 sec
George N Kibia
E26-0668/03
Page 43
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) * Motor will complete 1 revolution in 2 second * so the RPM will be 30. In the same manner delay is changed in the PRF so is the RPM.
2009
Output is the same as input given The 74157 is a quad 2-input multiplexer which select 4 bits of data from two sources under the control of a common data select input (S). The four outputs present the selected data in the true (non-
George N Kibia
E26-0668/03
Page 44
2009
inverted) form. The enable input (E) is active LOW. When E is HIGH, all of the outputs (1Y to 4Y) are forced LOW regardless of all other input conditions.
George N Kibia
E26-0668/03
Page 45
2009
CHAPTER FOUR
4.0 CIRCUIT DESIGN
4.1 HARDWARE DESCRIPTION
Microcontroller Based Vehicle Parking System is composed of the following broadly classified sections: 1. Microcontroller and Program section 2. Display section 3. Indicator section
4. Lift & motor section 5. Sensor section 6. LCD section This can be illustrated in the block diagram as below:
LCD DISPLAY
7 SEGMENT DISPLAY
George N Kibia
E26-0668/03
Page 46
2009
George N Kibia
E26-0668/03
Page 47
2009
OPERATION
In the lift section, there is a light beam and LDR to know whether a car has entered the lift or not. When the GREEN LED of indicator section glows, that means the lift is ready for the car to enter. When the car enters the lift, the light beam falling on LDR present in the lift gets cut and it gives a signal that a car has entered the lift. Then the program decides which floor lift has to go and gives a signal to motor section. Circuit diagram of sensor present in lift is shown below.
George N Kibia
E26-0668/03
Page 48
2009
R3
100R
output(mux)
RV1
RES-VAR
U1
Q DC 3 7
VCC
R4
100R
Q1
BC547
CV
R2
1k
GND
D1
LED
TR
TH
LDR
555
C1
220n
George N Kibia
E26-0668/03
Page 49
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) Circuit diagram of this section is shown below.
2009
OPERATION
When a person needs to come down from a particular floor to ground floor, he must focus the headlights of the car onto the LDR placed in that floor. When light falls on the LDR its resistance decreases. Hence IC 555 triggers and gives a signal. The program identifies that signal and gives a signal to the motor instructing it which flow to move to: the motor may move clockwise or anticlockwise. The circuit diagram of the sensor is shown below. This circuit is different compared to that of lift sensor shown above.
George N Kibia
E26-0668/03
Page 50
2009
R3
100R
output (mux)
U1
Q DC 3 7
VCC
R4
100R
Q1
BC547
CV
R2
1k
GND
TR
TH
RV2
RES-VAR
555
C1
220n
George N Kibia
E26-0668/03
Page 51
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) FIG 4.7: LCD interfaced to AT89C51 microcontroller.
2009
George N Kibia
E26-0668/03
Page 52
2009
ASSEMBLER
An ASSEMBLER is a program that transforms assembly language into machine language and the reverse by a disassembler. Unlike in high-level languages, there is usually a one-to-one correspondence between simple assembly statements and machine language instructions. Each computer architecture and processor architecture has its own machine language.
George N Kibia
E26-0668/03
Page 53
2009
IS THERE A CAR?
MOVE MOTOR UP
STOP MOTOR
INCREMENT F1 COUNTER
STOP MOTPR
END
George N Kibia
E26-0668/03
Page 54
2009
CHAPTER FIVE
5.0 CONCLUSION AND RECOMMENDATIONS
5.1 EXPERIMENTAL RESULTS A Seven segment display at the ground floor which is basically a counter displays the number of cars in each floor. It informs whether the floors are fully filled with cars or is there a free parking space in a particular floor or not. There is a lift facility to carry the car up and down the building. Movement of Lift is controlled by a stepper motor. An indicator with a green and red LED is kept in all the floors to indicate whether the lift is busy or is it ready to take the car up or down. If the red LED glows that means the lift is already engaged and the person has to wait for the green LED to glow. In this project I have provided TWO floors for car parking. Maximum storage capacity of each floor is ten. Storage capacity can be changed according to any number and the program modified to user specifications. When the car enters the lift, an LDR connected to a 555 timer detects the cars presence and sends a signal to the RED LED, this lights the LED indicating that the lift is busy. It also sends a signal to the microcontroller which determines the direction that the motor rotates; it can be clockwise or anticlockwise. After the RED LED glows the lift will take the person and the car up to the floor where there is an available parking. When the lift reaches the first floor, the processor compares the filled amount to that of the already fed capacity of that floor, and if it finds that the first floor is fully filled, it goes to the second floor and thus the procedure stops here. As soon as a car is placed in a particular floor, the display counter at the ground floor increments as to indicate the floor capacity has decreased by one. After the lift takes a car to a particular floor, it comes back to its normal position i.e. the ground floor and the motor that drives it stops. Now the processor sends a signal to the GREEN LED indicating that lift is free. When a person needs to come down from a particular floor to ground floor, he is expected to focus the headlight onto the LDR (light activated) placed in that floor. Now the sensor section sends signal to the motor that the lift has to be sent back to that particular floor and sends a signal to light the RED LED indicating that the lift is busy. As soon as the lift reaches that particular floor, the car should come inside the lift, the display counter at the ground floor decrements by one as to indicate the floor capacity has increased by one. Lift comes back to its normal position and that time, the motor that drives it, also stops. Now the processor sends a signal to light the GREEN LED indicating that lift is free.
George N Kibia
E26-0668/03
Page 55
2009
If there no parking is taking place, the processor carries out the job according to the following priority:1. It checks whether any car has been entered into the lift. 2. It checks whether any car headlights are focused in front of the LDR placed in each floor. This is a round robin system that continually checks for changes in the above states.
5.3 PROBLEMS ENCOUNTERED A number of problems were encountered during the design of the system and implementation.
1. Some of the components were unavailable in the market for some time thus there was a delay in the completion of the project in the set time. 2. Use of the breadboard in implementing the circuit designed was also disadvantageous as some of the components were loose fitting. 3. Simulation of the project in the computer was difficult as no program had all the devices. 4. Programming in assembly language has a lot of demerits. Its hard to debug and compile.
5.4 RECOMMENDATIONS
The set objectives were partially met. A lot was learnt in regard to operation of the microcontroller, transistor circuits, timer circuits and display circuits. The exercise acted as a good complement to theoretical knowledge acquired in class.
George N Kibia
E26-0668/03
Page 56
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) From research the following recommendation are made: project work should be started early,
2009
the department should avail some components to the students to cut costs while saving time on delays as students have to import components, The department should also stock some apparatus e.g. programmers for microcontrollers, solder suckers, Industries should be involved in the proposals for the projects thus the projects will be worthwhile.
George N Kibia
E26-0668/03
Page 57
2009
CHAPTER SIX
BUDGET ESTIMATE
ITEM MICROCONTROLLER 1 8051 2 8255PPI 2*16 CHARACTER LCD 3 DISPLAY 4 MUX 74157 5 7 SEGMENT DISPLAYS 6 LED(red, yellow, green) 7 LDR 8 9 10 11 12 13 14 555 TIMER RESISTORS CAPACITORS STEPPER MOTOR TRANSISTORS BUZZER CRYSTAL PRINTING AND 15 INTERNET 16 BREADBOARD 17 CONNECTING WIRES 18 40 PIN CONNECTOR GRAND TOTAL QUANTITY 1 2 1 1 2 9 3 3 28 10 1 LAB 7 1 KSH/QTY 1000 600 1700 200 150 10 50 50 5 20 TOTAL 1000 1200 1700 200 300 90 150 150 140 200 700 250 50 2500 900 300 9830
250 50
3 1
George N Kibia
E26-0668/03
Page 58
2009
CHAPTER SEVEN
7.0 TIME PLAN
Activity
Duration Semester I Sep Oct Nov Dec Semester II Jan Feb Mar Apr
Project proposal Drawing time plan Research Mini presentation Order of Components Software & hardware development Simulation & implementation Documentation Final presentation
George N Kibia
E26-0668/03
Page 59
2009
REFERENCES
BOOKS 1. K.J.Ayala, 8051 micro controller architecture, programming and application: Penram International Pub. 2. Jen Axelson, The Micro controller Idea book: Penram International Pub. 3. Myke Predko, Micro controller Basics and projects: Tata Mcgrowhill pub. 4. M A Mazidi, 8051 micro controller and embedded system: Pearson education 5. Scott Mackenzie, The 8051 microcontroller , 2 Edition,1995 6. Manfred Schleicher and Frank Blasinger, Digital Interfaces and Bus Systems for Communication practical fundamentals,3rd Edition,2001 7. Ronald J.Tocci, Digital System Principles and Application 8. Gakuru Wahome, Kenya Vision 2030 Transforming National Development,2007 9. Edward Hughes, Electrical machines 10. Charles Kinsley ,Electrical machines 11. B.L.Theraja and A.K.Theraja, A Textbook of Electrical Technology 12. F.C Fitchen, Transistor circuit analysis and design 13. Dave Proehnow and D.J Branning, Experiments in CMOS technology 14. Don Lancaster, CMOS Cook book WEBSITE LINKS 1. http:// www.datasheetarchieves.com 2. http:// www.wikipedia.com\multiplexer 3. http:// www.wikipedia.com\555 timer 4. http:// www.electronics_lab.com 5. http:// www. 8052\ 8051 Tutorial Index.com 6. http:// www.phillips semiconductors\80c51 family programmers guide and instruction set.html 7. http:// www.phillips semiconductors\80c51 family hardware.html 8. http:// www.phillips semiconductors\80c51 family architecture.html 9. Programming the 8255 PPI chip[online document],[cited 2006,15 th September], 10. Http://www.boondog.com/tutorial/dlltutor/8255.com 11. http://en.wikipedia.org/ 12. http://www.servicemagic.com/ 13. http://home.howstuffworks.com/ 14. http://www.boondog.com/ 15. http://www.codeproject.com/ 16. http://www.zycon.com/ 17. http://zone.ni.com/ 18. http://www.ozitronics.com/
George N Kibia
E26-0668/03
Page 60
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) APPENDIX A TERMS AND ACRONYMS 1. MICROBVPS: Microcontroller Based Vehicle Parking System 2. NCBD: Nairobi Central Business District 3. CCTV : Closed Circuit Television 4. MCU : Microcontroller Unit 5. LDR :Light Dependent Resistor 6. LCD :Light Crystal Display 7. PPI :Programmable Peripheral Interface 8. AT89C51 : Atmega 89c51 microcontroller 9. MUX: Multiplexer 10. LED: Light Emitting Diode 11. ROM: Read Only Memory 12. RAM: Random Access Memory 13. CPU: Central Processing Unit 14. ALU :Arithmetic and Logic Unit 15. RPM: Rotations Per Minute 16. 555 :555 Timer 17. 8255 : 8255 programmable peripheral interface
2009
George N Kibia
E26-0668/03
Page 61
2009
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22.
Fig1.1.Adiagonal Parking In Nairobi Fig 1.2. Multi Storey Parking Using Ramp (A Microbvps To Be Installed) Fig 1.3: Parking Lot Layout With Angle Parking As Seen From Above Fig 3.1: Block Diagram Showing The Usual Cpu Components, Program Counter, Alu, Working Registers, And The Clock Circuits. Fig 3.2 8255 Functional Block Diagram Fig 3.3: Darkness Activated Ldr Fig 3.4: Light Activated Ldr Fig 3.5 The Monostable Input And Output Waveform Fig 3.6 The 555 Monostable Circuit Fig 3.7 Varying The Time Period With A Variable Resistor Fig 3.8 Pin Configuration Of A Seven Segment Display: Fig 3.9 Circuit Diagram For Common Anode 7-Segment Display Fig3.10: Circuit Diagram For Common Cathode 7-Segment Display Interfaced To 8951 Fig.3.11: 2 Line X 16 Character Lcd Display Fig 3.12 Description Of Rotation Of A Stepper Motor Fig 3.13.Step Rotation A Stepper Motor Figure 4.1. Block Diagram Of Microcontroller Based Vehicle Parking System Fig 4.2 Project Block Diagram Fig 4.3:Seven Segment Connection To The 8255ppi Fig 4.4: Lift Sensor Fig 4.5 : Motor Interface To The 8255ppi Fig 4.6: Floor Sensor
LIST OF TABLES TABLE 1. Table 3.1: Control Signals Of The 8255ppi 2. Table 3.2: 555 Timer Pin Description Table 3. Table 3.3: For Common Cathode (The Seven Segment Requirement Pattern To Display The Hex Number, With The Seven Segment Conversion) 4. Table 3.4: For Common Anode (The Seven Segment Requirement Pattern To Display The Hex Number, With The Seven Segment Conversion) 5. Table 3.5: Pin Description Of Lcd Display 6. Table 3.6: List Of Lcd Display Instruction Command Codes. 7. Table 3.7 : Comparison Of Motor Types 8. Table 3.8:Pulses For Stepper Motor Module 9. Table 3.9 Multiplexer Pin Description
(MICROBVPS
George N Kibia
E26-0668/03
Page 62
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) APPENDIX B: MAIN MICROCONTROLLER PROGRAM: ; JOMO KENYATTA UNIVERSITY OF AGRICULTURE AND TECHNOLOGY
; FACULTY OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING ; EEE 2501: FINAL YEAR PROJECT REPORT ; MICROCONTROLLER BASED VEHICLE PARKING SYSTEM TITLE: ; AUTHOR GEORGE NGUGI KIBIA ; REG NUMBER E26-0668/03 ; DATE 25/03/2009
2009
ORG 0000H mov r0,#19h mov @r0,#0bfh inc r0 mov @r0,#86h inc r0 mov @r0,#0dbh inc r0 mov @r0,#0cfh inc r0 mov @r0,#0e6hinc r0 ; Storing the equivalent codes of common cathode display. mov @r0,#0edh ; inc r0 mov @r0,#fdh inc r0 mov @r0,#87h inc r0 mov @r0,#0ffh inc r0 mov @r0,#0e7h inc r0 mov @r0,#39h inc r0 mov @r0,#00h mov r0,#25h ; Storing the equivalent codes of common anode. mov @r0,#40h inc r0 mov @r0,#0f9h inc r0 mov @r0,#24h inc r0 mov @r0,#30h inc r0 mov @r0,#99h inc r0 mov @r0,#12h inc r0 mov @r0,#02h inc r0 mov @r0,#78h
inc r0 mov @r0,#00h inc r0 mov @r0,#18h inc r0 mov @r0,#0eh mov r0,#45h ; Storing ten 4 digit passwords in common anode. mov @r0,#00h inc r0 mov @r0,#01h inc r0 mov @r0,#02h inc r0 mov @r0,#03h inc r0 mov @r0,#08h inc r0 mov @r0,#00 inc r0 mov @r0,#05h inc r0 mov @r0,#01h inc r0 mov @r0,#01h inc r0 mov @r0,#00 inc r0 mov @r0,#00 inc r0 mov @r0,#01h inc r0 mov @r0,#06h inc r0 mov @r0,#00 inc r0 mov @r0,#05h inc r0 mov @r0,#00 inc r0 mov @r0,#09h inc r0 mov @r0,#08h inc r0
George N Kibia
E26-0668/03
Page 63
2009
jz SIREN ; Call SIREN if second floor is full. call lcdbusy mov a,#10h movx @dptr,a ; send lift is busy signal. call DELAY mov r7,#02 ; number of rotations to motor so that lift goes to first floor. mov r6,#02h call MOTOR_UP ; Call motor to rotate clockwise. mov a,#0ah xrl a,r3 jz I_FULL ; If first floor is full then jump to I_FULL inc r3 call DELAY mov a,r3 ; Increment the number of car in first floor and display the number of cars. call LED_CODES mov dptr,#2042h movx @dptr,a mov r7,#02h ; Again load the number of rotations to motor mov r6,#02h call MOTOR_DOWN ; Call motor to rotate anticlockwise. mov dptr,#2022h mov a,#30h movx @dptr,a ; send lift is free signal. call lcdwel sjmp DONE I_FULL: mov r7,#02h ;number of rotations to motor so that lift goes to second floor. mov r6,#02h call MOTOR_UP ; Call motor to rotate clockwise. inc r4 call DELAY mov a,r4 ; Increment the number of car in second floor. call LED_CODES ; Display the number of cars. mov dptr,#2041h movx @dptr,a mov r7,#04h ;Again load the number of rotations to motor. mov r6,#02h call MOTOR_DOWN ; Call motor to rotate anticlockwise. mov dptr,#2022h mov a,#30h
George N Kibia
E26-0668/03
Page 64
2009
DONE: movx a,@dptr ; Compare if start button of the keyboard is pressed. cjne a,#33h,OVER1 mov a,#0ah xrl a,r5 jz SIREN ; Call SIREN if third floor is full. mov a,#00 movx @dptr,a call lcdbusy setb psw.3 CLEAR: mov r1,#0ah ; Scanning entered password from keyboard mov r0,#04h START: mov dptr,#2020h mov a,#0eh movx @dptr,a WAIT: mov dptr,#2022h movx a,@dptr mov r7,#00 xrl a,r7 jz WAIT mov a,#02 LOOP: mov r6,a mov dptr,#2020h movx @dptr,a mov dptr,#2022h movx a,@dptr jnz COLSCAN inc r7 mov a,r6 rl a jmp LOOP COLSCAN: rrc a jc DONE1 inc r7 inc r7 inc r7 sjmp COLSCAN OVER1: jmp OVER DONE1: mov a,r7 clr psw.3 setb psw.4 mov r0,#19h
; Store
mov r7,#0ah ;Checking whether entered 4 digit password is any one of the stored password. mov r0,#45h CHECK: mov r1,#0ah mov r6,#03h CHECK1:mov a,@r0 xrl a,@r1 jnz NEXT inc r1 inc r0 djnz r6,CHECK1 mov dptr,#2022h mov a,#90h movx @dptr,a clr psw.3 jmp OK ; Jump to OK if password is correct. NEXT: inc r0 djnz r6,NEXT inc r0 djnz r7,CHECK mov dptr,#2022h mov a,#50h movx @dptr,a AGAIN: movx a,@dptr cjne a,#53h,AGAIN clr psw.3 mov a,#30h ;Give SIREN if entered password is wrong. movx @dptr,a REMAIN: movx a,@dptr
George N Kibia
E26-0668/03
Page 65
2009
MOTOR_DOWN:push r5 ;Subroutine for motor to rotate anticlockwise. mov r5,#70h mov r0,r6 mov dptr,#2020h mov a,#88h h6: movx @dptr,a rr a mov r2,#30 h4: mov r1,#255 h5: djnz r1,h5 djnz r2,h4 djnz r5,h6 mov r5,#0ffh djnz r6,h6 mov r6,r0 djnz r7,h6 pop r5 ret DELAY: mov r1,#10h Subroutine for Delay DELAY1: mov r2,#0ffh DELAY2: mov r0,#0ffh DELAY3: djnz r0,DELAY3 djnz r2,DELAY2 djnz r1,DELAY1 ret ;
OVER: mov dptr,#2022h mov a,#30h movx @dptr,a movx a,@dptr cjne a,#32h,I_OVER mov a,#10h movx @dptr,a call lcdbusy mov r7,#02h mov r6,#02h call MOTOR_UP ; Call motor to rotate clockwise. dec r3 ; Decrements the number of cars entered to first floor and display
George N Kibia
E26-0668/03
Page 66
2009
call DELAY mov r7,#06h mov r6,#02h call MOTOR_DOWN ; Call motor to rotate anticlockwise. mov dptr,#2022h mov a,#30h movx @dptr,a call lcdwel END: jmp REPEAT lcdwel: push r3 ; Subroutine for LCD to display push r4 WELCOME TO CAR PARKING SYSTEM mov a,#3ch call command mov a,#0eh call command mov a,#01h call command mov a,#06h call command mov a,#80h call command mov a,#'W' call data mov a,#'E' call data mov a,#'L' call data mov a,#'C' call data mov a,#'O' call data mov a,#'M' call data mov a,#'E' call data mov a,#' ' call data mov a,#88h call command mov a,#'T' call data mov a,#'O' call data mov a,#' ' call data mov a,#'C' call data mov a,#'A' call data1 mov a,#'R' call data mov a,#aah call command mov a,#'P'
George N Kibia
E26-0668/03
Page 67
2009
George N Kibia
E26-0668/03
Page 68
2009
George N Kibia
E26-0668/03
Page 69
2009
George N Kibia
E26-0668/03
Page 70
MICROCONTROLLER BASED VEHICLE PARKING SYSTEM (MICROBVPS) APPENDIX D.5 LIGHT DEPENDENT RESISTOR (LDR)
2009
George N Kibia
E26-0668/03
Page 71
U5
APPENDIX E:
+5v
HP-5082-7610
+88.8
George N Kibia
DP1 G F E D C B A +V2 +V1 10 11 12 13 17 16 15 14 PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 6 35 8 9 36 5 17 16 15 14 13 12 11 10 P3.7/RD P3.6/WR P3.5/T1 P3.4/T0 P3.3/INT1 P3.2/INT0 P3.1/TXD P3.0/RXD 6 11 2 7 8 10 13 1 3 14 25 24 23 22 21 20 19 18 PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 CS RESET A1 A0 WR RD
U4
E26-0668/03
HP-5082-7610
8 7 6 5 4 3 2 1
D7 D6 D5 D4 D3 D2 D1 D0
DP1 G F E D C B A +V2 +V1 37 38 39 40 1 2 3 4 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 A(8..15) D7 D6 D5 D4 D3 D2 D1 D0 27 28 A15 29 A14 30 A13 31 A12 32 A11 33 A10 34 A9 A8 28 27 26 25 24 23 22 21
6 11 2 7 8 10 13 1 3 14
EA ALE PSEN
31 30 29
U3
RST
1Y
D4
D1
LED-RED
LED-GREEN
2 3 5 6 11 10 14 13 1A 1B 2A 2B 3A 3B 4A 4B
PC(10..13)
32 33 34 35 36 37 38 39
XTAL2
18
XTAL1
19
U1
LM016L
LCD1
D3
1 15 A/B E
LED-GREEN
U6
D2
PB0 6 5 4 3 2 1
+5v
D7 D6 D5 D4 D3 D2 D1 D0
10 11 12 13 17 16 15 14
PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 PB(18..25) 6 CS RESET A1 A0 WR RD 37 38 39 40 1 2 3 4 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0
8255A GND=-5V VCC=+5V
LED-GREEN
D(0..7)
X2
CRYSTAL
25 24 23 22 21 20 19 18
35 8 9 36 5 D7 D6 D5 D4 D3 D2 D1 D0 27 28 29 30 31 32 33 34
U2
Page 71
2009