You are on page 1of 62

SMART PARKING SYSTEM

A Major Project Report in partial fulfillment for the award of the degree of

B.TECH
IN ELECTRONICS AND COMMUNICATIONS ENGINEERING

Guide:
Prof. MONICA GUPTA

Submitted by:
RAMIT VERMA ANSHUL GOEL NIKHIL RASTOGI ANIMESH GUPTA

BHARATI VIDYAPEETH'S COLLEGE OF ENGINEERING A-4, PASCHIM VIHAR,ROHTAK ROAD,NEW DELHI-63 NEW DELHI

BATCH 2008-2012

ABSTRACT

CERTIFICATE

Thi s is to certi fy that the proj e ct report e nt it l e d SMART PARKING SYSTEM done by R AM IT VER M A (15 3115 28 08 ), ANSHUL GOEL (1591152808), NIKHIL RASTOGI (167115 28 08 ) and ANIM ESH GUPTA (1761152808) i s an au the nt i c work carrie d out by them at BHAR ATI VIDYAPEETH S COLLEGE OF ENGINEER IN G unde r my gui dance .

M rs . M oni ca Gu pt a De part me nt of El ect roni cs and C ommu ni cat i on BVC OE, Ne w De lhi

ACKNOWLEDGEMENT

Wit h imme ns e ple as ure, we wou ld like t o pres e nt this maj or proj e ct re port at Bharat i Vidyape et h s C ol le ge Of Eng i ne e ri ng. It has bee n an enri chi ng experie nce f or us to u nderg o the s ame at BVC OE, whi ch woul d not have pos si bl e wit hou t t he g oodwi l l and su pport of the peopl e arou nd. As s tude nt s of Bharat i Vidyape et h s Coll eg e Of Engi ne e ri ng , we wou ld like t o expre ss ou r since re t hanks t o all those who he lped us. We woul d li ke to give ou r he art i ly t hanks t o Mrs . Monica Gupta, Project Mentor for gui di ng ou r way throu ghou t.

R ami t Verma(15 3115 28 08 )

Ans hul Goe l (15 9115 28 08 )

Nikhi l Rast og i (167115 28 08 )

Ani me s h Gupt a(176115 28 08 )

TABLE OF CONTENTS
S.NO Topics Page No.

Intro to project(A brief description, functional diagram) Working of the project (Non technical) Hardware description (circuit diagram) List of components Microcontroller Dc gear motor(+h bridge working) Reed IR sensor + comparator Lcd Motor Optocoupler Other circuitry (reset, clock description, rectifier circuit, buzzer) WORKING(detailed working of the project explaining the hardware and all the connections/peripherals) Program Flow(code part) Software used(keil, flash magic)

LIST OF FIGURES
S.NO NAME PG NO

CHAPTER 1 INTRODUCTION TO PROJECT

SMART PARKING CONTROL WITH LCD DISPLAY

In this project we show the automation of the smart parking system. In this project when any car enters the parking area then infra-red sensors senses the car. As soon as infra-red sensor senses the car then Automatic door lifts up automatically and shuts down immediately as soon as car enters the parking palace. Door is open only when any empty space is available in the parking area. If the parking space is available then door opens & if there is no parking space then LCD displays the message of NO SPACE. Also, if the space is available in the parking then the LCD displays the closet vacant parking space by showing GO TO 8 OR any number/slot which is available. Total number of parking space is occupied is shown by the different LEDs. The project will show 8 LEDs for the 8 different parking slots. AT89s51 microcontroller is used as a main processor. Magnetic sensors (Reed sensor) for monitor of the 8 different positions of the parking slot. One 2*16 LCD to display the different messages. Two infra-red sensor at the entry and exit gate. Two slow speed motor for opening and closing of the gate.

10

11

CHAPTER 2 WORKING OF THE PROJECT

12

