Document

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 66

Automatic gate opening system for parking lot

CONTENTS 1. ABSTRACT 2. INTRODUCTION TO EMBEDDED SYSTEMS 3. BLOCK DIAGRAM 4. HARDWARE REQUIREMENTS 4.1 TRANSFORMERS 4.2 VOLTAGE REGULATOR (LM7805, LM7809) 4.3 RECTIFIER 4.4 FILTER 4.5 MICROCONTROLLER (AT89S52/C51) 4.6 ULTRASONIC TRANSMITER & RECEIVER 4.7 555 TIMER 4.8 RELAY 4.9 SWING MOTOR 4.10 PUSH BUTTONS 4.11 LCD 4.12 BC547 4.13 BC557 4.14 LED 4.15 1N4007 4.16 RESISTORS 4.17 CAPACITORS 4.18 CA3140 4.19 IN4148
Electronics and communication Engg .. VEC

PAGE NO. 5 6 9 10 11 12 13 14 14 20 22 25 28 28 29 32 33 34 35 38 39 40 40
1

Automatic gate opening system for parking lot

5. SOFTWARE REQUIREMENTS 5.1 INTRODUCTION OF KEIL MICRO VISION 5.2 CONCEPT OF COMPILER 5.3 CONCEPT OF CROSS COMPILER 5.4 CREATING YOUR OWN APPLICATION IN UVISION2 5.5 DEBUGGING AN APPLICATION IN UVISION2 5.6 WINDOWS_ FILES 5.7 BUILDING PROJECTS 5.8 EMBEDDED C 6. SCHEMATIC DIAGRAM 6.1 DESCRIPTION 7. LAYOUT DIAGRAM 8. BILL OF MATERIALS 9. CODING 9.1 COMPILER 9.2 SOURCE CODE 10. HARDWARE TESTING 10.1 CONTINUITY TEST 10.2 POWER ON TEST 11. RESULTS 12.CONCLUSION 13. BIBLIOGRAPHY

41 41 42 42 43 43 43 44 44 45 46 49 50 52 52 61 64 64 65 65 66 66

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

LIST OF FIGURES

PAGE NO.

2 EMBEDDED DESIGN CALLS 3 BLOCK DIAGRAM OF THE PROJECT 4.1 A TYPICAL TRANSFORMER 4.2 BLOCK DIAGRAM OF VOLTAGE REGULATOR 4.3 BRIDGE RECTIFIER 4.4 FILTER RESPONSE 4.5(a) BLOCK DIAGRAM OF AT89S52 4.5(b) PIN DIAGRAM OF AT89S52 4.5(c) OSCILLATOR CONNECTIONS 4.6 ULTASONIC TRANSMITTER & RECEIVER 4.7(a) 555 TIMER IC 4.7(b) PIN DIAGRAM OF 555 TIMER 4.7(c) 555 TIMER AS BUFFER 4.7(d) 555 TIMER AS MONOSTABLE 4.7(e) 555 TIMER AS ASTABLE 4.7(f) OPERATION OF 555 TIMER 4.8(a) RELAY 4.8(b) RELAY SHOWING COIL AND SWITCH CONTACTS 4.10(a) PUSH BUTTONS

6 8 10 12 12 13 15 16 18 20 21 22 22 23 23 24 24 25 27 28 29
3

4.9(b) PUSH ON BUTTON 4.11 LCD


Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

4.14(a) TYPES OF LED 4.14(b) SYMBOL OF LED 4.15(a) IN4007 DIODES 4.15(b) PN JUNCTION DIODE 4.16 BASIC RESISTORS 4.17 BASIC CAPICTORS 6.SCHEMATIC DIAGRAM

33 34 34 35 37 38 44

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

CHAPTER 1 ABSTRACT

This ultrasonic proximity detector comprising independent, battery or AC powered transmitter and receiver sections make use of a pair of matched ultrasonic piezo ceramic transducers operating at around 40 kHz each. This circuit is used in getting reflected signals from the object such as a car coming in front of it that feeds a logical input to the microcontroller that develops an output to drive relays for opening the boom bar of the parking lot. Opamps are used to amplify the weak signals received upon reflection by the obstacle by the receiving ultrasonic transducer sent by the transmitting one, to switch on appropriate load

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

CHAPTER 2 INTRODUCTION TO EMBEDDED SYSTEM Embedded system


An Embedded System is a combination of computer hardware and software, and perhaps additional mechanical or other parts, designed to perform a specific function. An embedded system is a microcontroller-based, software driven, reliable, real-time control system, autonomous, or human or network interactive, operating on diverse physical variables and in diverse environments and sold into a competitive and cost conscious market.

An embedded system is not a computer system that is used primarily for processing, not a software system on PC or UNIX, not a traditional business or scientific application. High-end embedded & lower end embedded systems. High-end embedded system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital Assistant and Mobile phones etc .

System design calls:

Fig 2(a): Embedded system design calls

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

Characteristics of Embedded System:


An embedded system is any computer system hidden inside a product other than a computer. They will encounter a number of difficulties when writing embedded system software in addition to those we encounter when we write applications. ResponseOur system may need to react to events quickly. TestabilitySetting up equipment to test embedded software can be difficult. DebugabilityWithout a screen or a keyboard, finding out what the software is doing wrong (other than not working) is a troublesome problem. Reliability embedded systems must be able to handle any situation without human intervention. Memory space Memory is limited on embedded systems, and you must make the software and the data fit into whatever memory exists. Program installation you will need special tools to get your software into embedded systems.

Applications:
1) Military and aerospace embedded software applications 2) C om m u ni c at i o n Ap p l i c at i on s

Classification:
Real Time Systems. RTS is one which has to respond to events within a specified deadline.

RTS classification:
Hard Real Time Systems Soft Real Time System

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

