Sie sind auf Seite 1von 26

BAB 3 METHODOLOGI

RFID and password code door lock system have 4 main blocks of system which is RFID reader, controller, power regulator and siren circuit. The RFID reader acts as the signal receiver and when the frequency from the correct RFID card the password need to be enter and then microcontroller detects the correct codes.

A microcontroller of PIC16F877 is the major controller of the system.This microcontroller has power supply connected to it which comes from the regulator circuit that being built. The firmware for this microcontroller is program in the chip in order to program the chip using the boot loader techniques. The electromagnetic switch is used as the door movement sensor. This electromagnetic switch using the electromagnetic principle which will act as an electromagnet when there is power supply feed to it. So whenever there is any break in between this two switch the alarm will be on.

ZD-PIC MF SK40 (PIC STARTER KIT 40 PIN) New generation of ZD-PIC MF SK40 are design to offer user to utilize the function of PIC as easy as could be imagine. This start up kits come with basic element for user to begin project development. Which mean interface and program should be develop by user. This board offer plug and use features. This kit comes WITHOUT LCD Display and PIC Microcontroller to provide the freedom for user to choose PIC type.

Step 1 - Preparing blank piece of circuit board. Blank panels of single or double sided circuit boards come in various sizes. You need to cut out a piece 5mm x 5mm larger than the actual printed artwork ie. 2.5mm extra either side. I use a band saw to cut the panels to correct shape. Once the panel had been cut to correct shape, both copper surfaces (if double sided board is used) should be sanded withvery fine sand paper (B26 will suffice ) until all scuff marks and finger prints have been removed exposing new shining surface. After the board's surfaces had being sanded the board needs to be washed in warm soapy water to remove any shavings and dirt. This will ensure the printed artwork will bind with copper surface without any track breaks.

Step 2 - Preparing transfer film for double-sided boards. The image to the left shows transfer film after transferring the artwork on to a blank PCB. You can also use Photo printing paper (the glossy type 165 microns) it is much cheaper than film and does the same job. Before you can start you need to print your artwork on to a special transfer film. This film is not too cheap which is more of a reason to get things right the first time. Remember to print Top layer as MIRROR and Bottom layer as is. The basic preparation for double-sided boards is quiet simple. Cut out the Top and Bottom artwork leaving around 1.5cm on all sides. I must stress that the following step is one of the most important for successful alignment of the two sides of the artwork. Once cut out to correct shape you need to overlay both sides (toner inside, touching) as accurately as you can. When you are happy with the alignment use sticky tape on 3 sides to create an envelope. To make this step easier and more accurate I use sticky tape on one side first and with a sharp hobby knife I trim 1-2mm of the remaining edges. This makes sure that both films are cut exactly the same making the process of applying sticky tape much easier with less chance of missalignment. Check again the alignment of both layers. If all is well you may proceed to the next step, otherwise re-align and re-tape edges