PROJECT DESCRIPTION
In this project we use a one step down transformer to step down the voltage from 220 volt ac to 9 volt ac. Output of the step down transformer is further connected to the rectifier circuit. Rectifier circuit converts the ac voltage into dc voltage. For this purpose we use two diodes as a rectifier. Output of the rectifier is further connected to the filter capacitor circuit. Capacitor converts the pulsating dc into smooth DC. Output of the rectifier is now connected to the 7805 regulator circuit. Regulator provides a 5 volt regulated output to the micro controller circuit. Pin no 40 of the controller is connected to the positive supply. Pin no 20 is connected to the ground pin. Pin no 9 is reset pin and is connected to external capacitor and resistance to provide a power on reset logic. Pin no 18 and 19 is connected to the external crystal oscillator to provide a clock pulse to the controller circuit. Input infra-red sensor is connected to the p3.0 via op-amp circuit. Here we use IC LM 339 to compare the input signal from photodiode and reconnected to the micro-controller .In this project we use two infra-red sensors, one for the entry and second for the exit. As the beam is interrupted, photodiode provides a signal to the op-amp and then connected to the micro-controller circuit. At this time micro-controller circuit checks the availability of the parking space. If the space is available then micro-controller shows the message on the LCD. If the space is available then LCD shows the space message and immediate opens the door and closes the door after some time. . For monitoring parking position we use reed sensors for activation. When the reed sensor is activated then sensor provides a signal to the controller and controller switches on the specific LED also. For opening and closing the door we use two slow speed motors. Working voltage of these motors are 9 volt to 12 volt dc. We use two power sources in this project. One for the motors and second for the controller circuit. For controlling a dc motor we use H bridge circuit. In this project we use four transistor circuits to control the movement of dc motor for forward and reverse movement.

13

Circuit Diagram:

14

Working of project:
In this project we use one step down transformer to step down the voltage from 220 volt ac to 9 volt ac. Output of the step down transformer is further connected to the rectifier circuit. Rectifier circuit converts the ac voltage into dc voltage. For this purpose we use two diodes as a rectifier. Output of the rectifier is further connected to the filter capacitor circuit. Capacitor converts the pulsating dc into smooth DC. Output of the rectifier is now connected to the 7805 regulator circuit. Regulator provides a 5 volt constant to the micro controller circuit. Pin no 40 of the controller is connected to the positive supply. Pin no 20 is connected to the ground pin. Pin no 9 is reset pin and connected to external capacitor and resistance to provide a power on reset logic. Pin no 18 and 19 is connected to the external crystal oscillator to provide a clock pulse to the controller circuit. Input infra red sensor is connected to the p2.0 via op-amp circuit. Here we use IC LM 339 to compare the input signal from photodiode and reconnected to the micro-controller . As the beam is interrupted, photodiode provides a signal to the op-amp and then connected to the microcontroller circuit. At this time micro-controller circuit checks the availability of the parking space. If the space is available then micro-controller shows the message on the LCD. If the space is available then lcd shows the space message and immediate opens the door and closes the door after some time. For parking position monitor we use reed sensors for activation. When the reed sensor is activated then sensor provides a signal to the controller and controller switches on a specific LED also. For opening and closing the door we use slow speed dc gear motor. Working voltage of the motors is 9 volt to 12 volt dc. We use two power sources in this project. One for the motor and second for the controller circuit. For controlling a dc motor we use H bridge circuit. In this project we use four transistor circuits to control the movement of dc motor for forward and reverse movement.

15

Collector of both the transistors is connected to the positive supply 9 volt. This 9 volt supply is for the DC motor. If we use 12 volt motor then we use 12 volt dc supply here. Emitter of both the transistors is connected to the DC motor. Emitter of the PNP transistor is connected to the emitter of NPN transistor. Collector of both the PNP transistor is connected to the ground potential. Base point of both transistors is joined together. On this point we give a voltage.

16

17

If we give a positive voltage to the base of left junction and negative voltage to the right junction then motor moves to one direction. Because due to positive on base NPN is on and due to negative on base PNP is on. If left side NPN is on and right side PNP is on then motor moves to the one direction. If the voltage is reverse on the base point then motor moves to the reverse direction.

Motor moves to the reverse direction because base voltage is changed . Now left NPN and right PNP are on and motor moves to the reverse direction. Now when we attach the H bridge to the logical output of the micro-controller. So to interface the micro-controller with this H bridge we must connect a OPTOCOUPLER with the controller.

18

CHAPTER 3

SOFTWARE DESCRIPTION

19

HOW TO PROGRAM BLANK CHIP


First of all we select and open the assembler and wrote a program code in the file. After wrote a software we assemble the software by using internal assembler of the 8051 editor. If there is no error then assembler assembles the software a b d 0 error is show the output window.

20

Now assembler generates an ASM file and HEX file. This hex file is useful for us to program the blank chip .Now we transfer the hex code into the blank chip with the help of serial programmer kit. In the programmer we insert a blank chip 0f 89s52 series. These chips are multi time programmable chip. This programming kit is separately available in the market and we transfer the hex code into blank chip with the help of the serial programmer kit

21

PROGRAMMING DETAILS of THE PARKING CONTROLLER SYSTEM

IN THIS PROJECT WE USE ONE LCD TO DISPLAY THEPARKING POSITION AT EVERY TIME WHEN CAR ENTERS IN THE PARKING SYSTEM.

So we use lcd routine to display all the logic on the lcd. lcd EN RS RW d7 equ equ equ equ EQU p0 p2.7 p2.6 p2.5 P0.7