CHAPTER 3 BLOCK DIAGRAM

FIG. 3: Block diagram of project

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

CHAPTER 4 HARDWARE REQUIREMENTS


Hard ware components:
1. TRANSFORMER (230 12 V AC) 2. VOLTAGE REGULATOR (LM 7805) 3. RECTIFIER 4. FILTER 5. MICROCONTROLLER (AT89S52/AT89C51) 6. ULTRASONIC TRANSMITTER AND RECIVER 7. 555 TIMER 8. RELAY 9. SWING MOTOR 10. PUSH BUTTONS 11. LCD 12. BC547 13. BC558 14. LED 15. 1N4007 16. RESISTORS 17. CAPACITORS 18. CA3140 19. 1N4148

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

4.1 Transformer:
Transformers convert AC electricity from one voltage to another with a little loss of power. Step-up transformers increase voltage, step-down transformers reduce voltage. Most power supplies use a step-down transformer to reduce the dangerously high voltage to a safer low voltage.

Fig 4.1: A Typical Transformer

The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down and current is stepped up. The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage. TURNS RATIO = (Vp / Vs) = ( Np / Ns )

Ideal power equation:

Electronics and communication Engg .. VEC

10

Automatic gate opening system for parking lot

Where, Vp = primary (input) voltage. Vs = secondary (output) voltage Np = number of turns on primary coil Ns = number of turns on secondary coil Ip = primary (input) current Is = secondary (output) current.

4.2 Voltage regulator 7805:


Features Output Current up to 1A. Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V. Thermal Overload Protection. Short Circuit Protection. Output Transistor Safe Operating Area Protection.

Description: The LM78XX/LM78XXA series of three-terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a Wide range of applications. Each type employs internal current limiting, thermal shutdown and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output Current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents.

Electronics and communication Engg .. VEC

11

Automatic gate opening system for parking lot

Internal Block Diagram:

Fig 4.2: Block diagram of voltage regulator

4.3 Rectifier:
A rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), current that flows in only one direction, a process known as rectification. Rectifiers have many uses including as components of power supplies and as detectors of radio signals. Rectifiers may be made of solid state diodes, vacuum tube diodes, mercury arc valves, and other components. The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification. In positive half cycle only two diodes (1 set of parallel diodes) will conduct, in negative half cycle remaining two diodes will conduct and they will conduct only in forward bias only.

Fig:4.3 Bridge rectifier

Electronics and communication Engg .. VEC

12

Automatic gate opening system for parking lot

4.4 Filter:
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage.

The simple capacitor filter is the most basic type of power supply filter. The use of this filter is very limited. It is sometimes used on extremely high-voltage, low-current power supplies for cathode-ray and similar electron tubes that require very little load current from the supply. This filter is also used in circuits where the power-supply ripple frequency is not critical and can be relatively high. Below figure can show how the capacitor charges and discharges.

Fig:4.4 filter response

4.5 Microcontroller AT89S52:


The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density non volatile memory technology and is compatible with the industry standard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be
Electronics and communication Engg .. VEC 13

Automatic gate opening system for parking lot

reprogrammed in-system or by a conventional non volatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 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 interrupt or hardware reset.

Features: Compatible with MCS-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines

Electronics and communication Engg .. VEC

14

Automatic gate opening system for parking lot

Block Diagram of AT89S52:

Fig 4.5(a): Block diagram of AT89S52

Electronics and communication Engg .. VEC

15

Automatic gate opening system for parking lot

Pin Configurations of AT89S52

FIG 4.5(b): Pindiagram of AT89S52

Pin Description: VCC: Supply voltage.

GND: Ground
Electronics and communication Engg .. VEC 16

Automatic gate opening system for parking lot

Port 0: Port 0 is an 8-bit open drain bidirectional 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 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. 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 pull-ups and can be used as inputs. Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. 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 pull-ups and can be used as inputs. Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. 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 pull-ups and can be used as inputs RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out ALE/PROG: Address Latch Enable (ALE) is an 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. PSEN: Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each
Electronics and communication Engg .. VEC 17

Automatic gate opening system for parking lot

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. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2: Output from the inverting oscillator amplifier.

Oscillator Characteristics: XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven.

FIG 4.5(C): Oscillator Connections Idle Mode In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.
Electronics and communication Engg .. VEC 18

Automatic gate opening system for parking lot

Power down Mode In the power down mode the oscillator is stopped, and the instruction that invokes power down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power down mode is terminated. The only exit from power down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.

4.6 Ultrasonic transmitter and receiver:


Ultrasonic sensors (also known as transceivers when they both send and receive) work on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object. This technology can be used for measuring: wind speed and direction (anemometer), fullness of a tank and speed through air or water. For measuring speed or direction a device uses multiple detectors and calculates the speed from the relative distances to particulates in the air or water. To measure the amount of liquid in a tank, the sensor measures the distance to the surface of the fluid. Systems typically use a transducer which generates sound waves in the ultrasonic range, above 18,000 hertz, by turning electrical energy into sound, then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed. Ultrasonic generators use piezoelectric materials such as zinc or lead zirconium tartrates or quartz crystal. The material thickness decides the resonant frequency when mounted and excited by electrodes attached on either side of it. The medical scanners used for
Electronics and communication Engg .. VEC 19

Automatic gate opening system for parking lot

abdomen or heart ultrasound are designed at 2.5 MHz. In this circuit, a 40 kHz transducer is used for object detection in the air medium.

Fig: 4.6 Ultrasonic transmitter and receiver The velocity of sound in the air is around 330 m/s at 0C and varies with temperature 40 KHz Ultrasonic Transducer Transmitter and Receiver Pair. These transducers are very useful in making various sensors for detecting obstacles and measuring distances.

Features