Step 3 - Transferring the artwork on to blank panel. This step is not too difficult but it can be tricky. Once you have prepared a blank panel from STEP 1 and transfer film envelope in STEP 2 you are ready to continue to this step. A simple clothes iron. This is what I have mostly used (due to the fact that I do not poses a suitable laminator yet) however it is very tricky and with little practice it is possible to transfer on to smaller boards. Larger boards may not align as well as the transfer film and the panel expand when heated up. This coupled with trying to make sure all tracks are heated up may lead to some tracks being broken or over-heated not to mention miss-aligned on far ends of the PCB. To use this method I insert the blank panel in to the envelope making sure it is aligned with the artwork and place the envelope on top of 10 sheets of printer paper (Don't use newspaper or magazines as the heating process will lift the ink from the paper) to make sure I don't damage the table top surface. Set the clothes iron to "Cotton" and wait until it has heated up. Press the iron on to the envelope and hold for 5 seconds to pre-heat the board then lift the iron and slightly tilted (just enough to use the straight edge of the iron) slide the iron edge from one end of the board to the other applying constant pressure (imitating the board going through the heat rollers of a LaserJet printer). 2 or 3 passes should do the trick. Flip the envelope and repeat the process. Step 4 - Etching the board. This is the easy part. I use an etching tank and a small aquarium pump to pump the air in to the tank. I find using Ferric Chloride very good as the chemical does not go-off in storage and it is easy to wash off from your hands. Place the board in an etching tank for 20 minutes or until all excess copper is removed.

Once the board had been etched, clean it under slow running tap to remove any excess Ferric Chloride. Let it dry and use Acetone or nail polish remover on a cotton bud to quickly remove the toner. Step 5 - Drilling. Before you can drill it is necessary to punch markers in to the pads with a fine punch, this will help guide the drill, eliminating damaging the pad or drilling the hole off the pad. Please see images to the left. I use a small good quality hobby drill with appropriate bits (most common for ICs, resistors and caps is 0.9mm in diameter as the legs are 0.8mm) Place the PCB on top of a wooden block and drill through in to the block, this will minimize the damage from drill bit exiting the bottom side. Once you have drilled the PCB out you need to clean up sharp edges of the drilled holes by using a larger drill bit and giving it a 1-2 twist by hand. Repeat this for the other side. To protect the PCB from oxidization over longer period of time I use a Photo Coating Spray. This spray is available from any Dick Smith Electronics store. Couple of coats on each side should do it. The lacquer will burn off from the pads during soldering which works very well.

PROGRAMMING RFID MODULES

Open the latest RFID Simulation Project (Build 4) in PSoC Designer v. 4.1.You can find the RFID Simulation file from the Cypress web site.

Figure 1: Opening a project in PSoC Designer

Figure 2 : Browse and select the .soc file for BUILD 4

Figure 3: Open customcode.asm file found in Source Files folder.

The template customcode.asm file should look like this:


include "m8c.inc" include "address.inc" include "ram.inc" AREA customcode(ABS) ;***CREATE YOUR CUSTOM CODE BELOW THIS BANER******************** ;WARNING WARNING WARNING>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;USE LCALL and LJMP instead of call and jmp , ;otherwise PRA may not be functional anymore. ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<WARNING WARNING WARNING ;USE ORG to determine block that you will program. ;For example if you will write to block 192 , use ORG block192 ;For example if you will write to block 193 , use ORG block193 ;For example if you will write to block 194 , use ORG block194 ;code_starts_here(Do not delete this comment!) ;ORG blockxxx (START FROM HERE and write the block number) ;***CREATE YOUR CUSTOM ABOVE THIS BANNER**************************

Now , write the following codes in customcode.asm file

Figure 4: Select Rebuild All under Build Tab

Figure 5: Make sure project is build with 0 error(s) and 0 warning(s)

SOURCE CODES

D:\WORKSPACE\PBP\rfid_cl001.pbp '**************************************************************** '* Name : RFID_Code_Lock.BAS '* Author : '* Notice : '* : '* Date : 2010-9-21 '* Version : 1.0 '* : '**************************************************************** INCLUDE "modedefs.bas" DEFINE LOADER_USED 1 DEFINE OSC 4 ON INTERRUPT GOTO SECint ' Define timer interrupt handler DEFINE LCD_DREG PORTD ' LCD Data register at PORTB DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTB ' LCD RS in RD5 DEFINE LCD_RSBIT 4 DEFINE LCD_EREG PORTB ' LCD Enable in RD7 DEFINE LCD_EBIT 5 DEFINE LCD_RWREG PORTB ' LCD RW in RD6 DEFINE LCD_RWBIT 3 DEFINE LCD_BITS 8 ' 8bit operation DEFINE LCD_LINES 2 ' 2line ' Define ADCIN parameters 'Define ADC_BITS 10 ' Set number of bits in result 'Define ADC_CLOCK 3 ' Set clock source (3=rc) 'Define ADC_SAMPLEUS 50 ' Set sampling time in uS DEFINE HSER_BAUD 9600 'Hser baud rate DEFINE HSER_RCSTA 90h 'Hser receive status init DEFINE HSER_TXSTA 20h 'Hser transmit status init ' declare alias for input/output LED VAR PORTC.5 ACK VAR PORTE.2 ' Keypad acknowledge return signal when keypad pressed S1 VAR PORTA.2 ' Magnetic sensor 1 D0 VAR PORTA.0 ' Data line for wiegand protocol D1 VAR PORTA.1 'M1_L VAR PORTB.0 ' Motor driver for open/close door 'M1_R VAR PORTB.1 OUT1 VAR PORTB.0 OUT2 VAR PORTB.1 'OUT3 VAR PORTB.2 ALARM VAR PORTB.2 ' Turn on alarm , low enabled SYMBOL SPACE = 32 ' blank space SYMBOL TC = 190 ' get approx. 50ms interval interrupt SYMBOL PULSE = 50 ' 50 miliseconds pulse WIEGAND_STD CON 26 ' 26 bit wiegand code ID_START CON $10 ' 26 bit wiegand code, first ID stored ID_NEXT CON $20 ' 26 bit wiegand code, address interval ID_LAST CON $30 ' 26 bit wiegand code, last ID stored

' ********************** ' declare variable i VAR BYTE Flag VAR BIT ' declare keypad variable sTaTe VAR BYTE Page 1 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp KeyNUM VAR BYTE TEMP VAR BYTE KeyPTR VAR BYTE AddrPTR VAR BYTE InVAL VAR BYTE[16] RdVAL VAR BYTE[16] VrVAL VAR BYTE[16] Check_IND VAR BIT ' if check is done then set this flag Match_IND VAR BIT Verify_IND VAR BIT Output_IND VAR BIT ' if output should turn on InValidCnt VAR BYTE ' define READER Wiegand_Code VAR BYTE Parity_Odd VAR BIT Wiegand_ID VAR WORD Parity_Even VAR BIT InputBit VAR BIT shiftPos VAR BYTE shiftBit VAR BYTE IDBit VAR WORD CodeRead VAR BYTE ' BitCount VAR BYTE BitReadDone VAR BIT ' *************** Declare time variable *** cNTms VAR WORD cntSpeed VAR WORD cntSec VAR BYTE wMinute VAR BYTE wHour VAR BYTE SecElapsed VAR BYTE SecIND VAR BIT ' indicate seconds has advance ' ::: delayCNT VAR WORD delayMS VAR WORD ' Others j VAR BYTE CARD_CURRENT VAR WORD ID_CURRENT VAR BYTE ID_VALID_FLAG VAR BIT

' ********************** ' =========================================================================== ' PRESET PASSWORD for reset alarm, press *[password]# ' =========================================================================== EEPROM 0,["772266",0,0,0,0,0,0,0,0,0,0] EEPROM $10,["SUMAN",0,0,0,0,0,"60418",0] EEPROM $20,["221100",0,0,0,0,0,0,0,0,0,0] EEPROM $30,["SAM",0,0,0,0,0,0,0,"60419",0] EEPROM $40,["554433",0,0,0,0,0,0,0,0,0,0] ' =========================================================================== ' PROGRAM START ' =========================================================================== INIT: 'adcon1 = %10000000 ' all as analogue channel ADCON1 = 7 ' all as digital channel TRISA = %111111 ' first 3 input and rest output TRISB = 0 ' misc output TRISC = %10001111 ' output,Keypad input TRISD = %00000000 ' LCD output TRISE = $0f ' all 3 pins as input ' initialise interrupt OPTION_REG = %10000111 ' tmr prescalar,1:256 ' 1ms per cycle INTCON = %00100000 ' enable Timer interrupt only TMR0 = 0 - TC Page 2 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp 'SPBRG = 15 ' Set baud rate to 2400 'RCSTA = %10010000 ' Enable serial port and continuous receive 'TXSTA = %00100000 ' Enable transmit and asynchronous mode PORTE = 0 PORTD = 0 PORTC = %11000000 ' default serial enabled. PORTB = 0 ' PORTA = 0 GOTO reset ' =============================================== ' Reset variable ' =============================================== RESET: LCDOUT $fe,1,"RFID" LCDOUT $fe,$c0,"Code Lock" PAUSE 1000 ' lcdout $fe,1,"Testing..." ' LED = 1 ' red and green LED illuminate ' ALARM = 1 ' test alarm ' OUT1 = 1 ' reactivate door magnet after 5 seconds ' OUT2 = 1 ' pause 1000 ' LED = 0 ' ALARM = 0 ' OUT1 = 0 ' reactivate door magnet after 5 seconds ' OUT2 = 0 ' lcdout $fe,1,"Testing Done." ' pause 1000 ' === Reset RFID Variable Start.

BitReadDone = 0 bitcount = 0 ' start from bit 0, after read start bit 1 coderead = 0 Wiegand_ID = 0 Wiegand_Code = 0 ' === Reset RFID Variable End. cntms = 0 SecElapsed = 0 ID_CURRENT = 0 sTaTe = 0 ' default state 0 GOTO MAIN ' ============================================================================= ' RFID Function ' ============================================================================= READ_CARD: BitReadDone = 0 ' reset before read card coderead = 0 bitcount = 0 ' start from bit 0, after read start bit 1 Wiegand_ID = 0 Wiegand_Code = 0 WHILE BitReadDone = 0 IF (D0 = 0 OR D1 = 0) THEN ' make sure the change is due to RFID ' D0 = zero, default buffer value is zero ' do nothing IF D1 = 0 THEN ' bit 1 is parity, skip ' first 8 bit is wiegand code, after parity IF coderead < 9 AND coderead > 0 THEN shiftpos = 8 - coderead shiftbit = 1 IF shiftpos > 0 THEN shiftbit = shiftbit << shiftpos ENDIF Wiegand_Code = Wiegand_Code + shiftbit ENDIF Page 3 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp ' start from 9, next 16 bit is wiegand id IF coderead >= 9 AND coderead < 25 THEN shiftpos = (16 - Coderead) + 8 ' 16 bit, coderead start from 9 IDBit = 1 IF shiftpos > 0 THEN IDBit = IDBit << shiftpos ENDIF Wiegand_ID = Wiegand_ID + IDBit ENDIF ' bit 26 is parity, do nothing 'hserout ["1"] ' debug ELSE 'HSEROUT ["0"] ' debug ENDIF coderead = coderead + 1 ' This will skip the first parity bit IF coderead = WIEGAND_STD THEN BitReadDone = 1 ' finished read ENDIF

WHILE (D0 = 0 OR D1 = 0) @ nop @ nop @ nop WEND ' release after complete pulse ENDIF WEND 'hserout ["*",DEC5 Wiegand_ID,"#",10,13] LCDOUT $fe,1,"Authentitation.." LCDOUT $fe,$c9,DEC5 Wiegand_ID RETURN VALIDATE_CARD: CARD_CURRENT = 0 ' clear buffer first READ id_current + 10,TEMP TEMP = TEMP - $30 ' to number CARD_CURRENT = card_current + (TEMP*10000) READ id_current + 11,TEMP TEMP = TEMP - $30 ' to number CARD_CURRENT = card_current + (TEMP*1000) READ id_current + 12,TEMP TEMP = TEMP - $30 ' to number CARD_CURRENT = card_current + (TEMP*100) READ id_current + 13,TEMP TEMP = TEMP - $30 ' to number CARD_CURRENT = card_current + (TEMP*10) READ id_current + 14,TEMP TEMP = TEMP - $30 ' to number CARD_CURRENT = card_current + TEMP ' lcdout $fe,1,"E:",DEC5 CARD_CURRENT ' lcdout $fe,$c0,"R:",DEC5 Wiegand_ID IF Wiegand_ID = CARD_CURRENT THEN ID_VALID_FLAG = 1 ELSE ID_VALID_FLAG = 0 ENDIF RETURN ' ============================================================================= ' Keypad function ' ============================================================================= Flush_KEY: FOR i = 0 TO 15 InVAL[i] = 0 RdVAL[i] = 0 NEXT i KeyPTR = 0 RETURN Reset_key: CALL flush_key Page 4 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp RETURN

Read_Password: 'AddrPTR = ID_CURRENT + $10 'get starting address, default is 0 ' since id current reseted, place on the card ' read loop FOR i = 0 TO 15 RdVAL[i] = 0 READ i + AddrPTR,RdVAL[i] ' read into key value ' lcdout $fe,($80+i),rdval[i] NEXT i ' pause 5000 RETURN Compare: ' lcdout $fe,1,"compare" ' pause 1000 ' for i = 0 to 15 ' lcdout $fe,($80+i),rdval[i] ' lcdout $fe,($c0+i),inval[i] ' next i ' pause 2000 Check_IND = 0 match_ind = 1 FOR i = 0 TO 15 IF RdVAL[i] <> InVAL[i] THEN match_ind = 0 i = 16 ENDIF NEXT i Check_IND = 1 RETURN Read_KEY: InVAL[KeyPTR] = KeyNUM ' read into memory 'lcdout $fe,($c0+keyptr),keynum LCDOUT $fe,($c0+KeyPTR),"*" ' encrypted password IF KeyPTR < 15 THEN KeyPTR = KeyPTR + 1 RETURN Decode_KEY: SELECT CASE KeyNUM CASE "0","1","2","3","4","5","6","7","8","9" IF sTaTe = 4 THEN CALL read_key IF sTaTe = 84 THEN CALL read_key CASE "*" IF sTaTe = 99 THEN LCDOUT $fe,1 sTaTe = 80 ' start input reset password AddrPTR = 0 ' address for master reset CALL flush_key ' reset all entry ENDIF CASE "#" IF sTaTe = 84 THEN sTaTe = 85 ' request to validate reset password IF sTaTe = 4 THEN sTaTe = 5 ' request to validate reset password END SELECT KeyNUM = 0 RETURN

Read_KEYPAD: IF ack = 1 THEN TEMP.0 = PORTC.0 TEMP.1 = PORTC.1 TEMP.3 = PORTC.2 TEMP.2 = PORTC.3 'TEMP = PORTC & $0f TEMP = TEMP & $0f Page 5 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp IF TEMP = 12 THEN KeyNUM = "1" IF TEMP = 13 THEN KeyNUM = "2" IF TEMP = 14 THEN KeyNUM = "3" IF TEMP = 15 THEN KeyNUM = "A" IF TEMP = 4 THEN KeyNUM = "4" IF TEMP = 5 THEN KeyNUM = "5" IF TEMP = 6 THEN KeyNUM = "6" IF TEMP = 7 THEN KeyNUM = "B" IF TEMP = 8 THEN KeyNUM = "7" IF TEMP = 9 THEN KeyNUM = "8" IF TEMP = 10 THEN KeyNUM = "9" IF TEMP = 11 THEN KeyNUM = "C" IF TEMP = 0 THEN KeyNUM = "*" IF TEMP = 1 THEN KeyNUM = "0" IF TEMP = 2 THEN KeyNUM = "#" IF TEMP = 3 THEN KeyNUM = "D" IF TEMP = 16 THEN KeyNUM = 0 IF TEMP = 17 THEN KeyNUM = 0 IF TEMP = 18 THEN KeyNUM = 0 IF TEMP = 19 THEN KeyNUM = 0 'call beep 'lcdout $fe,$c0,keynum 'pause 1000 'lcdout $fe,$80,BIN8 PORTC," ",BIN4 TEMP GOTO decode_key ' decode what is read ELSE KeyNUM = 0 ENDIF RETURN ' ============================================================================= ' Motor function ' ============================================================================= 'OPEN_DOOR: ' m1_l = 1 ' m1_r = 0 ' pause 5000 ' m1_l = 0 ' m1_r = 0 ' return 'CLOSE_DOOR: ' m1_L = 0 ' m1_r = 1 ' pause 5000 ' m1_l = 0 ' m1_r = 0 ' return

' =============================================== ' MAIN PROGRAM ' =============================================== MAIN: LCDOUT $fe,$0c ' blink cursor off delayCNT = 0 WHILE delayCNT < 1 ' delay 1 seconds @ nop @ nop @ nop WEND ' *** RFID verification LCDOUT $fe,$1,"Wave Your" LCDOUT $fe,$c0,"<ID Card>" CALL read_card ID_VALID_FLAG = 0 ' invalidate id first FOR ID_CURRENT = ID_START TO ID_LAST STEP ID_NEXT CALL validate_card delayCNT = 0 ' while delayCNT < 2 ' delay 2 seconds Page 6 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp '@ nop '@ nop '@ nop ' wend IF ID_VALID_FLAG = 1 THEN LCDOUT $fe,1,"Welcome" FOR i = 0 TO 15 READ (id_current + i),TEMP IF TEMP = 0 THEN i = 15 ' End ID string ELSE LCDOUT $fe,($88+i),TEMP ' Display ID ENDIF NEXT i delayCNT = 0 WHILE delayCNT < 1 ' delay 1 seconds @ nop @ nop @ nop WEND LCDOUT $fe,$80,"INSERT-PASSWORD" LCDOUT $fe,$c0,"<# to complete>" delayCNT = 0 WHILE delayCNT < 1 ' delay 1 seconds @ nop @ nop @ nop WEND sTaTe = 3 ' rfid passed, check password AddrPTR = ID_CURRENT + $10 'get starting address, default is 0 ID_CURRENT = ID_LAST ' goto last after validation done ENDIF

NEXT ID_CURRENT ' after ID search, see whether ID identified ? IF ID_VALID_FLAG = 0 THEN sTaTe = 98 ' sound alarm, auto reset to 0 ENDIF ' *** Keypad code lock entry CALL Reset_key ' reset keypad entry Check_IND = 0 ' reset other variables match_ind = 0 Output_IND = 0 WHILE (sTaTe >= 3 AND sTaTe < 100) CALL Read_KEYPAD ' read and decode if any WHILE ack = 1 ' wait until debouncing off @ nop @ nop @ nop WEND IF Check_IND = 1 AND match_ind = 0 THEN Check_IND = 0 ' reset other variables match_ind = 0 Output_IND = 0 CALL Flush_KEY ' reset keypad entry for next retry ENDIF IF (sTaTe = 85 OR sTaTe = 5) THEN CALL read_password ' read from eeprom CALL compare IF sTaTe = 5 THEN sTaTe = 6 ' proceed to validation IF sTaTe = 85 THEN sTaTe = 86 ' proceed to validation ENDIF IF Output_IND = 1 THEN IF SecElapsed > 5 THEN LCDOUT $fe,$80,"PLEASE CLOSE" LCDOUT $fe,$c0," DOOR" OUT1 = 0 ' reactivate door magnet after 5 seconds OUT2 = 0 'OUT3 = 0 Page 7 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp IF s1 = 0 THEN sTaTe = 101 ' operating status ELSE LCDOUT $fe,$80,"OPEN DOOR" OUT1 = 1 OUT2 = 1 'OUT3 = 1 ENDIF IF SecElapsed > 30 THEN ' if door sensor not active, mean door not close back then Output_IND = 0 IF s1 = 1 THEN sTaTe = 99 ' sound alarm if door not close ELSE LCDOUT $fe,$80,"OPERATION" LCDOUT $fe,$c0,"MODE" sTaTe = 101 ' back to normal ENDIF

ELSE LCDOUT $fe,$ce,DEC2 (30 - SecElapsed) ' display time remaining ENDIF ENDIF WEND ' *** Repeat GOTO Main ' ========================================================================= ' Interrupt routine ' Interrupt routine used to decode keypad entry ' ========================================================================= DISABLE SECint: IF INTCON.2 = 1 THEN ' Timer 0 interrupt TMR0 = 0 - TC cntms = cntms + PULSE ' milisecond counter increment IF cntms => 1000 THEN SecElapsed = SecElapsed + 1 ' one seconds elapsed delayCNT = delayCNT + 1 cntms = 0 ' ******* animate LED TOGGLE led ' ******* ENDIF ' next selection SELECT CASE sTaTe CASE 0 ALARM = 0 ' turn off alarm SecElapsed = 0 ' reset time elapsed to zero InValidCnt = 0 ' reset valid count to zero CASE 3 LCDOUT $fe,$80,"INSERT-PASSWORD" LCDOUT $fe,$c0,"________________" sTaTe = 4 ' wait for password entry CASE 4 LCDOUT $fe,($c0+KeyPTR) 'keyptr will automatically advance LCDOUT $fe,$0f ' blink password CASE 5 LCDOUT $fe,1,"VALIDATE ..." LCDOUT $fe,$0f ' blink cursor off SecElapsed = 0 ' reset time elapsed to zero CASE 6 IF match_ind = 1 THEN LCDOUT $fe,$80,"RIGHT-PASSWORD" IF SecElapsed > 2 THEN sTaTe = 7 ' response to next state after 2 seconds ENDIF ELSE Page 8 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp LCDOUT $fe,1,"WRONG-PASSWORD" InValidCnt = InValidCnt + 1 LCDOUT $fe,$cf,#InValidCnt PAUSE 1000

IF InValidCnt >= 3 THEN sTaTe = 99 ' turn on alarm until reset pressed ELSE sTaTe = 9 ' back to retry ENDIF ENDIF CASE 7 LCDOUT $fe,1 ' clear screen Output_IND = 1 SecElapsed = 0 sTaTe = 8 CASE 9 LCDOUT $fe,$1,"INSERT-PASSWORD" LCDOUT $fe,$c0,"<# to complete>" sTaTe = 3 ' back to retry CASE 80 LCDOUT $fe,$80,"MASTER-RESET" LCDOUT $fe,$c0,"<# to complete>" sTaTe = 83 CASE 83 LCDOUT $fe,$80,"INSERT-PASSWORD" LCDOUT $fe,$c0,"________________" sTaTe = 84 ' wait for password entry CASE 84 LCDOUT $fe,($c0+KeyPTR) 'keyptr will automatically advance LCDOUT $fe,$0f ' blink password CASE 85 LCDOUT $fe,1,"VALIDATE ..." LCDOUT $fe,$0f ' blink cursor off SecElapsed = 0 ' reset time elapsed to zero CASE 86 IF match_ind = 1 THEN LCDOUT $fe,$80,"RIGHT-PASSWORD" sTaTe = 100 ' response to next state after 2 seconds ELSE LCDOUT $fe,$80,"WRONG-PASSWORD" SecElapsed = 0 sTaTe = 99 ' continue sound alarm ENDIF CASE 98 ALARM = 1 ' turn on alarm sTaTe = 0 CASE 99 IF SecElapsed = 0 THEN LCDOUT $fe,$1,"ALARM TRIGGER" LCDOUT $fe,$c0,"Manual Reset?" ALARM = 1 ' turn on alarm ELSE ALARM = 0 ENDIF IF SecElapsed > 15 THEN ' assume alarm turn off after 15 seconds SecElapsed = 0 ' repeat alarm until reset pressed ENDIF

CASE 100 LCDOUT $fe,$1,"MASTER RESET" LCDOUT $fe,$c0,"DONE." sTaTe = 0 CASE 101 LCDOUT $fe,1 sTaTe = 0 ' default state 0 Page 9 of 10 30/12/2011 6:14 PM D:\WORKSPACE\PBP\rfid_cl001.pbp END SELECT ENDIF INTCON = INTCON & %11111000 ' Clear interrupt flag RESUME ' Return to main program END

CHART FLOW

BAB 4: DAPATAN DAN ANALISA 1. Firstly, on the circuit by plug in the adapter to current. Wave your RFID card sign will appear on screen.Then, switch on the circuit wave the RFID card towards the RFID reader.

2. After that insert the correct password according to the person name appeared.

3. If the password entered was wrong,the system will give another two chance to enter the correct password (total of three password entry chances). If the person failed to enter the correct password for three times, the siren will be on. And the siren only will be off if and only if the master password entered into the system. We also programmed the system with 5 second of intraction time with system actively.If there is no interaction for 5 sec after swap card, the system will restart from beginning.

4. And if a correct password entered within these tree trials the will open but only 30 second. So we add an additional switch (SWITCH A)inside the door to enable open the door permenantly. These switch we include in because sometime there is needs to bring in stuffs and if more person want to enter into the room or etc, so these activities need more time.

5. The door should be close within these 30 sec or the siren will on.

6. So we add an additional switch (SWITCH A)inside the door to enable open the door permenantly.SWITCH A will disable the timing for activate siren.These switch we include in because sometime there is needs to bring in stuffs and if more person want to enter into the room or etc, so these activities need more time.

7. Before exit the room the person just need to press SWITCH B (reset button which only available inside room) and can close the door within 30 seconds. The system will reset and the safety siren will be activated. There also some additional programming made to these system, whereby if any intruders try to break in the door, the siren will be triggered. So, the only way to enter the room is by using the RFID card and enter the correct password.

BAB 5: KESIMPULAN DAN CADANGAN

Das könnte Ihnen auch gefallen