In this project we connect the lcd on the port P0. we use 8 data line of the lcd to the port p0. Note that p0.0 is connected to the d0 . Data pins are started from pin no 7 to pin no 14 of the lcd.

22

Enable pin of the lcd is connected to the p2.7 , Rs pin is connected to the p2.6 and RW pin is connected to the p2.5. First of all we call the lcd routine. mov lcd,#00h mov p3,p1 acall lcd216 acall lcdclr acall rethome acall doncoff acall wel-message wel-message:: MOV DPTR,#TABLE1 ACALL WRITE RET first of all we get the position of the sensor and transfer this data on the led display through data transfer logic. At the same time we display the first welcome message on the lcd. By calling lcd routine. In the lcd rountin we use two type of function, one is command and second is write. So in starting we display the first routine to display PARKING STATION. So in this project we use sensor on the port p1 and we transfer the data of the port p1 to port p3 and call basic rountie of the lcd protocol. Like lcd216 in the routine we transfer the 38 h data in the lcd. This 38 h

23

data is for 2by 16 character lcd.Then rethome and doncoff is the basic routine of the lcd . We use this type of routine in the starting of the program. Now after this we are waiting for the car. When car enter in the parking system then first infra red senor sense the signal and check the position. If the space is available then it display the go to space--- , and if there is no space then display NO-SPACE option. next: mov p3,p1 jb p2.0,enter sjmp next Our program is waiting for the input signal on p2.0, if the interruption is there then we call a ENTER function otherwise sensor position is display on the port p3 via l.e.d. enter: CLR P2.1 ; BUZZER ON

ACALL DELAY2 SETB P2.1 mov p3,p1 mov a,p1 cjne a,#00000000b,dooropen acall close acall nospace ACALL DELAY2 ; BUZZEROFF

24

When sensor give a input signal to the controller then first of all buzzer is on and after some delay buzzer is again off. Now we transfer the data of the sensor in accumulator and compares with the occupied position . If the all the sensors are occupied then all the sensor shows a 0 status. If all the sensors shows a 0 position then it means we call a door close option, and if all the sensor is no on 0 position then it calls the door open logic. In the case of door close function we call a NO SPACE display on the lcd by calling no space option. If the space is available then we open the door and then close the door Door open: open the door clr p2.3 setb p2.4 acall delay setb p2.3 setb p2.4 acall delay setb p2.3 clr p2.4 acall delay setb p2.3 setb p2.4 ret

25

Our door motor is connected to the p2.3 and p2.4 so we use the routine by providing a 0 and 1 signal to the these pins . In the scan logic first of all we check the sensor no 8, if this sensor is vacant then we call a message no 8 on the display and if this sensor is occupied then we go to next sensor position SCAN: mov P1.7,next ACALL MSG8 RET In the next we again check the sensor no 6 and occupied no 7, if this sensor is vacant then we call a message no 7 , if this sensor is also occupied then we go the next sensor position next: mov P1.6,F2 ACALL MSG7 RET after scan and display the message program return back to the original position and again check the next car for infra red sensor. LCD216: MOV A,#38H ;FORCES 2 X 16 MATRIX

ACALL COMMAND RET LCDCLR: MOV A,#01H ;CLEAR DISPLAY SCREEN

ACALL COMMAND

26

RET

RETHOME: MOV A,#02H

;RETURN HOME

ACALL COMMAND RET DONCOFF: MOV A,#0CH ACALL COMMAND RET FCBFL: MOV A,#80H ACALL COMMAND RET FCBSL: MOV A,#0C0H ACALL COMMAND RET COMMAND: MOV LCD,A ;INSTRUCTION COMMAND TO LCD ;CURSOR AT BEGINNING OF IIND LINE ;CURSOR AT BEGINNING OF IST LINE ;DISPLAY ON CURSOR OFF

27

CLR RS CLR RW SETB EN CLR EN RET

WRITE: CLR A

;WRITE FROM DATATABLES

MOVC A,@A+DPTR JZ BACK ACALL DISPLAY INC DPTR SJMP WRITE BACK: RET

DISPLAY: MOV LCD,A SETB RS CLR RW SETB EN

;WRITE COMMAND TO LCD

28

CLR EN RET