Use for motion or distance sensing Frequency: 40kHz 1.0kHz Aluminum case Lead length/spacing: 0.28 Case size: 0.30H x 0.43

Uses:
Ultrasonic sensors are used to detect the presence of targets and to measure the distance to targets in many automated factories and process plants. Sensors with an on or off digital output are available for detecting the presence of objects, and sensors with an analog output which varies proportionally to the sensor to target separation distance are commercially available.

Because ultrasonic sensors use sound rather than light for detection, they work in applications where photoelectric sensors may not. Ultrasonics are a great solution for clear object detection and for liquid level measurement, applications that photoelectric struggle with because of target translucence. Target colour and/or reflectivity don't affect ultrasonic sensors which can operate reliably in high-glare environments.

Electronics and communication Engg .. VEC

20

Automatic gate opening system for parking lot

4.7 555 Timer:


The 555 Timer IC is an integrated circuit (chip) implementing a variety of timer and multivibrator applications. The IC was designed by Hans R. Camenzind in 1970 and brought to market in 1971 by Signe tics (later acquired by Philips). The original name was the SE555 (metal can)/NE555 (plastic DIP) and the part was described as The IC Time Machine.

FIG 4.7(a) 555TIMER IC The 555 has three operating modes:

Monostable mode: in this mode, the 555 functions as a one-shot. Applications include timers, missing pulse detection, bouncefree switches, touch switches, frequency divider, capacitance measurement, pulse-width modulation (PWM) etc.

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 flip-flop, if the DIS pin is not connected and no capacitor is used. Uses include bouncefree latched switches, etc .

Pin Name Purpose: 1 2 3 GND TRIG OUT Ground, low level (0 V) OUT rises, and interval starts, when this input falls below 1/3 VCC. This output is driven to +VCC or GND.
21

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

4 5 6 7 8

RESET A timing interval may be interrupted by driving this input to GND. CTRL Control access to the internal voltage divider (by default, 2/3 VCC). THR DIS The interval ends when the voltage at THR is greater than at CTRL. Open collector output; may discharge a capacitor between intervals.

V+, VCC Positive supply voltage is usually between 3 and 15 V.

Fig 4.7(b) 555 Timer pin diagram Using the 555 as a buffer: A buffer circuit allows an input circuit to be connected to an output circuit, it is like an interface between one circuit and another. The buffer circuit requires very little input current but should be able to supply adequate output current. The circuit used is:

FIG 4.7 (c ) 555 Timer as buffer


Electronics and communication Engg .. VEC 22

Automatic gate opening system for parking lot

The circuit acts like an inverter or NOT gate. When the input is held low, the output is high and will provide (source) current. When the input is held high, the output is low and will sink current. Remember, for a buffer for even higher power devices that require even larger currents, the 555 buffer can be used to drive a relay or a transistor circuit. Using the 555 as a monostable The 555 can be used as a monostable using the circuit shown:

FIG 4.7(d) 555 Timer as a monostable Using the 555 as an astable The 555 can be used as an astable using the circuit shown:

FIG 4.7(e) 555 Timer as a astable


Electronics and communication Engg .. VEC 23

Automatic gate opening system for parking lot

Operation of the 555: It is not necessary to know how the 555 works. In fact a systems approach to electronics would never consider how any such sub-block works. However, a knowledge of how the 555 functions is useful. A much simplified block diagram of the 555 timer is shown:

FIG 4.7(f): Operation of 555timer

4.8 Relay:
A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism mechanically, but other operating principles are also used. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal.

Fig:4.8(a) Relay

Electronics and communication Engg .. VEC

24

Automatic gate opening system for parking lot

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and most have double throw (changeover) switch contacts as shown in the diagram.

Fig 4.8(b) Relay showing coil and switch contacts

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits; the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification.

The supplier's catalogue should show you the relay's connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil.

The figure shows a relay with its coil and switch contacts. You can see a lever on the left being attracted by magnetism when the coil is switched on. This lever moves the switch contacts.

Electronics and communication Engg .. VEC

25

Automatic gate opening system for parking lot

There is one set of contacts (SPDT) in the foreground and another behind them, making the relay DPDT. The relay's switch connections are usually labelled COM, NC and NO:

COM = Common, always connect to this; it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on.

Applications of relays
Relays are used to and for:

Control a high-voltage circuit with a low-voltage signal, as in some types of modems or audio amplifiers.

Control a high-current circuit with a low-current signal, as in the starter solenoid of an automobile.

Detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers.

Time delay functions. Relays can be modified to delay opening or delay closing a set of contacts. A very short (a fraction of a second) delay would use a copper disk between the armature and moving blade assembly. Current flowing in the disk maintains magnetic field for a short time, lengthening release time..

Electronics and communication Engg .. VEC

26

Automatic gate opening system for parking lot

4.9 Swing motor:


A synchronous (swing) motor is one in which the rotor normally rotates at the same speed as the revolving field in the machine. The stator is similar to that of an induction machine consisting of a cylindrical iron frame with windings, usually three-phase, located in slots around the inner periphery. The difference is in the rotor, which normally contains an insulated winding connected through slip rings or other means to a source of direct current (see Elementary synchronous generator.

One advantage of the synchronous motor is that the magnetic field of the machine can be produced by the direct current in the field winding, so that the stator windings need to provide only a power component of current in phase with the applied stator voltage.

4.10 Push buttons:

Fig 4.10(a): Push Buttons A push-button (also spelled pushbutton) or simply button is a simple switch mechanism for controlling some aspect of a machine or a process. Buttons are typically made out of hard material, usually plastic or metal. The surface is usually flat or shaped to accommodate the
Electronics and communication Engg .. VEC 27

Automatic gate opening system for parking lot

human finger or hand, so as to be easily depressed or pushed. Buttons are most often biased switches, though even many un-biased buttons (due to their physical nature) require a spring to return to their un-pushed state. Different people use different terms for the pushing of the button, such as press, depress, mash, and punch. Push to ON button:

Fig.4.10(b): push on button Initially the two contacts of the button are open. When the button is pressed they become connected. This makes the switching operation using the push button.

4.11 Liquid crystal display(lcd):


Description: This is the example for the Parallel Port. This example doesn't use the Bi-directional feature found on newer ports, thus it should work with most, if not all Parallel Ports. It however doesn't show the use of the Status Port as an input for a 16 Character x 2 Line LCD Module to the Parallel Port. These LCD Modules are very common these days, and are quite simple to work with, as all the logic required running them is on board.

LCD Background:

Frequently, an 8051 program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively.
Electronics and communication Engg .. VEC 28

Automatic gate opening system for parking lot

Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the 8051) and communicates directly with the LCD.

