【正文】
II Electronic cipher lock of Intelligence ABSTRACT Alone with the constantly development of science and technology today ,the promotion of quality of life ,it bees more and more important to how to bring about the family to guard against theft .Because of the simple construct of traditional machine lock, and the key is easy to lock . As a new tool to guard against theft, Access Control System of Intelligence is provided of its safer confidentiality, and using the vivid good, the high of safe coefficient. The design takes STC89C52 as its processing unit of heart, simplifying the design of hardware circuit, saving cost. It controls operation mode of circuit by program of chip, and import cipher by the keyboard. When checking 3 times false cipher, it can bring about prompt to give an alarm. Electronic lock is simple machine in everyday life, which is replaced by LED light in the design. When giving out light, meaning that the lock is open. The software design adoption the design thought from top to bottom, to make the system toward development of small, strengthen the stability of system. Test result indicated that the design can achieve the demand of market. Keyword STC89C52/ Electronics lock/ 1 目 錄 中文摘要 ???????????????????????? I 英文摘要 ????????????????????????Ⅱ 1 緒論 ????????????????????????? 3 課題背景及意義 ?????????????????? 3 智能 紅外遙控門 的發(fā)展趨勢 ????????????? 4 2 系統(tǒng)總體方案設(shè)計 ??????????????????? 5 智能 紅外遙控門 的設(shè)計要求 ????????????? 5 總體設(shè)計方案選定 ????????????????? 6 3 硬件設(shè)計 ??????????????????????? 6 單片機簡介 ????????????????????? 6 主要特征 ???????????????????? 6 引腳介紹 ???????????????????? 7 液晶顯示 1602 介紹 ????????????????? 9 硬件電路設(shè)計 ??????????????????? 11 最小系統(tǒng)設(shè)計 ?????????????????? 12 紅外遙控介紹 ??????????????????? 13 遙控發(fā)射器及編碼 ?? ??????????????? 13 遙控 接收及其解碼 ? ???????????????? 13 顯示電路設(shè)計 ?????????????????? 14 4 軟件設(shè)計 ?????????????????????? 15 2 軟件設(shè)計思路 ??????????????????? 15 5 系統(tǒng)調(diào)試 ????????????????????? 18 焊接注意事項 ??????????????????? 18 硬件調(diào)試及問題解決 ???????????????? 19 6 總結(jié) ???????????????????????? 21 致謝 ?????????????????????????? 22 參考文獻 ???????????????????????? 23 附錄 ?????????????????????????? 24 硬件原理圖 ????????????????????? 24 測試結(jié)果圖 ????????????????????? 24 程序源代碼 ????????????????????? 25 3 1 緒論 課題 背景 及意義 隨著社會科技 的進步,鎖已 發(fā)展到了密碼鎖、磁性鎖、電子鎖、激光鎖、聲控鎖等等。 電子技術(shù)的不斷發(fā)展,各類電子產(chǎn)品應(yīng)運而生,智能電子密碼鎖就是其中之一。國內(nèi)的不少企業(yè)也引進了世界上先進的技術(shù),發(fā)展前景非 ??捎^。提高電子密碼鎖之防護能力的必然途徑是報警,在金融業(yè)的許多場所有人值守、有電視監(jiān)控,具有報警功能,可以綜合物理防范和人力防范兩種作用。 ( 3) LCD 顯示在密碼正確時顯示為:綠燈亮,密碼錯誤時顯示 ERROR,輸入密碼時顯示 Password。 方案二:采用一種是用以 STC89C52為核心的單片機控制方案。 主要特性 32 可編程 I/O 線 在 F1ash編程時, P0口接收指令字節(jié),而在程序校驗時,輸出指令字節(jié),校驗時,要求外接上拉電阻。 P3 口: P3 口是一組帶有內(nèi)部上拉電阻的 8 位雙向 I/ 0 口。 9 PSEN:程序儲存允許( PSEN)輸出是外部程序存儲器的讀選通信號,當(dāng)STC89C52 由外部程序存儲器取指令(或數(shù)據(jù))時,每個機器周期兩次 PSEN有效,即輸出兩個脈沖。 XTAL2: 振蕩器反相放大器的輸出端 。 特性 : a 容易和 Bin/8Bin Mpu 相連; b 可選擇 5 7 或 5 10 點字符; c 顯示數(shù)據(jù) RAM 容量: 80 8Bin( 80 字符); d 字符發(fā)生器 ROM 能提供戶所需字符庫或標準庫;字符容量: 192 個字符( 5 11 7 點字符); 32 個字符( 5 10 點字符); e DDRAM 和 CGRAM 都能從 Mpu 讀取數(shù)據(jù); f 輸出信號: 16 個行掃信號( mon singnal), 40 個列掃信號( sengment singnal) g 電源復(fù)位電路; h 顯示占空比: 1/8duty( 1Line, 5 7dots+Cursor); 1/11 duty( 1Line,5 10dote+Cuesor); 1/16 duty( 2Line, 5 7dots+Cuesir); i 振蕩電路; j 指令: 11 種; k 80 引腳、塑封。根據(jù)應(yīng)用的要求,復(fù)位操作通常有兩種基本形式:上電復(fù)位和開關(guān)復(fù)位。這個放大器與作為反饋元件的片外石英晶體或陶瓷諧振器一起構(gòu)成自激振蕩器,振蕩電路參見圖 。這種情況下,外部時鐘脈沖接到 XTAL1端,即內(nèi)部時鐘發(fā)生器的輸入端, XTAL2則懸空。當(dāng)發(fā)射器按鍵按下后,既有遙控碼發(fā)出,所按的鍵不同遙控碼也不同。 根據(jù)紅外編碼的格式,程序應(yīng)該等待 9ms 的起始碼和 的結(jié)果碼完成后才能讀碼。因此充分利用其內(nèi)部豐富的硬件資源和軟件資源,采用與 C51系列單片機相對應(yīng)的 19 C語言和結(jié)構(gòu)化程序設(shè)計方法進行軟件編程。 5. 顯示器表面的保護膜直到焊接完成才可揭掉,禁止手指及其它硬物接觸偏光片,禁止水和其他化學(xué)物質(zhì)沾污裝置, 因為這些物質(zhì)會污染顯示器表面 。 焊接流程按照附錄所示的電子密碼鎖的硬件聯(lián)接原理圖按下列順序依次焊接: ( 1)焊接單片機的晶振電路、復(fù)位電路等單片機的最小系統(tǒng)的外圍電路。 LCD 焊接時的問題: ( 1)接通電源后 LCD 無反應(yīng),各個引腳均屬正常。在設(shè)計的過程中遇到問題,可以說得是困難重重,這畢竟第一次做的,難免會遇到過各種各樣的問題,同時在設(shè)計的過程中發(fā)現(xiàn)了自己的不足之處,對以前所學(xué)過的知識理解得不夠深刻,掌握得不夠牢固,對單片機匯編語言掌握得不好 , 通過這次課程設(shè)計之后,一定把以前所學(xué)過的知識重新溫故。在論文的選題、資料查詢、開題、研究、設(shè)計和撰寫的每一個環(huán)節(jié),都得到導(dǎo)師的悉心指導(dǎo)和幫助。 //data 區(qū) ,全局變量 .定義當(dāng)前狀態(tài)機的初始值 . volatile unsigned char KeyValue=NoKey。 unsigned char KeyScan(void)。 } unsigned char KeyScan(void) { unsigned char cord_h,cord_l,cord_key。 //讀入行線值 cord_key=cord_h|cord_l。 //39。 //ESC case 0xed:cord_key=Key4。 case 0xbd:cord_key=Key6。 //39。 //39。 case 0xd7:cord_key=Key0。 case 0x77:cord_key=KeyDOWN。 } //顯示 焦點箭頭 if(0==) { DisBuf[0][0]=0x7E。DisBuf[0][1],MenuMain[].Menu_Name)。 } //顯示 ,顯示緩沖區(qū)的內(nèi)容到 LCD GotoXY(0,0)。 //向上翻頁 if(KeyUP==KeyValue) { if(1==) { =0。 =4。 } else { if(MenuMain[PointFunIndex].Menu_Function!=0) { 30 (*MenuMain[PointFunIndex].Menu_Function)()。 Print(Is Locked now! )。 GotoXY(0,1)。 //沒有按鍵觸發(fā) for(i=0。//等待收一個功能鍵 KeyState=1。 PressErrorCnt = 0。 //顯示停頓 800ms. PressErrorCnt = 0。 Delay1ms(500)。 //按鍵判斷 WaitOneKey(2)。 } } while(1)。 //===================================================== //輸入密碼 for(i=0。 //置位 KeyState,表示已經(jīng)響應(yīng) ,防止同一按鍵重復(fù)響應(yīng) . goto EndLable_2。i++) { if(Password[i] == Passkey[i])++tmp。 //顯示停頓 800ms. PressErrorCnt = 0。 goto lable2。i++) { if(WaitOneKey(4) == KeyESC)goto lable3。 Print(===Input twice==)。 //收一個數(shù)字鍵 GotoXY(9+i,1)。 } //輸入新密碼正確的處理 if(CRC == PasswordLength) { //============================================== //寫入新輸入的密碼 for(i=0