TABLE1: DB 'P','A','R','K','I','N','G','',' ','S','T','A','T','I','O','N', TABLE2: DB 'G','O','-','-','-','T','O',' ', TABLE3: DB '*','*','*','N','O','S','P','A','C','E','*','*','*', TABLE4: DB 'G','O','-','-','-','T','O','*','*','*','1', TABLE5: DB 'G','O','-','-','-','T','O','*','*','*','2', TABLE6: DB 'G','O','-','-','-','T','O','*','*','*','3', TABLE7: DB 'G','O','-','-','-','T','O','*','*','*','4', TABLE8: DB 'G','O','-','-','-','T','O','*','*','*','5', TABLE9: DB 'G','O','-','-','-','T','O','*','*','*','6', TABLE10: DB 'G','O','-','-','-','T','O','*','*','*','7', TABLE11: DB 'G','O','-','-','-','T','O','*','*','*','8', First of all we get the position of the sensor and transfer this data on the led display through data transfer logic. At the same time we display the first welcome message on the lcd. By calling lcd routine. In the lcd rountine we use two type of function, one is command and second is write. So in starting we display the first routine to display PARKING STATION. In this project we use microcontroller for all the functions.s . So we must program the controller before insert in the hardware unit. So for programming we use 8051 ide software. This software is free ware and available on the internet

29

This special software provides a wonderful atmosphere of programming. We written our source code in this software and then complier compile this software and converted into hex code. We transfer this hex code into blank ic with the help of the serial port programmer. IN the serial port programmer firstly we select the ic then we transfer the code into the blank IC.

30

When our source code is complete then with the help of this software we convert this code in to hex code. This conversion is done automatically by the software

31

CHAPTER 4: AT89s52 MICROCONTROLLER DESCRIPTION

32

AT89S52
Features Compatible with MCS-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 10,000 Write/Erase Cycles 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 Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer Power-off Flag Fast Programming Time Flexible ISP Programming (Byte and Page Mode)

Description
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 nonvolatile 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 reprogrammed in-system or by a conventional nonvolatile 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 con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.

33

Pin Description

34

Block Diagram

35

Pin Description
VCC Supply voltage. GND Ground. 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. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes dur-ing program verification. External pull-ups are required during program verification. 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 inter-nal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the follow-ing table. Port 1 also receives the low-order address bytes during Flash programming and verification. 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 pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 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 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 pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 receives some control signals for Flash programming and verification. Port 3 also serves the functions of various special features of the AT89S52, as shown in the following table. 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. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. 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. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped dur-ing 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.

36

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 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 (VPP) during Flash programming. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier. Special Function Registers A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 5-1. Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0. Timer 2 Registers: Control and status bits are contained in registers T2CON (shown in Table 5- 2) and T2MOD (shown in Table 10-2) for Timer 2. The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit autoreload mode. Interrupt Registers: The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.

Instruction Set Summary


Arithmetic Operations Mnemonic Description Byte Cycle

ADD A, Rn Add register to accumulator 1 1 ADD A, direct Add direct byte to accumulator 2 1 ADD A, @Ri Add indirect RAM to accumulator 1 1 ADD A, data Add immediate data to accumulator 2 1 ADDC A, Rn Add register to accumulator with carry flag 1 1 ADDC A, direct Add direct byte to A with carry flag 2 1

37

ADDC A, @Ri Add indirect RAM to A with carry flag 1 1 ADDC A, #data Add immediate data to A with carry flag 2 1 SUBB A, Rn Subtract register from A with borrow 1 1 SUBB A, direct Subtract direct byte from A with borrow 2 1 SUBB A,@Ri Subtract indirect RAM from A with borrow 1 1 SUBB A, data Subtract immediate data from A with borrow 2 1 INC A Increment accumulator 1 1 INC Rn Increment register 1 1 INC direct Increment direct byte 2 1 INC @Ri Increment indirect RAM 1 1 DEC A Decrement accumulator 1 1 DEC Rn Decrement register 1 1 DEC direct Decrement direct byte 2 1 DEC @Ri Decrement indirect RAM 1 1 INC DPTR Increment data pointer 1 2 MUL AB Multiply A and B 1 4 DIV AB Divide A by B 1 4 DA A Decimal adjust accumulator 1 1

Logic Operations Mnemonic Description Byte Cycle

ANL A, Rn AND register to accumulator 1 1 ANL A, direct AND direct byte to accumulator 2 1 38

ANL A,@Ri AND indirect RAM to accumulator 1 1 ANL A, #data AND immediate data to accumulator 2 1 ANL direct, A AND accumulator to direct byte 2 1 ANL direct, #data AND immediate data to direct byte 3 2 ORL A, Rn OR register to accumulator 1 1 ORL A, direct OR direct byte to accumulator 2 1 ORL A,@Ri OR indirect RAM to accumulator 1 1 ORL A, #data OR immediate data to accumulator 2 1 ORL direct, A OR accumulator to direct byte 2 1 ORL direct, #data OR immediate data to direct byte 3 2 XRL A, Rn Exclusive OR register to accumulator 1 1 XRL A direct Exclusive OR direct byte to accumulator 2 1 XRL A,@Ri Exclusive OR indirect RAM to accumulator 1 1 XRL A, #data Exclusive OR immediate data to accumulator 2 1 XRL direct, A Exclusive OR accumulator to direct byte 2 1 XRL direct, #data Exclusive OR immediate data to direct byte 3 2 CLR A Clear accumulator 1 1 CPL A Complement accumulator 1 1 RL A Rotate accumulator left 1 1 RLC A Rotate accumulator left through carry 1 1 RR A Rotate accumulator right 1 1 RRC A Rotate accumulator right through carry 1 1