FIG 4.11: LCD

44780 LCD background: The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).

Electronics and communication Engg .. VEC

29

Automatic gate opening system for parking lot

The three control lines are referred to as EN, RS, and RW. The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data.

To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which should be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost always be low .Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

4.12 BC547:
Technical specification: The BC547 transistor is an NPN Epitaxial Silicon Transistor. The BC547 transistor is a general-purpose transistor in small plastic packages. It is used in general-purpose switching and amplification BC847/BC547 series 45 V, 100 mA NPN general-purpose transistors.

Electronics and communication Engg .. VEC

30

Automatic gate opening system for parking lot

BC 547 TRANSISTOR PINOUTS

We know that the transistor is a "CURRENT" operated device and that a large current (Ic) flows freely through the device between the collector and the emitter terminals. However, this only happens when a small biasing current (Ib) is flowing into the base terminal of the transistor thus allowing the base to act as a sort of current control input. The ratio of these two currents (Ic/Ib) is called the DC Current Gain of the device and is given the symbol of hfe or nowadays Beta, (). Beta has no units as it is a ratio. Also, the current gain from the emitter to the collector terminal, Ic/Ie, is called Alpha, (), and is a function of the transistor itself. As the emitter current Ie is the product of a very small base current to a very large collector current the value of this parameter is very close to unity, and for a typical low-power signal transistor this value ranges from about 0.950 to 0.999.

An NPN Transistor Configuration:

Electronics and communication Engg .. VEC

31

Automatic gate opening system for parking lot

4.13 BC557:

BC557 Transistors The BC557 transistor is an PNP Epitaxial Silicon Transistor. The BC557 transistor is a general-purpose transistor in small plastic packages. It is used in general-purpose switching and amplification BC847/BC547 series 45 V, 100 mA PNP general-purpose transistors.

An PNP Transistor Configuration:

The BC557 transistor is an PNP bipolar transistor, in which the letters "P" and "N" refer to the majority charge carriers inside the different regions of the transistor. Most bipolar transistors used today are PNP, because electron mobility is higher than hole mobility in semiconductors, allowing greater currents and faster operation. PNP transistors consist of a layer of N-doped semiconductor (the "base") between two P-doped layers. A small current entering the base in common-emitter mode is amplified in the collector output. In other terms, an PNP transistor is "on" when its base is pulled high relative to the emitter.

Electronics and communication Engg .. VEC

32

Automatic gate opening system for parking lot

4.14 LED: A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices, and are increasingly used for lighting. When a light-emitting diode is forward biased (switched on), electrons are able to recombine with holes within the device, releasing energy in the form of photons.

This effect is called electroluminescence and the color of the light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. An LED is often small in area (less than 1 mm2), and integrated optical components may be used to shape its radiation pattern. LEDs present many advantages over incandescent light sources including lower energy consumption, longer lifetime, improved robustness, smaller size, faster switching, and greater durability and reliability. Types of LEDS:

Fig 4.14(a): Types of LED Light-emitting diodes are used in applications as diverse as replacements for aviation lighting, automotive lighting as well as in traffic signals. The compact size, the possibility of narrow bandwidth, switching speed, and extreme reliability of LEDs has allowed new text and video displays and sensors to be developed, while their high switching rates are also useful in advanced communications technology. Electronic Symbol:

Fig 4.14(b): symbol of LED


Electronics and communication Engg .. VEC 33

Automatic gate opening system for parking lot

4.15 1N4007:
Diodes are used to convert AC into DC these are used as half wave rectifier or full wave rectifier. Three points must he kept in mind while using any type of diode. 1. Maximum forward current capacity 2. Maximum reverse voltage capacity 3. Maximum forward voltage capacity

Fig: 4.15(a)1N4007 diodes

The number and voltage capacity of some of the important diodes available in the market are as follows:

Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and IN4007 have maximum reverse bias voltage capacity of 50V and maximum forward current capacity of 1 Amp.

Diode of same capacities can be used in place of one another. Besides this diode of more capacity can be used in place of diode of low capacity but diode of low capacity cannot be used in place of diode of high capacity. For example, in place of IN4002; IN4001 or IN4007 can be used but IN4001 or IN4002 cannot be used in place of IN4007.The diode

Electronics and communication Engg .. VEC

34

Automatic gate opening system for parking lot

BY125made by company BEL is equivalent of diode from IN4001 to IN4003. BY 126 is equivalent to diodes IN4004 to 4006 and BY 127 is equivalent to diode IN4007.

Fig:4.15(b)PN Junction diode PN junction operation: Now that you are familiar with P- and N-type materials, how these materials are joined together to form a diode, and the function of the diode, let us continue our discussion with the operation of the PN junction. But before we can understand how the PN junction works, we must first consider current flow in the materials that make up the junction and what happens initially within the junction when these two materials are joined together.

Current Flow in the N-Type Material:


