數(shù)字密碼鎖的設(shè)計源代碼_第1頁
數(shù)字密碼鎖的設(shè)計源代碼_第2頁
數(shù)字密碼鎖的設(shè)計源代碼_第3頁
數(shù)字密碼鎖的設(shè)計源代碼_第4頁
數(shù)字密碼鎖的設(shè)計源代碼_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、咸寧學(xué)院學(xué)士學(xué)位論文電子與信息工程學(xué)院本 科 畢 業(yè) 論 文論文題目 數(shù)字密碼鎖的設(shè)計 學(xué)生姓名 學(xué) 號 專 業(yè) 電子信息科學(xué)與技術(shù) 班 級 電信 指導(dǎo)教師 2010年5月3湖北科技學(xué)院學(xué)士學(xué)位論文摘 要基于atmega88v設(shè)計的數(shù)字密碼鎖是以atmega88v為核心控制電路,配以電源電路、復(fù)位電路、指示電路、報警電路、鍵盤電路等外圍電路,實(shí)現(xiàn)對密碼的輸入、識別、修改、存儲及輸入密碼錯誤時報警等功能。該系統(tǒng)中,atmega88v是輸入和輸出的聯(lián)系部件,它通過讀取從鍵盤輸入的數(shù)據(jù)并對存儲在單片機(jī)中的密碼進(jìn)行識別比較,判斷密碼是否輸入正確,并作出相應(yīng)的決定,指示報警器是否發(fā)出嗡鳴聲以及發(fā)光二極管

2、是否閃爍。這種密碼鎖以其安全性高、成本低、易操作等優(yōu)點(diǎn)受到越來越多人的歡迎。關(guān)鍵詞:密碼鎖;atmega88v;鍵盤;lcd顯示abstractthe core control circuit of digital code lock designed based on atmega88v is atmega88v,and together with the power circuit, reset circuit, indicating circuit, alarm circuit, keyboard and other peripheral circuits circuit it can

3、realize the function of input, identification, modification, storage of the password, and the alarm when inputting the wrong password. in the system, atmega88v is the link of input and output components, it can estimate whether the input password is right by identifying and comparing the data readin

4、g from the keyboard and the password stored in the microcontroller, and make the appropriate decision that whether the indicating alarm audible hum and the light diode blinking. because of its high security, low cost, easy operation, etc, this digital code lock is more and more popular. key words: d

5、igital code lock; atmega88v; keyboard; lcd display19參考文獻(xiàn)目 錄1.緒 論12. 課題設(shè)計方案32.1 整體方案選擇32.2 控制器的選擇52.2.1 51系列單片機(jī)概述52.2.2 pic系列52.2.3 avr系列63.系統(tǒng)的主要器件93.1 atmega88v單片機(jī)簡介93.2 液晶顯示模塊0802114.硬件設(shè)計154.1 單片機(jī)的最小系統(tǒng)154.2 鍵盤電路164.3 顯示電路174.4 報警電路185.軟件設(shè)計196.調(diào)試216.1 軟件調(diào)試216.2 硬件調(diào)試217. 結(jié)論與展望23參考文獻(xiàn)25附錄a(原理圖):27附錄b(p

6、cb圖):28附錄c(實(shí)物圖):29附錄d(main.c):30 參考文獻(xiàn)1 朱璇,唐曉茜,殷建軍基于單片機(jī)智能加密電子密碼鎖設(shè)計j輕工機(jī)械,2009.82 孟祥忠.數(shù)字電子密碼鎖的設(shè)計d.大連理工,2007.63 劉瀟婷.基于fpga的紅外遙控電子密碼鎖的實(shí)現(xiàn)d.大連海事大學(xué),2008.34 邱燕,鄧鵬戈數(shù)字電子密碼鎖j現(xiàn)代電子技術(shù),2010.75 王紅航,張華斌.電子密碼鎖的eda設(shè)計與實(shí)現(xiàn)j.電子元器件應(yīng)用,2009.66 陳華麗,何顏平.基于vhdl的數(shù)字密碼鎖設(shè)計j.研究與開發(fā),2008.87 羅維,葛亦斌,邱燁,盛蒙蒙.基于at89s52電子密碼鎖系統(tǒng)的設(shè)計j.數(shù)字技術(shù)與應(yīng)用,20