39

SWAP A Swap nibbles within the accumulator 1 1 Data Transfer *) MOV A, ACC is not a valid instruction Mnemonic Description Byte Cycle MOV A, Rn Move register to accumulator 1 1 MOV A, direct *) Move direct byte to accumulator 2 1 MOV A,@Ri Move indirect RAM to accumulator 1 1 MOV A, #data Move immediate data to accumulator 2 1 MOV Rn, A Move accumulator to register 1 1 MOV Rn, direct Move direct byte to register 2 2 MOV Rn, #data Move immediate data to register 2 1 MOV direct, A Move accumulator to direct byte 2 1 MOV direct, Rn Move register to direct byte 2 2 MOV direct, direct Move direct byte to direct byte 3 2 MOV direct,@Ri Move indirect RAM to direct byte 2 2 MOV direct, #data Move immediate data to direct byte 3 2 MOV @Ri, A Move accumulator to indirect RAM 1 1 MOV @Ri, direct Move direct byte to indirect RAM 2 2 MOV @Ri, #data Move immediate data to indirect RAM 2 1 MOV DPTR, #data16 Load data pointer with a 16-bit constant 3 2 MOVC A,@A + DPTR Move code byte relative to DPTR to accumulator 1 2 MOVC A,@A + PC Move code byte relative to PC to accumulator 1 2

40

MOVX A,@Ri Move external RAM (8-bit addr.) to A 1 2 MOVX A,@DPTR Move external RAM (16-bit addr.) to A 1 2 MOVX @Ri, A Move A to external RAM (8-bit addr.) 1 2 MOVX @DPTR, A Move A to external RAM (16-bit addr.) 1 2 PUSH direct Push direct byte onto stack 2 2 POP direct Pop direct byte from stack 2 2 XCH A, Rn Exchange register with accumulator 1 1 XCH A, direct Exchange direct byte with accumulator 2 1 XCH A,@Ri Exchange indirect RAM with accumulator 1 1 XCHD A,@Ri Exchange low-order nibble indir. RAM with A 1 1

Boolean Variable Manipulation Program and Machine Control Mnemonic Description Byte Cycle CLR C Clear carry flag 1 1 CLR bit Clear direct bit 2 1 SETB C Set carry flag 1 1 SETB bit Set direct bit 2 1 CPL C Complement carry flag 1 1 CPL bit Complement direct bit 2 1 ANL C, bit AND direct bit to carry flag 2 2 ANL C, /bit AND complement of direct bit to carry 2 2

41

ORL C, bit OR direct bit to carry flag 2 2 ORL C, /bit OR complement of direct bit to carry 2 2 MOV C, bit Move direct bit to carry flag 2 1 MOV bit, C Move carry flag to direct bit 2 2 ACALL addr11 Absolute subroutine call 2 2 LCALL addr16 Long subroutine call 3 2 RET Return from subroutine 1 2 RETI Return from interrupt 1 2 AJMP addr11 Absolute jump 2 2 LJMP addr16 Long jump 3 2 SJMP rel Short jump (relative addr.) 2 2 JMP @A + DPTR Jump indirect relative to the DPTR 1 2 JZ rel Jump if accumulator is zero 2 2 JNZ rel Jump if accumulator is not zero 2 2 JC rel Jump if carry flag is set 2 2 JNC rel Jump if carry flag is not set 2 2 JB bit, rel Jump if direct bit is set 3 2 JNB bit, rel Jump if direct bit is not set 3 2 JBC bit, rel Jump if direct bit is set and clear bit 3 2 CJNE A, direct, rel Compare direct byte to A and jump if not equal 3 2

42

Mnemonic Description Byte Cycle CJNE A, #data, rel Compare immediate to A and jump if not equal 3 2 CJNE Rn, #data rel Compare immed. to reg. and jump if not equal 3 2 CJNE @Ri, #data, rel Compare immed. to ind. and jump if not equal 3 2 DJNZ Rn, rel Decrement register and jump if not zero 2 2 DJNZ direct, rel Decrement direct byte and jump if not zero 3 2 NOP No operation 1 1

43