Conduction in the N-type semiconductor, or crystal, is similar to conduction in a copper wire. That is, with voltage applied across the material, electrons will move through the crystal just as current would flow in a copper wire. This is shown in figure 1-15. The positive potential of the battery will attract the free electrons in the crystal. These electrons will leave
Electronics and communication Engg .. VEC 35

Automatic gate opening system for parking lot

the crystal and flow into the positive terminal of the battery. As an electron leaves the crystal, an electron from the negative terminal of the battery will enter the crystal, thus completing the current path. Therefore, the majority current carriers in the N-type material (electrons) are repelled by the negative side of the battery and move through the crystal toward the positive side of the battery.

Current Flow in the P-Type Material :


Current flow through the P-type material is illustrated. Conduction in the P material is by positive holes, instead of negative electrons. A hole moves from the positive terminal of the P material to the negative terminal. Electrons from the external circuit enter the negative terminal of the material and fill holes in the vicinity of this terminal. At the positive terminal, electrons are removed from the covalent bonds, thus creating new holes. This process continues as the steady stream of holes (hole current) moves toward the negative terminal.

4.16 Resistor:
A resistor is a two-terminal electronic component designed to oppose an electric current by producing a voltage drop between its terminals in proportion to the current, that is, in accordance with Ohms law: V = IR Resistors are used as part of electrical networks and electronic circuits. They are extremely commonplace in most electronic equipment. Practical resistors can be made of various compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).

Electronics and communication Engg .. VEC

36

Automatic gate opening system for parking lot

Fig:4.16 Basic resistors A resistor is a two-terminal passive electronic component which implements electrical resistance as a circuit element. When a voltage V is applied across the terminals of a resistor, a current I will flow through the resistor in direct proportion to that voltage. The reciprocal of the constant of proportionality is known as the resistance R, since, with a given voltage V, a larger value of R further "resists" the flow of current I as given by Ohm's law:

