本密碼鎖控制器由AT89C2051單片機(jī)組成, 工作穩(wěn)定可靠, 保密性高, 實(shí)用性強(qiáng), 并具有報(bào)警控制功能,。?
一,、電路組成和原理圖
工作原理圖如附圖一所示, 該電路由AT89C2051做控制元件, P1口為鍵盤口, 其中P1.4~P1.7為鍵盤掃描輸出口, P1.0~P1.3為鍵盤掃描輸入口,; P3口為信號(hào)輸出口, 其中P3.0輸出開(kāi)鎖控制信號(hào)去驅(qū)動(dòng)電磁鎖, P3.1輸出密碼錯(cuò)信號(hào), P3.2輸出報(bào)警控制信號(hào)去驅(qū)動(dòng)報(bào)警器,。1腳為復(fù)位端,4腳,、5腳接晶振,,各元器件參數(shù)如圖所示,。該電路鍵盤由16個(gè)按鍵組成,15個(gè)“數(shù)字”鍵, 1個(gè)“輸入”鍵,; 密碼由8位數(shù)字組成(可由用戶對(duì)程序稍加修改設(shè)置為任意位數(shù)的密碼),,每位數(shù)字均可為15個(gè)數(shù)字中的任意一個(gè)數(shù),這樣組成的密碼不可破譯,,特別是當(dāng)別人不知密碼位數(shù)時(shí)更不可破譯,。
圖一
二、工作原理
通電復(fù)位,,電路進(jìn)入就緒狀態(tài),,等待用戶輸入密碼,。當(dāng)用戶輸入密碼并按下“輸入”鍵后,如輸入密碼正確則由P3.0輸出開(kāi)鎖控制信號(hào)且綠燈亮,,如輸入密碼錯(cuò)誤則由P3.1輸出密碼錯(cuò)誤指示信號(hào)紅燈亮,如連續(xù)三次輸入密碼錯(cuò)誤則由P3.2輸出報(bào)警控制信號(hào)且黃燈亮,,并且必須等待解出報(bào)警后方可重新開(kāi)鎖,。
??????? ORG? 0000H
?????? MOV P3,#0BFH
?????? MOV R4,#00H
BEGIN: MOV R0,#01FH
?????? MOV R3,#00H
KEY? : MOV P1,#0FH
?????? MOV A,P1
?????? ANL A,#0FH
?????? CJNE A,#0FH,KEY1
?????? SJMP KEY
?KEY1: MOV P3,#0BFH
?????? LCALL DEL12
?????? MOV A,#0EFH
?KEY2: MOV R2,A
?????? MOV P1,A
?????? MOV A,P1
?????? ANL A,#0FH
?????? CJNE A,#0FH,KEY3
?????? MOV A,R2
?????? SETB C
?????? RLC A
?????? JC KEY2
?????? SJMP KEY
?KEY3: MOV B,#0FBH
?KEY4: RRC A
?????? INC B
?????? JC KEY4
?????? MOV A,R2
?????? SWAP A
?KEY5: RRC A
?????? INC B
?????? INC B
?????? INC B
?????? INC B
?????? JC KEY5
?KEY6: MOV A,P1
?????? ANL A,#0FH
?????? CJNE A,#0FH,KEY6
?????? LCALL DEL12
?????? LCALL OPREAT
?????? LJMP KEY
DEL12: MOV R6,#01EH
?DEL2: MOV R7,#64H
?DEL1: DJNZ R7,DEL1
?????? DJNZ R6,DEL2
?????? RET
OPREAT:INC R0
?????? MOV A,B
?????? MOV @R0,A
?????? CJNE A,#0FH,COUNT
?????? CJNE R3,#08H,ERROR
?????? MOV R1,#20H
?????? MOV B,#00H
?????? MOV DPTR,#TAB
?LOOP: MOV A,B
?????? MOVC A,@A+DPTR
?????? CLR C
?????? SUBB A,@R1
?????? JNZ ERROR
?????? INC R1
?????? INC B
?????? DJNZ R3,LOOP
?OPEN: MOV P3,#0BEH
?????? LJMP $
ERROR: MOV P3,#0BDH
?????? INC R4
?????? CJNE R4,#03H,AGAIN
ALARM: MOV P3,#0B9H
?????? LJMP $
AGAIN: LJMP BEGIN
COUNT: INC R3
?????? RET
TAB:DB 01H,03H,05H,07H,02H,04H,06H,08H
END