CHAPTER 5:

HARDWARE DESCRIPTION

44

Components Description
STEP DOWN TRANSFORMER Step down transformer from 220 volt Ac to 9-0-9 ac. We use step down transformer to step down the voltage from 220 to 9 volt ac. This AC is further connected to the rectifier circuit for AC to DC conversion. Transformer current rating is 750 mA.

DIODE
In this project we use IN 4007 diode as a rectifier. IN 4007 is special diode to convert the AC into DC

In this project we use two diode rectifiers. Here we use full wave rectifier. Output of rectifier is pulsating DC. To convert the pulsating dc into smooth dc we use Electrolytic capacitor as a main filter. Capacitor converts the pulsating dc into smooth dc and this DC is connected to the Regulator circuit for Regulated 5 volt DC.

45

Pin no 40 of the controller is connected to the positive supply. Pin no 20 is connected to the ground. Pin no 9 is connected to external resistor capacitor to provide a automatic reset option when power is On.

46

Reset Circuitry Pin no 9 of the controller is connected to the reset circuit. On the circuit we connect one resistor and capacitor circuit to provide a reset option when power is on. As soon as you give the power supply the 8051 doesnt start. You need to restart for the microcontroller to start. Restarting the microcontroller is nothing but giving a Logic 1 to the reset pin at least for the 2 clock pulses. So it is good to go for a small circuit which can provide the 2 clock pulses as soon as the microcontroller is powered. This is not a big circuit we are just using a capacitor to charge the microcontroller and again discharging via resistor.

47

Crystal Pin no 18 and 19 is connected to external crystal oscillator to provide a clock to the circuit. Crystals provide the synchronization of the internal function and to the peripherals. Whenever ever we are using crystals we need to put the capacitor behind it to make it free from noises. It is good to go for a 33pf capacitor.

We can also resonators instead of costly crystal which are low cost and external capacitor can be avoided. But the frequency of the resonators varies a lot. And it is strictly not advised when used for communications projects.

48

Hardware Description Opto-Coupler is a special optically isolated device to interface the input with output using light. OptoCoupler provide an electrical isolation between the input and output circuit. Opto-coupler provides isolation between the two power supplies. Microcontroller power supply is 5 volt dc and motor supply is varying from 9volt to 12 volt dc. With the help of the microcontroller we provide an optical isolation between two power supply

In Opto-coupler there is one input and one output and there is no connection between input and output. On input point there is one infra red l.e.d. cathode point of the l.e.d is connected to the resistor R1 and further connected to the microcontroller ports. In this project we use one dc motor, so we use One H Bridge circuit with two Opto-coupler. LCD Frequently, an 89s52 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 89s52 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively. 44780 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).

49

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 sould 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. AN EXAMPLE HARDWARE CONFIGURATION As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with. For the sake of this tutorial, we are going to use an 8-bit data bus--so we'll be using 11 of the 8051's I/O pins to interface with the LCD. Let's draw a sample psuedo-schematic of how the LCD will be connected to the 8051.

As you can see, we've established a 1-to-1 relation between a pin on the 8051 and a line on the 44780 LCD. Thus as we write our assembly program to access the LCD, we are going to equate constants to the 8051 ports so that we can refer to the lines by their 44780 name as opposed to P0.1, P0.2, etc. Let's go ahead and write our initial equates: DB0 EQU P1.0 DB1 EQU P1.1 DB2 EQU P1.2

50

DB3 EQU P1.3 DB4 EQU P1.4 DB5 EQU P1.5 DB6 EQU P1.6 DB7 EQU P1.7 EN EQU P3.7 RS EQU P3.6 RW EQU P3.5 DATA EQU P1 Having established the above equates, we may now refer to our I/O lines by their 44780 name. For example, to set the RW line high (1), we can execute the following insutrction: SETB RW WRITING TEXT TO THE LCD Now we get to the real meat of what we're trying to do: All this effort is really so we can display text on the LCD. Really, we're pretty much done. Once again, writing text to the LCD is something we'll almost certainly want to do over and over--so let's make it a subroutine. WRITE_TEXT: SETB RS MOV DATA,A SETB EN CLR EN LCALL WAIT_LCD RET The WRITE_TEXT routine that we just wrote will send the character in the accumulator to the LCD which will, in turn, display it. Thus to display text on the LCD all we need to do is load the accumulator with the byte to display and make a call to this routine. A "HELLO WORLD" PROGRAM Now that we have all the component subroutines written, writing the classic "Hello World" program-which displays the text "Hello World" on the LCD is a relatively trivial matter. Consider: LCALL INIT_LCD LCALL CLEAR_LCD MOV A,#'H' LCALL WRITE_TEXT MOV A,#'E' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'L'

