PROGRAMMABLE CODE LOCK

download PROGRAMMABLE CODE LOCK

of 25

Transcript of PROGRAMMABLE CODE LOCK

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    1/25

    PROGRAMMABLE CODE LOCK

    INTRODUTION

    Today every body is very consious about the security of their assets andhome appilance. So home security system is very popular nowadays but it also have somedrawbacks. In case conventional home security system, any one can operate it that meansany one can swtich it on or off without permission of the owner. Introduction of code lock

    home security system can greatly solve this problem. By using this system only user canoperate home security stystem. In this system, when correct code is entered the controller senses it and triggers motor and whenever faulty code is entered the microcontroller sensesit and alarm turns on. Hence user can change the code and can keep it secret.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    2/25

    BLOCK DIAGRAM

    CIRCUIT DIAGRAM

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    3/25

    J P 1

    8 H E A D E R

    12345678

    C 2 3

    2 2 0 0 M F D / 2 5 v

    D 3

    1 N 4 0 0 7

    AC

    V C C

    C 2 4C A P N P

    6 M h z

    1

    2

    U 7U L N 2 0 0 4

    1234567

    8

    9

    1 01 11 21 31 41 51 6

    I N AI N BI N CI N DI N EI N FI N G

    GND

    COM

    O U T GO U T FO U T EO U T DO U T CO U T BO U T A

    J 1 0

    1 5 - 0 - 1 5

    1

    23

    V C C

    R 1R

    T O M O T O R

    K 1

    R E L A Y S P D T 34

    51

    2

    + 1 2 VR 2R

    U 5

    L M 7 8 1 2

    1

    2

    3V I N

    GND

    V O U T

    D 1

    1 N 4 0 0 7

    AC

    V C C

    V C C

    V C C

    a

    b

    c

    d

    e

    f

    g

    DP

    CC

    D 1 6 A

    S E V E N S E G M E N T

    1

    7

    6

    4

    3

    9

    1 0

    5

    2

    + 1 2 V

    C 1 5

    1 8 p F J 6

    m o t o r

    12

    U 1

    L M 7 8 0 5

    1

    2

    3V I N

    GND

    V O U T

    V C C

    C 2 6

    1 0 M F DT O K E Y B O A R D

    V C CR 1 2

    1 0 K

    C 2 5

    1 8 p F

    J 3

    b u z z e r

    12

    U 6

    7 4 4 7 A

    7

    1

    2

    6

    5

    3

    1 3

    1 2

    1 1

    1 0

    9

    1 5

    1 4

    8

    4

    16

    I N A

    I N B

    I N C

    I N D

    R B I

    L T

    O U T A

    O U T B

    O U T C

    O U T D

    O U T E

    O U T F

    O U T GGND

    B I / R B OVCC

    C 2 7C A P N P

    4 7 0 o h m s * 7

    + 1 2 V

    T O A L A R M

    U 4A T 8 9 C 5 1

    91 8

    1 9

    20

    3140

    12345678

    2 1

    2 22 32 42 52 62 72 8

    1 01 11 21 31 41 51 61 7

    3 9

    3 83 73 63 53 43 33 2

    R S TX 2

    X 1

    GND

    EA

    VCC

    P 1 . 0P 1 . 1P 1 . 2P 1 . 3P 1 . 4P 1 . 5P 1 . 6P 1 . 7

    P 2 . 0P 2 . 1P 2 . 2P 2 . 3P 2 . 4P 2 . 5P 2 . 6P 2 . 7

    P 3 . 0P 3 . 1P 3 . 2P 3 . 3P 3 . 4P 3 . 5P 3 . 6P 3 . 7

    P 0 . 0P 0 . 1P 0 . 2P 0 . 3P 0 . 4P 0 . 5P 0 . 6P 0 . 7

    CIRCUIT DESCRIPTION

    Micro controller :

    A Micro controller is used for controlling entire circuits and tomaintain timings. Here a micro controller named AT89c51 from Atmel Corporationis used for that purpose. AT89c51 is an bit micro controller has 40 pins arranged in4 I/O ports, that ports are used here for connecting LCD module and to interfacewith the load.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    4/25

    As shown in above figure micro controller is wired with a crystal for clock and each pin of the crystal is connected to ground through a 18 pF capacitor to avoidnoise pulses in the clock. Here a 1 MHz crystal is used that gives 1MHz clock for the micro controller.

    Micro controllers RESET pin is connected to an RC circuit asshown in above figure. This will give a high pulse to the RESET pin at time of starting. This will reset the micro controller means start execution from 0000h. It isessential for a micro controller circuit. When the power is switched ON charge incapacitor will be zero then the reset pin will get high voltage, capacitor starts

    charging then the voltage across the RST pin will decrease, micro controller startsexecution.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    5/25

    KEY BOARD-:

    Keyboard is used to input the code. Keyboard is continously sensed

    by the microcontroller. Keyboard used is a 4 3 matrix type keyboard. Rows andcolumns are connected to port 3 of microcontroller . The three columns areconnected to P3.4, P3.5, and P3.7 which is programmed as input and is set as 0. Thefour row are connected to P3.0, P3.1, P3.2, and P3.3 which is programmed as outputand is continously sensed. When this iall this keys at logic high no key is pressedand when any of pin output goes low the two of output is made logic high and eventhen if the input pin remains low then the key of the column which is not made highis pressed. In this way key board is sensed by the microcontroller.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    6/25

    BCD to 7- SEGMENT DISPLAY DRIVER -:

    A74LS47 IC is used as a display decoding/driving IC. This is used asa display control. It is simple chip to use but bear in mind that its output go lowwhen activated thus requiring a common anode configured display unit. There twotypes of decoder driverv corresponding to two types 7-segment displays. Indicator logic circuits inside the 7447 converrt the four bit BCD input to the 7 bit outputwhich are active low 7446 can also be used in place of 7447.

    7-SEGMENT DISPLAY-:

    It consist of seven LEDs labelled a through g. By forwardbiasing different LEDs we can display the digit 0through9. 7 segment indicatorsare of two types common anode and common cathode .In common anode type ,anodes of all 7 Led s are tied togetyher whil;e in common cathode type all cathodesare tied together .When common anode type is used a current limiting must beconnected between LED segments and ground .When common cathode type is usedresistor must be connected between every LED segment and +Vcc.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    7/25

    Relay switching:

    Relays are connected to micro controller through UlN 2004 relaydriver. ULN 2004 has seven internal relay drivers that may be used to control sevenrelays. Inputs of ULN 2004 is connected to micro controllers port which is used toON/OFF the relays. When port output is logic 1 the corresponding relay will beswitched ON, as well as when the out put is logic 0 the relay will be switched OFF.

    These relays are used to control the loads that are to be controlled.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    8/25

    POWER SUPPLY

    The present chapters the operation of power supply circuit built usingfilter, rectifier, and then voltage regulators. Starting with an ac voltage, a steady dcvoltage is obtained by rectifying the ac voltage, then filtering to a dc level, andfinally, regulating to obtain a desired fixed dc voltage .The regulator is usually

    obtained from an IC voltage regulator unit, which takes a dc voltage, which remainthe if the input dc voltage varies, or the output load connected to the dc voltagechangesThe ac voltage, typically 220 v rms is connected to a transformer, which step that acvoltage down to the level for the desired dc output. Diode rectifier then provides afull wave rectified voltage that is initially filtered by simple capacitor filter toproduce a dc voltage. This resulting dc voltage usually has some ripple or ac voltagevariation. The regulated circuit can use this dc input to provide a dc voltage that notonly has much less ripple voltage but also remain the same dc value even if theinput voltage vary some what, or the load connected to the output dc voltagechanges. This voltage regulation is usually obtained using regulator IC .

    VOLTAGE REGULATOR

    The voltage regulator plays an important role in a power supply unit .The primarypurpose of the regulator is to aid the rectifier and filter circuit in providing a constant dcvoltage to the device. Power supplies without regulators have an inherent problem of changing of dc voltage values due to variations in the load or due to fluctuations in the ac

    linear voltage. With regulator connected to the dc output, the voltage can be maintainedwith a close tolerant region of the desired output.

    IC VOLTAGE REGULATIOR

    Voltage regulator comprises a class of widely use ICs. Regulator IC outs contain thecircuit for reference source, comparator, amplifier, control device, and overload protectionall in a single IC. Although the central construction of the IC is some what difference fromthat described for discrete voltage regulator circuits, the central operation is much thesame .IC units provides regulation of either a fixed positive voltage, a fixed negativevoltage or an adjustable set voltage.

    A power supply can be built using a transformer connected to the ac supply line to stepthe ac voltage to desired amplitude, then rectifying that ac voltage, filtering with acomparator RC filter, if desired, and finally regulating the dc voltage using IC regulator

    The fixed voltage regulator has an unregulated dc input voltage, vi, applied to oneinput terminal and a regulated output dc voltage, from a second terminal, with third

    terminal connected to the ground For a selected regulator IC device specifications list a

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    9/25

    voltage range over which the input voltage can vary to maintain a regulated output voltage.Over a range of load, current .The specifications also list the amount of output voltagechange resulting from a change in load current (load regulation) or input voltage (lineregulation).

    IC O/p Voltage (Vo) Minimum I/p Voltage (Vi)

    7805 5 7.37806 6 8.37808 8 10.57810 10 12.57812

    Example of monolithic regulator s are 78xx/79xxseries and 723general purposeregulators.78xx series are three terminal, positive fixed voltage regulators .In 78xx the lasttwo numbers indicate the output voltage, the 7812 represent a 12 v regulator

    The third IC terminal is connected to ground. While the input voltage may vary over some permissible voltage range and the output load may vary over some acceptable range.The output voltage remains constant within specified voltage variation limits

    78xx series are three terminal positive fixed voltage regulators. There are some outputvoltage options available such as 5, 6, 8,10,12,18and 24 v.

    PCB LAYOUT

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    10/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    11/25

    FABRICATION OF PCB

    The PCB must be fabricated first. Then the components are soldered carefully to PCB.We should keep in mind that the quality of soldering affects the quality of output. Theprocedure for fabricating the PCB for setting up the circuit of any multi purposeproject is described below.

    PCB MAKING

    Making of Printed Circuits Boards (PCBs) is as much as art on a techniqueparticularly so when they are to fabricated in very small numbers. There are severalways of drawing PCB patterns and making the final boards. The making of PCB patternsand making PCB essentially involves two steps.

    1. Preparing the PCB drawing and2. Fabricating the PCB itself from the drawing.

    The traditional method of drawing with complete placement of parts, taking aphotographic negative of the drawing, developing the image of negative formed on photosensitized copper plate and dissolving the excess copper by itching is a standard practicebeing followed in large scale operations. However, for small-scale operations, where largenumbers of copies are not required, the cost saving procedure presented here may beadopted.

    PCB DRAWING

    Making of PCB drawing involves some preliminary considerations such as placement

    of components on a piece of paper. Locating holes, deciding the diameters of various holes, the optimum area of each components should occupy the shapeand location lands for connecting two or more components at a place, full spaceutilization and prevention of over crowding of components at a particular place.There is no other way to arrive at the conclusion than by trial and error. For anchoring leads of component 1mm diameter holes and for fixing PCB holdingscrews to the 3mm diameter holes can be made. Following these hints, a sketchof PCB is made.

    PCB FABRICATION

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    12/25

    The copper clad PCB laminate is now prepared by rubbing away the oxide, grease etc.With fine emery paper or sand paper on this, the final PCB drawing may be traced byusing a carbon paper. Clips are used to prevent the carbon paper from slipping while PCBpattern is being traced on the laminate. Only the connecting lines in PCBs, slants andholes, should be traced. The components position can be marked on the PCBs reverse sideif desired.

    The marked holes in PCB may be drilled using 1mm or 3mm drill bits and the tracedPCB pattern created with black, quick drilling enamel paint, using a thin brush or a smallmetal case. In case, if there is any shorting of lines due to spilling of paint, there may beremoved by scrapping with a blade or knife, after the paint has dried.

    After drying, 20-30gms of Ferric chloride in 75ml of water may be heated to about

    60deg and over the PCBs placed with its copper side upwards in a plastic tray. Stirring thesolution helps speedy etching. The dissolution of unwanted copper would take about 45minutes. If etching takes longer, the solution may be heated again and the process isrepeated. The paint on the pattern can be removed by rubbing with a rag soaked in thinner,turpentine or acetone. The PCB may then be washed and dried.

    Depending on the wiring diagram, the resistors are taken care at first, and then the ICsare soldered.

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    13/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    14/25

    FLOW CHART

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    15/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    16/25

    .org 0000hsjmp key0.org 0050h

    key0:mov sp,#50h

    mov r0,#00hmov 74h,#06hmov 75h,#07hmov 76h,#08hmov 77h,#09hmov r1,#00hmov r2,#00hmov p2,#0ffhmov p1,#0ffhclr p0.0clr p0.1

    key12: acall key1ljmp store

    key1:mov p3,#0fehjb p3.7,skip1ljmp a0

    skip1: jb p3.5,skip2ljmp a1

    skip2: jb p3.4,skip3ljmp a2

    skip3: mov p3,#0fdhjb p3.7,skip4ljmp a3

    skip4: jb p3.5,skip5ljmp a4

    skip5: jb p3.4,skip6ljmp a5

    skip6: mov p3,#0fbhjb p3.7,skip7ljmp a6

    skip7: jb p3.5,skip8ljmp a7

    skip8: jb p3.4,skip9ljmp a8

    skip9: mov p3,#0f7hjb p3.7,skip10ljmp a9

    skip10: jb p3.5,skip11ljmp a10

    skip11: jb p3.4,skip12

    ljmp a11

    skip12: ljmp key1

    a0: lcall delay3loop0: jnb p3.7, loop0

    lcall delay3mov a,#00hret

    a1: lcall delay3loop1: jnb p3.5, loop1

    lcall delay3

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    17/25

    mov a,#01hret

    a2: lcall delay3loop2: jnb p3.4, loop2

    lcall delay3mov a,#02hret

    a3: lcall delay3loop3: jnb p3.7, loop3

    lcall delay3mov a,#03hret

    a4: lcall delay3loop4: jnb p3.5, loop4

    lcall delay3mov a,#04hret

    a5: lcall delay3loop5: jnb p3.4, loop5

    lcall delay3mov a,#05hret

    a6: lcall delay3loop6: jnb p3.7, loop6

    lcall delay3mov a,#06hret

    a7: lcall delay3loop7: jnb p3.5, loop7

    lcall delay3mov a,#07hret

    a8: lcall delay3loop8: jnb p3.4, loop8

    lcall delay3mov a,#08hret

    a9: lcall delay3loop9: jnb p3.7, loop9

    lcall delay3mov a,#09hret

    a10: lcall delay3loop10: jnb p3.5, loop10

    lcall delay3mov a,#10hret

    a11: lcall delay3loop11: jnb p3.4, loop11

    lcall delay3mov a,#11h

    ret

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    18/25

    store:clr p0.1cjne r0,#05h,str ljmp cc

    str: cjne r0,#04h,str0cjne a,#10h,com1mov r2,#01hljmp chan

    com1: cjne a,#11h,str6mov r2,#02hljmp chan

    str0: cjne a,#10h,str1ljmp key12

    str1: cjne a,#11h,str2ljmp key12

    str2: cjne r0,#03h,str3inc r0mov 73h,amov p1,aljmp key12

    str3: cjne r0,#02h,str4inc r0mov 72h,amov p1,aljmp key12

    str4: cjne r0,#01h,str5inc r0mov 71h,amov p1,aljmp key12

    str5: cjne r0,#00h,str6inc r0mov 70h,amov p1,a

    str6: ljmp key12

    chan:mov a,70hcjne a,74h,alarm1

    mov a,71hcjne a,75h,alarm1mov a,72hcjne a,76h,alarm1mov a,73hcjne a,77h,alarm1mov p1,#0ffhmov p2,#0ffhcjne r2,#01h,elevinc r0ljmp key12

    elev: setb p0.0 ;motor openlcall delayclr p0.0mov r0,#00hmov r1,#00h

    dis15: ljmp key12

    alarm1: mov p1,#0ffhsetb p0.1lcall delay1clr p0.1

    mov r0,#00h

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    19/25

    mov r1,#00hlcall delay1ljmp key12

    cc: cjne r1,#04h,chan0cjne a,#11h,dis15mov r0,#00hmov r1,#00hmov p1,#0ffhmov p2,#0ffhljmp key12

    chan0: cjne a,#10h,cc1ljmp key12

    cc1: cjne a,#11h,cc2ljmp key12

    cc2: cjne r1,#03h,chan1inc r1mov 77h,amov p1,aljmp key12

    chan1: cjne r1,#02h,chan2inc r1mov 76h,amov p1,aljmp key12

    chan2: cjne r1,#01h,chan3inc r1mov 75h,amov p1,aljmp key12

    chan3: cjne r1,#00h,chan4inc r1mov 74h,amov p1,a

    chan4: ljmp key12

    .org 032dhljmp key0

    ;**********************delay for key debouncing *********************************;delay3:

    mov r6,#05hd8 mov tmod,#10h

    mov tl1,#6ah

    mov th1,#0aahd9: setb tr1jnb tf1,d9clr tf1djnz r6,d8ret

    delay: mov r5,#0ahs8: mov r6,#0ahs9: mov tmod,#10h

    mov tl1,#3ch

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    20/25

    mov th1,#0afhdisp:

    setb tr1jnb tf1,dispclr tr1

    clr tf1djnz r6,s9djnz r5,s8ret

    delay1: mov r5,#02hs1: mov r6,#0e4hs2: mov tmod,#10h

    mov tl1,#00hmov th1,#00hsetb tr1

    disp1: jnb tf1,disp1clr tr1clr tf1djnz r6,s2djnz r5,s1ret

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    21/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    22/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    23/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    24/25

  • 8/7/2019 PROGRAMMABLE CODE LOCK

    25/25