【正文】
moto.1995. Realization of PID Controls by Fuzzy Control Methods.Fuzzy Sets and Systems[17]Serial Infrared Physical Layer Specification, Version . October 15,1998,IBM corporation ,HewlettPackard Company, Sharp Inc. [18]Link Management Protocol ,Version 23,1996,IBM Corporation. [19]Serial Infrared Link Access Protocol(IrLAP),Version . June 16, 1996,IBM Corporation , [20]HewlettPackard Company, Apple Computer, Inc., Counterpoint Systems Foundry, Inc. [21]AT24C01 datasheet. 32 / 53The Device of Infrared Electronic Lock in Code Based on single chip DeviceTang Jianguo(College of Engineering, South China Agricultural University Guangzhou 510640, China)Abstract:Along with the exaltation of social science and the living level of people, how carry out the family to guard against theft, this problem also change particularly of the simple construct of traditional machine lock,the affairs of theft is electronics lock is safer because of its confidentiality, using the vivid good, the safe coefficient is high, being subjected to the large customer close.The Infrared Electronic lock is a kind of to take the high strength password sequence as the foundation, on board the password switch that carry out in the single slice. It is the information medium with the Infrared, thus carrying out to control from a distance, can also provide with a structure simple contact type munication to connect, and hard to broken. This lock have the usage that convenience, operation simple, and the price cheap etc. so it can bring convenient to the our it is applicable to those special place where is damage of human body, for example high radiation area, high infection area etc. It can carry out the key information to register in the main on board initial attestation, the password information encrypt, the red unauthorized biography lose, and the key throws to lose to discard etc. Go to correspond by letter the principle according to the string between 51 machines, make use of infrared to deliver, this is easy to encrypt and protect to the passwords information the adoption is infrared from a distance outside opposite lock is have more advantage to the electronics bination lock that keyboard input in the machine. For example, infrared ray shoot equip adoption infrared diode, control from a distance shoot the machine is easy to make the production smaller and cheaper。Adopt the numerical signal codes,not only can carry out many controls of the road information, increase the remote control function, raise the anti interference that signal deliver, reduce the mistake action,but also the power consume is low。The infrared ray will not reveal toward outdoors, will not produce a disturb of signal。Respond quickly,the efficiency deliver is high, work stable credibility etc. So the infraredcontrol uses extensive correspondence and controls from a distance the means currently. The software design adoption the design thought from top to bottom, to make the 33 / 53system toward wear distribute type,turn to the direction development of small, strengthen the system and can expand the stability and the result enunciation, various functions of this system are already all request of this design.Key words:Infrared ray, Remote control, Codelock, single chip0 / 53附 錄附錄 1 主要元器件清單序號 名稱 型號及規(guī)格 數(shù)量1 單片機(jī) AT89S52 22 存儲器 AT24C01 23 紅外一體化接收頭 TL1838 24 紅外發(fā)射二極管 LED 25 晶振 26 發(fā)光二極管(紅) ED 17 發(fā)光二極管(黃) LED 18 三極管 9015 49 穩(wěn)壓電源 5V 110 電池盒 四芯 111 萬用板 單面 112 撥碼開關(guān) MD8 113 按鍵 微動 514 ISP 座 DC2-10P 215 排阻 A103G10kΩ 116 可調(diào)電阻 W103326T1kΩ 217 電阻 177。1% 518 電阻 177。1% 219 電阻 177。1% 220 電阻 177。1% 421 電解電容 105℃50V22uF177。20% 222 電解電容 105℃50V10uF177。20% 223 陶瓷電容 NOP50V33pF177。10% 41 / 5324 電解電容 NOP50V100pF177。10% 1附錄 2 程序清單/*本設(shè)計(jì)的程序分為從機(jī)和主機(jī)兩部分,由于篇幅所限,以下程序只給出主程序 *//*******************************從機(jī)主程序**********************************/include include include include include include include /*AT89S5X SFR定義()*/sfr AUXR = 0x8e。sfr WDTRST = 0xa6。sfr WDTPRG =0xA7。sfr16 TIMEER2 = 0xcc。sfr16 RCAP2 = 0xca。define WDIDLE (14)sbit KEY_START=P3^3。sbit LIGHT_REG_OK=P3^7。sbit OUT_38K =P2^7。const DWORD id=15600。extern uchar RecBuf[7]。extern uchar WrIdx。2 / 53extern bit DataOK。define FRAME_HEAD_SLAVE 0x23uchar SndBuf[7]={39。\039。}。uchar *RecCmd=(uchar *)amp。RecBuf[1]。uchar *SndCmd=(uchar *)amp。SndBuf[1]。DWORD rand_num。DWORD *RecData=(DWORD *)amp。RecBuf[2]。DWORD *SndData=(DWORD *)amp。SndBuf[2]。bit isConnected。uchar code my_num=0。sbit S1=P1^7。sbit S2=P1^6。sbit S3=P1^5。sbit S4=P1^4。sbit S5=P1^3。sbit S6=P1^2。sbit S7=P1^1。sbit S8=P1^0。uchar time=0。void ClrWdt(void)//喂狗{WDTRST = 0x1e。//89s52內(nèi)狗WDTRST = 0xe1。//89s52內(nèi)狗}void delay(void){ uchar i,j。3 / 53 for(i=100。i0。i) for(j=100。j0。j)。}void send_data(void){REN = 0。 //關(guān)接受send_string(SndBuf,6)。REN = 1。 //允許接受}void init(void){ LIGHT_REG_OK=0。 isConnected =0。 T2CON = 0x00。 // 16 Bit AutoReload Mode RCAP2H = (6553532767)/256。 // 重裝值 RCAP2L = (6553532767)%256。 TH2 = (6553532767)/256。 TL2 = (6553532767)%256。 ET2 = 1。 TR2 = 1。 SndBuf[0]=FRAME_HEAD_SLAVE。 TMOD |=0x02。 TH0= 0xF4。 ET0 =1。 TR0 =1。 init_m()。 EA =1。 P1=0。}4 / 53void main(void){ init()。 send_string(Hello,5)。 AUXR |= WDIDLE。PCON |= GF0_ | IDL_。//喂瘋狗(GF0_=1) 并進(jìn)入空閑狀態(tài)(IDL_=1) WDTPRG |=0x06。 ClrWdt()。while(1) { if(!isConnected) {bit Key=0。if(KEY_START==0) { delay()。 if(KEY_START==0) { Key=1。 } while(KEY_START==0)。/*ClrWdt()。*/ }if(Key) { *SndCmd=CMD_COME。 send_data()。 S1=1。 }} ClrWdt()。5 / 53if(time=150) //150*32767* us = { time =0。 send_string(idle,4)。 ET0 = 0。 ET2 = 0。 EX0 = 1。 EX1 = 1。 WrIdx = 0。 ClrWdt()。 PCON |= IDL_。 } if(DataOK)