51

LCALL WRITE_TEXT MOV A,#'O' LCALL WRITE_TEXT MOV A,#' ' LCALL WRITE_TEXT MOV A,#'W' LCALL WRITE_TEXT MOV A,#'O' LCALL WRITE_TEXT MOV A,#'R' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'D' LCALL WRITE_TEXT The above "Hello World" program should, when executed, initialize the LCD, clear the LCD screen, and display "Hello World" in the upper left-hand corner of the display.

H Bridge

An H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H bridges are available as integrated circuits, or can be built from discrete components. The term H Bridge is derived from the typical graphical representation of such a circuit. An H bridge is built with four switches (solid-state or mechanical). When the switches S1 and S4 (according to the first

52

figure) are closed (and S2 and S3 are open) a positive voltage will be applied across the motor. By opening S1 and S4 switches and closing S2 and S3 switches, this voltage is reversed, allowing reverse operation of the motor. Using the nomenclature above, the switches S1 and S2 should never be closed at the same time, as this would cause a short circuit on the input voltage source. The same applies to the switches S3 and S4. This condition is known as shoot-through. The H-bridge arrangement is generally used to reverse the polarity of the motor, but can also be used to 'brake' the motor, where the motor comes to a sudden stop, as the motor's terminals are shorted, or to let the motor 'free run' to a stop, as the motor is effectively disconnected from the circuit. The following table summarizes operation, with S1-S4 corresponding to the diagram above.

S1

S2

S3

S4

Result

Motor moves right

Motor moves left

Motor free runs

Motor brakes

Motor brakes

Construction: A solid-state H bridge is typically constructed using opposite polarity devices, such as PNP BJTs or P-channel MOSFETs connected to the high voltage bus and NPN BJTs or N-channel MOSFETs connected to the low voltage bus. The most efficient MOSFET designs use N-channel MOSFETs on both the high side and low side because they typically have a third of the ON resistance of P-channel MOSFETs. This requires a more complex design since the gates of the high side MOSFETs must be driven positive with respect to the DC supply rail. However, many integrated circuit MOSFET drivers include a charge pump within the device to achieve this.

53

Reed Sensor
The reed switch is an electrical switch operated by an applied magnetic field. It was invented at Bell Telephone Laboratories in 1936 by W. B. Ellwood. It consists of a pair of contacts on ferrous metal reeds in a hermetically sealed glass envelope. The contacts may be normally open, closing when a magnetic field is present, or normally closed and opening when a magnetic field is applied. The switch may be actuated by a coil, making a reed relay, or by bringing a magnet near to the switch. Once the magnet is pulled away from the switch, the reed switch will go back to its original position. An example of a reed switch's application is to detect the opening of a door, when used as a proximity switch for a burglar alarm.

A Reed Sensor is an omnipolar, magnetically activated switch, which means a magnet can approach it from any angle, with either pole. Several possible operating methods are shown below. The reed switch contains a pair (or more) of magnetizable, flexible, metal reeds whose end portions are separated by a small gap when the switch is open. The reeds are hermetically sealed in opposite ends of a tubular glass envelope.

Reed switch diagrams from Ellwood's patent, U.S. Patent 2,264,746, Electromagnetic switch A magnetic field (from an electromagnet or a permanent magnet) will cause the reeds to come together, thus completing an electrical circuit. The stiffness of the reeds causes them to separate, and open the circuit, when the magnetic field ceases. Another configuration contains a non-ferrous normally-closed contact that opens when the ferrous normally-open contact closes. Good electrical contact is assured by plating a thin layer of non-ferrous precious metal over the flat contact portions of the reeds; low-

54

resistivity silver is more suitable than corrosion-resistant gold in the sealed envelope. There are also versions of reed switches with mercury "wetted" contacts. Such switches must be mounted in a particular orientation otherwise drops of mercury may bridge the contacts even when not activated. Since the contacts of the reed switch are sealed away from the atmosphere, they are protected against atmospheric corrosion. The hermetic sealing of a reed switch make them suitable for use in explosive atmospheres where tiny sparks from conventional switches would constitute a hazard. One important quality of the switch is its sensitivity, the amount of magnetic field necessary to actuate it. Sensitivity is measured in units of Ampere-turns, corresponding to the current in a coil multiplied by the number of turns. Typical pull-in sensitivities for commercial devices are in the 10 to 60 AT range. The lower the AT, the more sensitive the reed switch. Also, smaller reed switches, which have smaller parts, are more sensitive to magnetic fields, so the smaller the reed switch's glass envelope is, the more sensitive it is. In production, a metal reed is inserted in each end of a glass tube and the end of the tube heated so that it seals around a shank portion on the reed. Infrared-absorbing glass is used, so an infrared heat source can concentrate the heat in the small sealing zone of the glass tube. The thermal coefficient of expansion of the glass material and metal parts must be similar to prevent breaking the glass-to-metal seal. The glass used must have a high electrical resistance and must not contain volatile components such as lead oxide and fluorides. The leads of the switch must be handled carefully to prevent breaking the glass envelope.