7、09.78 張毅剛.新編mcs-51單片機(jī)應(yīng)用設(shè)計m.哈爾濱:哈爾濱工業(yè)大學(xué)出版社,2003.69 張培仁.基于c語言編程mcs-51單片機(jī)原理與應(yīng)用m.北京:清華大學(xué)出版社,2002.1010 耿德根avr單片機(jī)將領(lǐng)導(dǎo)八位單片機(jī)新潮流8051將終成為歷史j電子質(zhì)量,2001,8.11 陳再清pic單片機(jī)、51單片機(jī)和avr單片機(jī)的對比分析j.電子質(zhì)量,2006.8.12 吳雙力,崔劍,王伯嶺.avr-gcc與avr單片機(jī)c語言開發(fā)m.北京:北京航空航天大學(xué)出版社出版,20041013 李廣第,朱月秀.單片機(jī)基礎(chǔ)(第3板)m北京:北京航空航天大學(xué)出版社,2007.6.14 胡漢才.高檔avr單

8、片機(jī)原理及其應(yīng)用m.北京:清華大學(xué)出版社,2008.315 mega88 atmel datasheet16 江海波,王卓然,耿德根.深入淺出avr單片機(jī):從atmega48/88/168開始m北京:中國電力出版社,2008.617 劉蘭香,張秋生.atmega128單片機(jī)應(yīng)用與開發(fā)實(shí)例m.北京:機(jī)械工業(yè)出版社,2006.4.18 李宏,張家田.液晶顯示器件應(yīng)用技術(shù)m.北京:機(jī)械工業(yè)出版社,2004.219 李廣第,朱月秀.單片機(jī)基礎(chǔ)(第3板)m北京:北京航空航天大學(xué)出版社,2007.6.20 金春林,邱慧芳.avr系列單片機(jī)c語言編程與應(yīng)用實(shí)例m.北京:清華大學(xué)出版社,2003.621 樓然

9、苗,李光飛.單片機(jī)課程設(shè)計指導(dǎo)m.北京:北京航空航天大學(xué)出版社,2007.722 李捷,陳典濤,陳建華.一種基于單片機(jī)的電子密碼鎖的設(shè)計j農(nóng)機(jī)化研究,2004.923 徐瑋.51單片機(jī)綜合學(xué)習(xí)系統(tǒng)1602字符型液晶顯示篇j電子制作,2008.824 first chip empress the system eda/ic of the electronics engineering designm25 shucheng zhu,zhenwang,tianwei zhuo,linzhong zhu. an intelligent robot based on sound source local

10、ization and ultrasound distance detectionj. department of electrical and computer engineering,the hong kong university of science and technology,hk;department of computer control system,shajiao b power smfion ltd26 陳建林,趙立紅.基于proteus的數(shù)字密碼鎖的仿真設(shè)計j.機(jī)械工程與自動化,2009.1027 李智輝,李浩瀧,白宇龍.基于51單片機(jī)密碼鎖的proteus仿真設(shè)計j.

11、電腦知識與技術(shù),2009.6附錄附 錄附錄a(原理圖):附錄b(pcb圖):附錄c(實(shí)物圖):附錄d(main.c):#include iom88v.h#include macros.h#include head.hvoid initial(void);void delay(unsigned int);void lcdinit(void); /lcd初始化void lcdbusytest(void);/lcd判忙子程序void lcdwrite(void); /lcd寫入void lcdoutput(unsigned char message); /lcd寫程序void memoryread(

12、void);void memorywrite(void);unsigned char read_eeprom(unsigned int addr);void write_eeprom(unsigned int addr, unsigned char data);void check(void);/-中斷子程序開始 -#pragma interrupt_handler pcint1_isr:iv_pcint1void pcint1_isr(void) unsigned char i,j = 0;keyboard = pinc&0x3f;for(i=1;i=6;i+)j = keyboard&bi