Units:
The ohm (symbol: ) is the SI unit of electrical resistance, named after Georg Simon Ohm. An ohm is equivalent to a volt per ampere. The reciprocal of resistance R is called conductance G = 1/R and is measured in Siemens (SI unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal of an ohm: S = 1.

4.17 Capacitor: A capacitor or condenser is a passive electronic component consisting of a pair of conductors separated by a dielectric. When a voltage potential difference exists between the conductors, an electric field is present in the dielectric. This field stores energy and produces a mechanical force between the plates. The effect is greatest between wide, flat, parallel, narrowly separated conductors. An ideal capacitor is characterized by a single constant value, capacitance, which is measured in farads. This is the ratio of the electric charge on each conductor to the potential difference between them.leakage.The conductors and leads introduce an equivalent series resistance and the dielectric has an electric field strength limit resulting in a breakdown voltage.
Electronics and communication Engg .. VEC 37

Automatic gate opening system for parking lot

Fig:4.17 Capacitors A capacitor (formerly known as condenser) is a device for storing electric charge. The forms of practical capacitors vary widely, but all contain at least two conductors separated by a non-conductor. Capacitors used as parts of electrical systems, for example, consist of metal foils separated by a layer of insulating film. Capacitors are widely used in electronic circuits for blocking direct current while allowing alternating current to pass, in filter networks, for smoothing the output of power supplies, in the resonant circuits that tune radios to particular frequencies and for many other purposes. A capacitor is a passive electronic component consisting of a pair of conductors separated by a dielectric (insulator). When there is a potential difference (voltage) across the conductors, a static electric field develops in the dielectric that stores energy and produces a mechanical force between the conductors. An ideal capacitor is characterized by a single constant value, capacitance, measured in farads.

4.18 CA3140

Electronics and communication Engg .. VEC

38

Automatic gate opening system for parking lot

4.5MHz, BiMOS Operational Amplifier with MOSFET Input/Bipolar Output: The CA3140A and CA3140 are integrated circuit operational amplifiers that combine the advantages of high voltage PMOS transistors with high voltage bipolar transistors on a single monolithic chip. The CA3140A and CA3140 BiMOS operational amplifiers feature gate protected MOSFET (PMOS) transistors in the input circuit to provide very high input impedance, very low input current, and high speed performance. The CA3140A and CA3140 operate at supply voltage from 4V to 36V (either single or dual supply). These operational amplifiers are internally phase compensated to achieve stable operation in unity gain follower operation, and additionally, have access terminal for a supplementary external capacitor if additional frequency roll-off is desired.

4.19 1N4148

The 1N4148 is a standard small signal silicon diode used in signal processing. Its name follows the JEDEC nomenclature. The 1N4148 is generally available in a DO-35 glass package and is very useful at high frequencies with a reverse recovery time of no more than 4ns. This permits rectification and detection of radio frequency signals very effectively, as long as their amplitude is above the forward conduction threshold of silicon (around 0.7V) or the diode is biased.

Applications

High-speed switching

Electronics and communication Engg .. VEC

39

Automatic gate opening system for parking lot

CHAPTER 5 SOFTWARE REQUIREMENTS

5.1 Introduction to keil micro vision


Keil an ARM Company makes C compilers, macro assemblers, real-time kernels, debuggers, simulators, integrated environments, evaluation boards, and emulators for ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU families.

Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development. When starting a new project, simply select the microcontroller you use from the Device Database and the Vision IDE sets all compiler, assembler, linker, and memory options for you.

5.2 Concept of complier


Compilers are programs used to convert a High Level Language to object code. Desktop compilers produce an output object code for the underlying microprocessor, but not for other microprocessors. I.E the programs written in one of the HLL like C will compile the code to run on the system for a particular processor like x86 (underlying microprocessor in the computer). For example compilers for Dos platform is different from the Compilers for Unix platform So if one wants to define a compiler then compiler is a program that translates source code into object code.

The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instruction. See there is a bit little difference between compiler and an interpreter. Interpreter just interprets whole program at a time while compiler analyses and execute each line of source code in succession, without looking at the entire program.
Electronics and communication Engg .. VEC 40

Automatic gate opening system for parking lot

The advantage of interpreters is that they can execute a program immediately. Secondly programs produced by compilers run much faster than the same programs executed by an interpreter. However compilers require some time before an executable program emerges. Now as compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language.

5.3 Concept of cross complier


A cross compiler is similar to the compilers but we write a program for the target processor (like 8051 and its derivatives) on the host processors (like computer of x86). It means being in one environment you are writing a code for another environment is called cross development. And the compiler used for cross development is called cross compiler. So the definition of cross compiler is a compiler that runs on one computer but produces object code for a different type of computer.

5.4 Creating Your Own Application in Vision2


To create a new project in Vision2, you must: 1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device Database. 4. Create source files to add to the project. 5. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add the source files to the project. 6. Select Project - Options and set the tool options. Note when you select the target device from the Device Database all special options are set automatically. You typically only need to configure the memory map of your target hardware. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target.
Electronics and communication Engg .. VEC 41

Automatic gate opening system for parking lot

5.5 Debugging an Application in Vision2


To debug an application created using Vision2, you must: 1. Select Debug - Start/Stop Debug Session. 2. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the Output Window to execute to the main C function. 3. Open the Serial Window using the Serial #1 button on the toolbar. Debug your program using standard options like Step, Go, Break, and so on.

5.6 Window Files.


Now use from the menu Project Select Device for Target and select a CPU for your project. The Select Device dialog box shows the Vision2 device data base. Just select the microcontroller you use. We are using for our examples the Philips 80C51RD+ CPU. This selection sets necessary tool Options for the 80C51RD+ device and simplifies in this way the tool Configuration.

5.7 Building Projects and Creating a HEX Files


Typical, the tool settings under Options Target are all you need to start a new application. You may translate all source files and line the application with a click on the Build Target toolbar icon. When you build an application with syntax errors, Vision2 will display errors and warning messages in the Output Window Build page. A double click on a message line opens the source file on the correct location in a Vision2 editor window. Once you have successfully generated your application you can start debugging.

After you have tested your application, it is required to create an Intel HEX file to download the software into an EPROM programmer or simulator. Vision2 creates HEX files with each build process when Create HEX files under Options for Target Output is enabled. You may start your PROM programming utility after the make process when you specify the program under the option Run User Program #1.
Electronics and communication Engg .. VEC 42

Automatic gate opening system for parking lot

5.8 Embedded c
Use of embedded processors in passenger cars, mobile phones, medical equipment, aerospace systems and defense systems is widespread, and even everyday domestic appliances such as dish washers, televisions, washing machines and video recorders now include at least one such device.

Because most embedded projects have severe cost constraints, they tend to use low-cost processors like the 8051 family of devices considered in this book. These popular chips have very limited resources available most such devices have around 256 bytes (not megabytes!) of RAM, and the available processor power is around 1000 times less than that of a desktop processor. As a result, developing embedded software presents significant new challenges, even for experienced desktop programmers. If you have some programming experience - in C, C++ or Java - then this book and its accompanying CD will help make your move to the embedded world as quick and painless as possible.

Electronics and communication Engg .. VEC

43

Automatic gate opening system for parking lot

CHAPTER 6 SCHEMATIC DIAGRAM

Fig 6: Schematic Diagram

Electronics and communication Engg .. VEC

44

Automatic gate opening system for parking lot

6.1 Description:
Powersupply: The circuit uses standard power supply comprising of a step-down transformer from 230Vto 12V and 4 diodes forming a Bridge Rectifier that delivers pulsating dc which is then filtered by an electrolytic capacitor of about 470F to 1000F. The filtered dc being unregulated, IC LM7805 is used to get 5V DC constant at its pin no 3 irrespective of input DC varying from 9V to 14V. The input dc shall be varying in the event of input ac at 230volts section varies in the ratio of V1/V2=N1/N2.

The regulated 5V DC is further filtered by a small electrolytic capacitor of 10F for any noise so generated by the circuit. One LED is connected of this 5V point in series with a resistor of 330 to the ground i.e., negative voltage to indicate 5V power supply availability. The 12V point is used for other applications as on when required.

Standard connections to microcontroller: ATMEL series of 8051 family of micro controllers need certain standard connections. The actual number of the Micro controller could be 89C51 , 89C52, 89S51, 89S52, as regards to 20 pin configuration a number of 89C2051. The 4 set of I/O ports are used based on the project requirement. Every micro controller requires a timing reference for its internal program execution therefore an oscillator needs to be functional with a desired frequency to obtain the timing reference as t =1/f.

A crystal ranging from 2 to 20 MHz is required to be used at its pin number 18 and 19 for the oscillator. Typically 11.0592 MHz crystal is used in general for most of the circuits. Crystal

provides the reference frequency only and it is not a crystal oscillator as miss understood by many but it oscillates at 11.0592MHz. Two small value ceramic capacitors of 33pF each is used as a standard connection for the crystal as shown in the circuit diagram.

Electronics and communication Engg .. VEC

45

Automatic gate opening system for parking lot

Reset: Pin no 9 is provided with an RESET arrangement by a combination of an electrolytic capacitor and a register forming RC time constant. At the time of switch on, the capacitor gets charged, after charging it behaves as a full short circuit from the positive to the pin number 9. After the capacitor gets fully charged the current stops flowing and pin number 9 is pulled down by a 10k resistor to the ground. This arrangement of reset pin 9 going high initially and then to logic 0 i.e., low helps the program execution to start from the beginning. In absence of this the program execution could have taken place habitually anywhere from the program cycle. A pushbutton switch is connected across the capacitor so that at any given time as desired it can be pressed that discharges the capacitor and while released the capacitor starts charging again and then pin number 9 goes to high and then back to low, to enable the program execution from the beginning. This operation of high to low of the reset pin takes place in fraction of a second as decided by the time constant R and C. For example: A 10F capacitor and a 10k resistor would render a 100ms time to pin number 9 from logic high to low, there after the pin number 9 remains low.

OPERATION:
Connections: The output of the power supply which is 5v is connected to the 40th Pin of microcontroller and GND is connected to its 20th Pin. Pin 21- 28 of port2 of micro controller is connected to D0-D7 data pins of LCD. Pin10 of Port3.0 of microcontroller is connected to transistor Q7 (BC547) that drives a relay. The collector terminal of transistor Q6 is given to Port P1.0 of microcontroller. Pin37, 38, 39 of Port0 of microcontroller is connected to RS, RW, EN pins of LCD.

Electronics and communication Engg .. VEC

46

Automatic gate opening system for parking lot

Working: The project uses a pair of ultrasonic transducers comprising of 1 transmitter and 1 receiver. The transmitter can deliver 40 KHz ultrasonic sound while the maximum receiver is design to accept only 40KHz sound waves. One 555 timer U1 used as astable multivibrator with RC time constant formed out of RV1 ,R1, R2 & C2 that delivers at its output pin 3, 40KHz to drive the ultrasonic transmitter being amplified by Q1 & Q2. The receiver ultrasonic unit that is kept next to the transmitter shall thus be able to receive reflected 40KHz, once the pair faces any obstacle in front. The 40Khz so received by the ultrasonic receiver is further amplified by a two stage amplifier formed out of Q3 & Q4. The amplified AC signal of 40KHz is filtered in a voltage doubling circuit comprising of D3 & D4 that develops a voltage at Pin 2 of U2. This voltage is compared against a value preset by the variable resistor connected to non inverting input of U2 pin3. The voltage at Pin3 is so set that it is more than the pin2 i.e.,. inverting input of U2 used as a comparator in normal condition while no reflections takes place from the transmitter to the receiver by any obstacle faced ahead. The output of the comparator thus goes high at Pin6 of U2 hat drives 2 transistors Q5 and Q6 such that Pin1 of microcontroller goes low. In the event of any obstacle causing reflection results in the DC voltage at Pin2 to go higher than Pin3 such that the output at Pin6 goes low that results in Q6 collector going high in turn Pin1 of micro controller goes high. This change in logic state at Pin1 i.e. Port1.0 outputs logic high as per program at Port3.0 i.e. Pin 10 of microcontroller to drive the transistor Q7 which in turn activates the relay. The relay switches on the load, a swing motor is connected to main supply through NO contacts of the relay.

Electronics and communication Engg .. VEC

47

Automatic gate opening system for parking lot

CHAPTER 7 LAYOUT DIAGRAM

Fig.7: Layout Diagram


Electronics and communication Engg .. VEC 48

Automatic gate opening system for parking lot

CHAPTER 8 BILL OF MATERIALS


QTY PART-REFS Resistors 1 2 1 1 1 2 1 3 1 1 2 1 R1 R2,R3 R4 R5 R6 R7,R8 R9 R10,R11,R12 R13 R14 R15,R16 R17 100R 220R 33R 390K 470K 1.5K 12K 10K 100K 4.7K 390R 1K VALUE

Capacitors 1 1 1 1 1 2 1 C1 C2 C3 C4 C5 C6,C7 C8 0.01UF 680nF 0.22UF 0.1UF 560nF 33PF 10UF

Integrated Circuits
Electronics and communication Engg .. VEC 49

Automatic gate opening system for parking lot

1 1 1

U1 U2 U3

AT89S52 555 CA3140

IC Bases 1 2 40-PIN 8-PIN

Diodes 3 1 D1-D3 D4 1N4148 IN4007

Transistors 5 2 Q1-Q5 Q6,Q7 BC547 BC558

Miscellaneous 1 1 1 1 1 1 1 1 2 2 1 1 CRYSTAL LCD PCB-CONNECTOR RELAY SWING MOTOR RV1 POT FEMALE BURGE MALE BURGE MALE BURGE FEMALE BURG 11.0592MHz LM016L(16X2) CONN-H2(2 PIN) 12V 230V AC 10k 16-PIN 16 PIN 2-PIN 2-PIN

ULTRASONIC TRANSIMITTER ULTRASONIC RECEIVER


50

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

CHAPTER 9 CODING

9.1 Complier:

1. 2.

Click on the Keil Vision Icon on Desktop The following fig will appear

3. 4.

Click on the Project menu from the title bar Then Click on New Project

Electronics and communication Engg .. VEC

51

Automatic gate opening system for parking lot

5.

Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\

6. 7.

Then Click on Save button above. Select the component for u r project. i.e. Atmel
52

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

8.

Click on the + Symbol beside of Atmel

9.

Select AT89C51 as shown below

10. 11.

Then Click on OK The Following fig will appear


53

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

12. 13. 14.

Then Click either YES or NOmostly NO. Now your project is ready to USE. Now double click on the Target1, you would get another option Source group 1 as shown in next page.

Electronics and communication Engg .. VEC

54

Automatic gate opening system for parking lot

15.

Click on the file option from menu bar and select new.

16.

The next screen will be as shown in next page, and just maximize it by double clicking on its blue boarder.

17.

Now start writing program in either in EMBEDDED C or ASM.

Electronics and communication Engg .. VEC

55

Automatic gate opening system for parking lot

18.

For a program written in Assembly, then save it with extension . asm and for EMBEDDED C based program save it with extension .C

19.

Now right click on Source group 1 and click on Add files to Group Source.

Electronics and communication Engg .. VEC

56

Automatic gate opening system for parking lot

20.

Now you will get another window, on which by default EMBEDDED C files will appear.

21. 22. 23.

Now select as per your file extension given while saving the file Click only one time on option ADD. Now Press function key F7 to compile. Any error will appear if so happen.

Electronics and communication Engg .. VEC

57

Automatic gate opening system for parking lot

24. 25.

If the file contains no error, then press Control+F5 simultaneously. The new window is as follows

26. 27.

Then Click OK. Now click on the Peripherals from menu bar, and check your required port as shown in fig below.

Electronics and communication Engg .. VEC

58

Automatic gate opening system for parking lot

28.

Drag the port a side and click in the program file.

29. 30.

Now keep Pressing function key F11 slowly and observe. You are running your program successfully.

Electronics and communication Engg .. VEC

59

Automatic gate opening system for parking lot

9.2 SOURCE CODE


#include<reg52.h> sbit sense=P1^0; sbit motor=P3^0; sbit RS=P0^0; sbit RW=P0^1; sbit EN=P0^2;

void delay1() { int x,y; for(x=0;x<50;x++) for(y=0;y<2000;y++); } void main() { sense=1; motor=0; RS=0; RW=0; EN=0; lcd_port=0x00; lcd_init(); while(1) { if(sense==1) { lcd_cmd(0x80);
Electronics and communication Engg .. VEC 60

Automatic gate opening system for parking lot

lcd_string("ULTRASONIC PROX"); lcd_cmd(0xc0); lcd_string(" GATE OPENED "); motor = 1; delay1(); motor = 0; delay1(); delay1(); lcd_cmd(0xc0); lcd_string(" GATE CLOSED "); motor = 1; delay1(); motor = 0; } else if(sense==0) { lcd_cmd(0x80); lcd_string("ULTRASONIC PROX"); lcd_cmd(0xc0); lcd_string(" GATE CLOSED "); motor=0; } } } void lcd_init() { lcd_cmd(0x38); lcd_cmd(0x0c); lcd_cmd(0x06); //5x7 matrix lcd & 16x2 lcd // display on & curser off // shift the curser to right
61

// motor is on

//motor is off

// motor is on

//motor is off

Electronics and communication Engg .. VEC

Automatic gate opening system for parking lot

lcd_cmd(0x01); lcd_cmd(0x80); }

// clear the lcd // lcd 1st line starting position

Void lcd_cmd(unsigned char cmd) { lcd_port=cmd; // put command on data bus RS=0; RW=0; EN=1; EN=0; } // rs = 0 for command //rw = 0 writing //make enable pin high // make eneble pin low

void lcd_data(unsigned char data1) { lcd_port=data1; RS=1; RW=1; EN=1; EN=0; } // put data on data bus

// rs = 1 for data //rw = 0 writing //make enable pin high // make eneble pin low

void lcd_string(unsigned char t) // display strings on lcd { while(t) { lcd_data(t); } }


Electronics and communication Engg .. VEC 62

Automatic gate opening system for parking lot

void delay(unsigned int i) { unsigned int j,k; for(j=0;j<i;j++) { for(k=0;k<10;k++) { ; } } }

CHAPTER 10 HARDWARE TESTING


10.1 Continuity test:

In electronics, a continuity test is the checking of an electric circuit to see if current flows (that it is in fact a complete circuit). A continuity test is performed by placing a small voltage (wired in series with an LED or noise-producing component such as a piezoelectric speaker) across the chosen path. If electron flow is inhibited by broken conductors, damaged components, or excessive resistance, the circuit is "open".

Devices that can be used to perform continuity tests include multi meters which measure current and specialized continuity testers which are cheaper, more basic devices, generally with a simple light bulb that lights up when current flows.

Electronics and communication Engg .. VEC

63

Automatic gate opening system for parking lot

An important application is the continuity test of a bundle of wires so as to find the two ends belonging to a particular one of these wires; there will be a negligible resistance between the "right" ends, and only between the "right" ends.

This test is the performed just after the hardware soldering and configuration has been completed. This test aims at finding any electrical open paths in the circuit after the soldering. Many a times, the electrical continuity in the circuit is lost due to improper soldering, wrong and rough handling of the PCB, improper usage of the soldering iron, component failures and presence of bugs in the circuit diagram. We use a multi meter to perform this test. We keep the multi meter in buzzer mode and connect the ground terminal of the multi meter to the ground. We connect both the terminals across the path that needs to be checked. If there is continuation then you will hear the beep sound.

10.2 Power on test:

This test is performed to check whether the voltage at different terminals is according to the requirement or not. We take a multi meter and put it in voltage mode. Remember that this test is performed without microcontroller. Firstly, we check the output of the transformer, whether we get the required 12 v AC voltage.

Then we apply this voltage to the power supply circuit. Note that we do this test without microcontroller because if there is any excessive voltage, this may lead to damaging the controller. We check for the input to the voltage regulator i.e., are we getting an input of 12v and an output of 5v. This 5v output is given to the microcontrollers 40th pin. Hence we check for the voltage level at 40th pin. Similarly, we check for the other terminals for the required voltage. In this way we can assure that the voltage at all the terminals is as per the requirement

Electronics and communication Engg .. VEC

64

Automatic gate opening system for parking lot

CHAPTER 11 RESULT

CHAPTER 12 CONCLUSION

CHAPTER 13 BIBLIOGRAPHY
TEXT BOOKS REFERED 1. The 8051 Microcontroller and Embedded systems by Muhammad Ali Mazidi and Janice Gillispie Mazidi , Pearson Education. 2. ATMEL 89S52 Data Sheets.

Electronics and communication Engg .. VEC

65

Automatic gate opening system for parking lot

WEBSITES www.atmel.com www.beyondlogic.org www.wikipedia.org www.howstuffworks.com

Electronics and communication Engg .. VEC

66

You might also like