OPERATING METHODS PERPENDICULAR MAGNET TRAVEL This method maximizes air gap.

PARALLEL MAGNET TRAVEL Up to three operations possible with one magnet.

55

NOSE-TO-NOSE ACTIVATION Both ends of the magnet work equally well.

ROTATIONAL MAGNET TRAVEL Multi-pole ring magnets can be used to achieve a larger number of operations per rotation.

CONCLUSION

We found this project to be very intense and interesting. We managed to first implement each module separately and then combined them to form one bigger unit. We ended up getting all of the instructions we

56

wished to implement. We also simulated some of the instructions on the hardware. At the end, the 8-bit Microprocessor was successfully designed and simulated using Xilinx ISE.

APPENDIX
lcd equ EN equ RS equ p0 p2.7 p2.6

57

RW equ d7 EQU mov p3,p1

p2.5 P0.7

mov lcd,#00h acall lcd216 acall lcdclr acall rethome acall doncoff acall wel-message wel-message:: MOV DPTR,#TABLE1 ACALL WRITE RET next: mov p3,p1 jb p2.0,enter sjmp next enter: CLR P2.1 SETB P2.1 mov p3,p1 mov a,p1 cjne a,#00000000b,dooropen acall close acall nospace ACALL DELAY2 Door open: open the door clr p2.3 setb p2.4 acall delay setb p2.3 ; BUZZER ON ; BUZZEROFF ACALL DELAY2

58

setb p2.4 acall delay setb p2.3 clr p2.4 acall delay setb p2.3 setb p2.4 ret SCAN: mov P1.7,next ACALL MSG8 RET next: mov P1.6,F2 ACALL MSG7 RET LCD216: MOV A,#38H RET LCDCLR: MOV A,#01H RET RETHOME: MOV A,#02H ACALL COMMAND RET DONCOFF: MOV A,#0CH ACALL COMMAND ;DISPLAY ON CURSOR OFF ;RETURN HOME ;CLEAR DISPLAY SCREEN ACALL COMMAND ;FORCES 2 X 16 MATRIX ACALL COMMAND

59

RET FCBFL: MOV A,#80H ACALL COMMAND RET ;CURSOR AT BEGINNING OF IST LINE

FCBSL: MOV A,#0C0H ACALL COMMAND RET COMMAND: MOV LCD,A CLR RS CLR RW SETB EN CLR EN RET WRITE: CLR A MOVC A,@A+DPTR JZ BACK ACALL DISPLAY INC DPTR SJMP WRITE BACK: DISPLAY: MOV LCD,A SETB RS CLR RW SETB EN CLR EN RET RET ;WRITE COMMAND TO LCD ;WRITE FROM DATATABLES ;INSTRUCTION COMMAND TO LCD ;CURSOR AT BEGINNING OF IIND LINE

60

TABLE1: DB 'P','A','R','K','I','N','G','',' ','S','T','A','T','I','O','N', TABLE2: DB 'G','O','-','-','-','T','O',' ', TABLE3: DB '*','*','*','N','O','S','P','A','C','E','*','*','*', TABLE4: DB 'G','O','-','-','-','T','O','*','*','*','1', TABLE5: DB 'G','O','-','-','-','T','O','*','*','*','2', TABLE6: DB 'G','O','-','-','-','T','O','*','*','*','3', TABLE7: DB 'G','O','-','-','-','T','O','*','*','*','4', TABLE8: DB 'G','O','-','-','-','T','O','*','*','*','5', TABLE9: DB 'G','O','-','-','-','T','O','*','*','*','6', TABLE10: DB 'G','O','-','-','-','T','O','*','*','*','7', TABLE11: DB 'G','O','-','-','-','T','O','*','*','*','8',

BIBLIOGRAPHY

The 8051 Microcontroller and Embedded. Systems. Using Assembly and C, Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. McKinlay, 2nd ed., 2008. A Reservation-based Smart Parking System by Hongwei Wang, Wenbo He.

61

The 8051/8052 Microcontroller: Architecture, Assembly Language, And Hardware Interfacing by Craig Steiner. Fundamentals of Microcontrollers and Microprocessors by B.Ram, 7th ed., 2010. http://www.scribd.com/007brijendra/d/36615309-Report-on-Project-Based-on-8051-MicroController

62

You might also like