13、t(i-1); if(j=0)keytest13 = i + 0x30;/用于做鍵盤測試switch(i) case 1: number = 3; break; case 2: number = 6; break; case 3: number = 2; break; case 4: number = 5; break;case 5: number = 1; break; case 6: number = 4; break; pcifr |= bit(pcif1); /再次將標(biāo)志位清除,防止抖動/-中斷子程序 結(jié)束-/-eeprom讀寫程序 開始-void write_eeprom(unsig

14、ned int addr, unsigned char data) while(eecr&(1eewe); eear = addr; eedr = data; cli(); eecr |= (1eemwe); eecr |= (1eewe); sei(); unsigned char read_eeprom(unsigned int addr) while(eecr&(1eewe); eear = addr; eecr |= (1eere); return eedr;/-eeprom讀寫程序 結(jié)束-/-eeprom數(shù)據(jù)存取 開始-void memoryread(void) password0

15、= read_eeprom(0x01); password1 = read_eeprom(0x02); password2 = read_eeprom(0x03); password3 = read_eeprom(0x04); password4 = read_eeprom(0x05); password5 = read_eeprom(0x06); password6 = read_eeprom(0x07); password7 = read_eeprom(0x08);void memorywrite(void) write_eeprom(0x01,setpassword8); write_e

16、eprom(0x02,setpassword9); write_eeprom(0x03,setpassword10); write_eeprom(0x04,setpassword11); write_eeprom(0x05,setpassword12); write_eeprom(0x06,setpassword13); write_eeprom(0x07,setpassword14); write_eeprom(0x08,setpassword15); write_eeprom(0x10,0x88);/-eeprom數(shù)據(jù)存取 結(jié)束-/-延時子程序 開始-void delay(unsigned

17、 int delaytime) unsigned int temp1=0;/*臨時變量*/ unsigned int temp2=0;/*臨時變量*/ for(temp1=1;temp1=delaytime;temp1+) for (temp2=1;temp2 0;i-) lcdwrite();portb = 0x38; /數(shù)據(jù)總線8位,顯示行數(shù)2行,字符5*7點(diǎn)陣lcdwrite();portb = 0x06; /向ddram寫入一個字符后,ac自動加1;顯示畫面不移動lcdwrite();portb = 0x0f;/開顯示,光標(biāo)顯示,閃爍lcdwrite();portb = 0x01;/清

18、屏lcdwrite();lcdoutput(welcomelcd);sei();/-lcd初始化 結(jié)束-/-lcd判忙 開始-void lcdbusytest(void) int busytest = 1;rs_clear; /指令rw_set; while(busytest=1) e_set; busytest = pinb&0x80; e_clear;/-lcd判忙 結(jié)束-/-lcd輸出 開始-void lcdoutput(unsigned char message)unsigned char i = 0;cli();lcdbusytest();rs_clear; /指令portb = 0

19、x03;lcdwrite();for(i=0;i16;i+) if(i=8)lcdbusytest(); rs_clear; portb = 0x0c0; lcdwrite(); lcdbusytest();rs_set;portb = messagei;lcdwrite();sei();/-lcd輸出 結(jié)束-/- check 開始-void check(void)unsigned char i = 0;passwordcheck = 0;for(i=0;i8;i+)if(inputpasswordi+8=passwordi)passwordcheck+;/- check 結(jié)束-/-主程序 開

20、始-void main (void)unsigned char i = 0;initial();/系統(tǒng)初始化if(read_eeprom(0x10)=0x88)memoryread();state = 1;columnnum = 0;elsestate = 0;while(1)keyboard = pinc&0x3f;if(keyboard=0x2e)write_eeprom(0x08,0x00);state = 0;columnnum = 0;keyboard = 0xff;if(state=0)if(columnnum=0)lcdoutput(setpassword);lcdbusytes

21、t();rs_clear;portb = 0x0c0;lcdwrite();columnnum = 1;switch(number)case 0:break;case 1:memorywrite();lcdoutput(save);for(i=0;i8;i+)setpasswordi+8 = ;state = 1;columnnum = 0;number = 0;break;case 2:if(setpasswordcolumnnum+7=0x39)setpasswordcolumnnum+7 = 0x30;lcdbusytest();rs_set;portb = setpasswordcol

22、umnnum+7;lcdwrite();lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();delay(100);lcdbusytest();rs_set;portb = *;lcdwrite();lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();number = 0;break;case 3:lcdoutput(cancel);for(i=0;i8;i+)setpasswordi+8 = ;state = 1;columnnum = 0;n

23、umber = 0;break;case 4:if(columnnum=1)columnnum = 1;elsecolumnnum-;lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();number = 0;break;case 5:if(setpasswordcolumnnum+70x30)setpasswordcolumnnum+7 = 0x30;elsesetpasswordcolumnnum+7-;if(setpasswordcolumnnum+7=8)columnnum = 8;elseif(setpassw

24、ordcolumnnum+7=0x30)columnnum+;lcdbusytest();rs_clear;portb = 0x0c0 + columnnum - 1;lcdwrite();number = 0;break;elseif(columnnum=0)lcdoutput(inputpassword);lcdbusytest();rs_clear;portb = 0x0c0;lcdwrite();columnnum = 1;switch(number)case 0:break;case 1:memoryread();check();if(passwordcheck=8)/portd &= bit(4);lcdoutput(right);delay(30);/portd |= bit(4);else portd &= bit(4);lcdoutput(wrong);portd |= bit(4);for(i=0;i8;i+)inputpasswordi+8 = ;state = 1;columnnum = 0;number = 0;break;case 2:if(inputpasswordcolum

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論