【正文】
。具體方法為: 單擊 “工程菜單 /為目標 ?目標 1?設置選項 ”選項,彈出窗口,點擊 “Debug”按鈕。 KEIL 是一款具有強悍功能的 51 系列兼容單片機 C 語言軟件開發(fā)系統(tǒng),為用 戶 提供豐富的庫函數(shù)和功能強大的集成開發(fā)調試工具, 其 生成目標代碼的效率非常之高,且多數(shù)語句生成的匯編代碼很緊湊,容易理解。當不小心輸錯密碼時,可以退格將輸錯的位清除,退格一次密碼的位數(shù)減一位,同時顯示器上的 “*”個數(shù)也減 1。 開始 發(fā)送起始命令 分別取高 8 位地址和低 8 位地址 結束 發(fā)送寫器件地址 發(fā)送應答信號 發(fā)高 8 位地址 發(fā)低 8 位地址 發(fā)送應答信號 發(fā)送應答信號 發(fā)送非應答信號 發(fā)送停止命令 發(fā)送起始命令 發(fā)送讀器件 地址 發(fā)送應答信號 將讀出的數(shù)據(jù)送出 西南科技大學本科生畢業(yè)論文 24 圖 47 為實現(xiàn)此功能的程序流程圖。 讀隨機地址內容:開始 → 寫器件地址 → 響應 → 要讀的字節(jié)地址 → 響應 →開始 → 讀器件地址 → 響應 → 數(shù)據(jù) → 無響應 → 停止。數(shù)據(jù)輸出完畢后,主機發(fā)送停止信號,讀操作完畢。 圖 45 將字節(jié)寫入 AT24C02 的程序流程圖 開始 發(fā)送起始命令 分別取高 8 位地址和低 8 位地址 結束 發(fā)送寫器件地址 發(fā)送應答信號 發(fā)高 8 位地址 發(fā)低 8 位地址 發(fā)送應答信號 發(fā)送應答信號 發(fā)送數(shù)據(jù) 發(fā)送應答信號 發(fā)送停止命令 西南科技大學本科生畢業(yè)論文 22 ( 2)頁寫。AT24C02 有 2 種不同的寫操作形式和 3 種不同的讀操作方式。 西南科技大學本科生畢業(yè)論文 20 e=1。 //e 由 1→0 跳變時為執(zhí)行命令 delay(1)。 下面為 LCD1602 寫命令子函數(shù)和寫數(shù)據(jù)子函數(shù)。 在本設計中, ~ 為行輸出口, ~ 為列輸出口。 采用一行一行的掃描方法,逐行輸出 0,然后讀列的值。 西南科技大學本科生畢業(yè)論文 15 第 4章 軟件設計 軟件總體設計 根據(jù)電子密碼鎖的實際應用要求和其應該具有的功能,本次 設計的主程序流程圖如圖 41 所示。圖 310 是用蜂鳴器模擬的報警機構仿真圖。 WP=0,允許單片機進行讀 西南科技大學本科生畢業(yè)論文 13 寫操作。數(shù)據(jù)發(fā)送或者接收的時鐘從此引腳輸入。 1 2 3 4 5 6 7 8 9 ACK SCL SDA P 起始信號 停止信號 西南科技大學本科生畢業(yè)論文 12 1 5 2 6 AT24C01 3 7 4 8 A0 A1 A2 Vss Vcc WP SCL SDA AT24C02簡介 AT24C02 是 Atmel 公司生產(chǎn)的 AT24CXX 系列串行 E2PROM 中的一種,是具有 I2C 總線接口功能的電可擦除串行存儲器。圖 36 中的第 9 個時鐘脈沖對應于應答位。 I2C 總線上所有的外圍器件都有規(guī)范的器件地址,器件地址有 7 位組成,它和 1 位方向為構成了 I2C 總線器件的尋址字節(jié)。 表 31 是 LCD1602 的 16 個引腳和引腳對應功能。 當確定有鍵被按下時,通過逐行掃描,讀出 I/O 口的值可以知道哪一行的值被改變了,被改變了的行即是被按下的按鍵所在行。 圖 34 是 4x4 矩陣鍵盤在 PROTEUS 中的電路原理仿真圖。在單片機工作后,如果還想再次復位,只需按下開關,單片機就能重新變成復位狀態(tài)。因為單片機已經(jīng)包含了數(shù)據(jù)存儲器和程序存儲器,所以只要在其外部加上時鐘電路和復位電路就可以構成單片機最小系統(tǒng)。 基于實際情況,在設計中,用發(fā)光二極管代替電磁鎖,二極管亮則代表鎖開, 二極管不亮則代表鎖關。 本設計應該按以下步驟去實現(xiàn): 第一步:選擇材料和器件。相對于笨重而構造簡單的傳 統(tǒng)機械鎖來說,電子密碼鎖具有體積小,可靠性高的優(yōu)勢。電子密碼鎖雖然有安全性高、操作簡單等優(yōu)點,但是卻不如機械鎖價格低廉,因此,在市場上的主流產(chǎn)品還是機械鎖。特別是傳統(tǒng)的機械鎖,由于其構造簡單,在慣偷面前,甚至能夠只用一根鐵絲就直接將其打開,使其失去 了保障用戶個人財產(chǎn)安全的意義。 (3)能夠報警。 關鍵詞 :單片機;密碼鎖;電子鎖;矩陣鍵盤;掉電存儲 西南科技大學本科生畢業(yè)論文 II The Design Of Electronic Code Lock Based On Single Chip Microputer Abstract: As sealed device, the lock added to such objects like door, box, drawer etc, can be opened with specified key. Since the ancient time, lock is a kind of security, guaranteeing people?s property safety even life safety. With the development of human history and more attention paid to property safety and life safety, various multifunctional locks can be seen in the world. Traditional mechanical locks people use in life are gradually replaced by electronic bination lock characterized with better safety performance and more functions. In the modern society, electronic bination lock is a noun familiar to everyone. Usually, the door of munity is equipped with electronic bination lock. This paper will introduce an electronic bination lock. This lock controls the electric circuits and the performance of chips by identifying password. Thus, the openness and closeness of the lock can be controlled, and the task of electronic lock device can be pleted. This design is about bination lock, based on the AT89C51 singlechip microputer as the core of controlling goals. This design in which the AT89C51 singlechip microputer as the core of the controlling goals cooperated with relevant circuits and software programs can achieve such functions like password input and modification, information display, keyboard locking, warning system, and the openness and closeness of the lock etc. In this design, the openness of lock and alarming are according to identifying the password, and password revision and storage is achieved by the function of the AT24C02 serial storage. Electronic bination lock described in this paper is characterized with high security, low power consumption, and simplicity of operation etc. Keywords: Singlechip microputer, Combination lock, Electronic lock, Matrix keyboard, Power lost storage 西南科技大學本科生畢業(yè)論文 III 目錄 第 1章 緒論 .................................................................................................................. 1 電子密碼鎖簡介 ................................................................................................. 1 電子密碼鎖設計的背景及意義 ......................................................................... 1 電子密碼鎖 的現(xiàn)狀及 發(fā)展趨勢 ......................................................................... 2 第 2章 總體設計 .......................................................................................................... 3 設計分析 ............................................................................................................. 3 系統(tǒng)結構 ............................................................................................................. 4 第 3章 硬件電路設計 .................................................................................................. 5 單片機接口分配 ................................................................................................. 5 單片機最小系統(tǒng)設計 ......................................................................................... 5 時鐘電路 ....................................................................................................... 5 復位電路 ....................................................................................................... 6 最小系統(tǒng) ....................................................................................................... 6 矩陣鍵盤設計 ..................................................................................................... 7 LCD 顯示模塊設計 ............................................................................................. 8 掉電存儲模塊 ................................................................................................... 10