目 录
第 1 章 综 述 ........................................ 4
1.1系统简介..................................................... 4
第2章 芯片介绍 ....................................... 4
2.1 AT89C51简介 ................................................ 4
2.1.1主要特性: ............................................ 6 2.1.2外部特性: ............................................. 5 2.1.3内部结构: ............................................ 8 2.1.4中断处理: ........................................... 10
第3章 系统扩展 ....................................... 5
3.1 LM386N-1 .................................................... 5 3.1.1 LM386N-1介绍 .......................................... 5 3.1.2 LM386N-1引脚 .........................错误!未定义书签。 3.1.3内部电路 ..............................错误!未定义书签。 3.1.4芯片特性 ..............................错误!未定义书签。
第4章 硬件设计 ....................................... 8
4.1 原理图制作 .................................................. 8 4.1.1基本结构 ............................................... 8 4.1.2 LED数码管显示电路 ....................错误!未定义书签。 4.1.3键盘电路设计 ..........................错误!未定义书签。 4.1.4报警电路设计 ........................................... 9
第5章 软件设计 ...................................... 16
5.1软件开发流程................................................ 16 5.1.2新建一个源文件并把它加入到项目中,同时增加并配置选择的器件的启动代码................................................ 16 5.1.5编译项目并生成可以编程PROM的HEX文件 ................. 17 5.2系统程序流程图.............................................. 17 5.3 按键功能 ................................................... 18 5.4密码输入错误报警功能........................................ 20
第6章 系统调试 ...................................... 22
6.1 硬件调试 ................................................... 22 6.2 软件调试 ................................................... 23
第7章 设计特点与不足 ................................ 23
7.1 设计思路 ................................................... 23 7.2 设计不足 ................................................... 23
第8章 结论 ........................................ 23
0
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
谢辞 ................................................. 25 参考文献 ............................................. 26 附 录 ........................................... 27
附录A:外文资料翻译—原文部分................................... 27
附录B:外文资料翻译—译文部分................................... 33 附录C:主要源程序代码:........................................ 39 附录D:原理图.................................................. 44 附录F:光盘资料说明............................................. 45
1
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
基于单片机的密码锁设计与制作
摘 要
在日常的生活和工作中, 住宅与部门的安全防范、单位的文件档案、财务报表以及一些个人资料的保存多以加锁的办法来解决。若使用传统的机械式钥匙开锁,人们常需携带多把钥匙, 使用极不方便, 且钥匙丢失后安全性即大打折扣。随着科学技术的不断发展,人们对日常生活中的安全保险器件的要求越来越高。为满足人们对锁的使用要求,增加其安全性,用密码代替钥匙的密码锁应运生。密码锁具有安全性高、成本低、功耗低、易操作等优点。
本系统由单片机系统、矩阵键盘、LED显示和报警系统组成。介绍了密码锁的单片机为核心,密码锁和LM386N-1单元的详细介绍和说明。本文设计的密码锁电路主要由单片机、键盘输入电路和显示电路等单元电路构成,其功能是由键盘输入5位密码,通过单片机进行密码比较,实现系统开锁的功能。本文详细的介绍了系统各个硬件的性能和作用,以及软件设计思路和主要软件模块的流程图。
本设计电路结构简单,软件功能完善,充分发挥了单片机的优点。而且保密性较高,使用灵活性好。
关键词:单片机;密码锁;LM386N-1
2
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
SCM -based electronic password locks Design and
Production ABSTRACT
In day-to-day living and working in the residential sector and the safety precautions, units of paper files, financial statements, and some personal information to the preservation of more than locking the solution to the problem. If the use of traditional mechanical key to unlock, people often need to carry more keys, a very inconvenient to use, and after the loss of key security that is greatly reduced. With the continuous development of science and technology, in the daily lives of people on insurance safety devices increasingly demanding. To meet the requirements of the use of locks to increase their security, with a password instead of the password key lock came into being. Password lock is safe, low cost, low power consumption, easy to operate, and other advantages.
The design of the remote control password lock on the MCU at the core,
password lock control unit and PTR8000 for the detailed briefing and annotations.This article designs the password locks the electric circuit mainly by the monolithic integrated circuit, unit electric circuit constitutions and so on keyboard entry electric circuit and display circuit, its function is by the keyboard entry 5 passwords, carries on the password comparison through the monolithic integrated circuit, the realization system unblanking function. This article detailed introduction system each hardware performance and function, as well as software design mentality and main software module flow chart.
This design electric circuit structure is simple, the software function is perfect,
has displayed the monolithic integrated circuit merit fully.Moreover the secrecy is high, the use flexibility is good.
3
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
第 1 章 综 述
本次毕业设计所要完成的主要内容是利用AT89C51单片机及相应的接口芯片设计一个基于单片机的密码锁系统。先由程序设定密码,按键扫描输入,进行密码比较,正确发出信号,错误则发出警报。
1.1系统简介
单片机又称单片微控制器,它不是完成某一个逻辑功能的芯片,而是把一个计算机系统集成到一个芯片上。概括的讲:一块芯片就成了一台计算机。它的体积小、质量轻、价格便宜、为学习、应用和开发提供了便利条件。同时,学习使用单片机是了解计算机原理与结构的最佳选择。 等等等等。。。。。。
第2章 芯片介绍
MCS-51单片机 等等等等。。。。。。
2.1 AT89C51简介
AT89C51单片机是美国ATMEL公司生产的低功耗,高性能CMOS 8位单片机,片内含4K bytes的可系统编程的Flash只读程序存储器,器件采用ATMEL公司的高密度,非易失性存储技术生产,兼容标准8051指令系统及引脚。它集Flash程序存储器,既可在线编程(ISP)也可用传统方法进行编程及通用8位微处理器于单片芯片中,ATMEL公司的功能强大,低价AT89C51单片机可为您提供许多高性价比的应用场合,可灵活应用于各种控制领域。
2.1.1主要特性:
4
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
2.1.2 管脚说明:
AT89C51芯片有40条引脚,双列直插式封装引脚图所示:
2.1.3 内部结构:
2.1.4 中断处理
第3章 系统扩展
由于要求对报警进行控制,因此该系统中,我将使用LM386N-1音频放大芯片。LM386N-1 是一种音频集成功放,具有自身功耗低、电压增益可调整、电源电压范围大、外接组件少和总谐波失真小等优点,广泛应用于录音机和收音机之中。
3.1 LM386N-1
3.1.1 LM386N-1介绍
LM386是美国国家半导体公司生产的音频功率放大器,主要应用于低电压消费类产品。为使外围组件最少,电压增益内置为20。但在1脚和8脚之间增加一只外接电阻和电容,便可将电压增益调为任意值,直至200。输入端以地位参考,同时输出端被自动偏置到电源电压的一半,在6V电源电压下,它的静态功耗仅为24mW,使得LM386特别适用于电池供电的场合。LM386的封装形式有塑封8引线双列直插式和贴片式。 3.1.2 LM386N-1引脚
LM386 的外形和引脚的排列如下图所示。引脚2为反相输入端,为同相输入端;3引脚5为输出端;引脚6和4分别为电源和地;引脚1和8为电压增益设定端;使用时在引脚7和地之间接旁路电容,通常取10μF。
5
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
3.1.3 内部电路
LM386内部电路原理图如图所示。与通用型集成运放相类似,它是一个三级放大电路。
第一级为差分放大电路,T1和T3、T2和T4分别构成复合管,作为差分放大电路的放大管;T5和T6组成镜像电流源作为T1和T2的有源负载;T3和T4信号从管的基极输入,从T2管的集电极输出,为双端输入单端输出差分电路。使用镜像电流源作为差分放大电路有源负载,可使单端输出电路的增益近似等于双端输出电容的增益。
第二级为共射放大电路,T7为放大管,恒流源作有源负载,以增大放大倍数。 第三级中的T8和T9管复合成PNP型管,与NPN型管T10构成准互补输出级。二极管D1和D2为输出级提供合适的偏置电压,可以消除交越失真。
引脚2为反相输入端,引脚3为同相输入端。电路由单电源供电,故为OTL电路。输出端(引脚5)应外接输出电容后再接负载。
6
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
电阻R7从输出端连接到T2的发射极,形成反馈通路,并与R5和R6构成反馈网络,从而引入了深度电压串联负反馈,使整个电路具有稳定的电压增益。 3.1.4 芯片特性
1.静态功耗低,约为 4mA,可用于电池供电。 2.工作电压范围宽,4-12V or 5-18V。 3.外围组件少。
4.电压增益可调,20-200。 5.低失真度。
电源电压4-12V或5-18V(LM386N-4);静态消耗电流为4mA;电压增益为20-200dB;在1、8脚开路时,带宽为300KHz;输入阻抗为50K;音频功率0.5W。
尽管LM386的应用非常简单,但稍不注意,特别是器件上电、断电瞬间,甚至工作稳定后,一些操作(如插拔音频插头、旋音量调节钮)都会带来的瞬态冲击,在输出喇叭上会产生非常讨厌的噪声。
1、通过接在1脚、8脚间的电容(1脚接电容+极)来改变增益,断开时增益为20dB。因此用不到大的增益,电容就不要接了,不光省了成本,还会带来好处--噪音减少。
2、PCB设计时,所有外围元件尽可能靠近LM386;地线尽可能粗一些;输入音频信号通路尽可能平行走线,输出亦如此。这是死理,不用多说了吧。
3、选好调节音量的电位器。质量太差的不要,否则受害的是耳朵;阻值不要太大,10K最合适,太大也会影响音质,转那么多圈圈,不烦那!
4、尽可能采用双音频输入/输出。好处是:“+”、“-”输出端可以很好地抵消共模信号,故能有效抑制共模噪声。
5、第7脚(BYPASS)的旁路电容不可少!实际应用时,BYPASS端必须外接一个电解电容到地,起滤除噪声的作用。工作稳定后,该管脚电压值约等于电源电压的一半。增大这个电容的容值,减缓直流基准电压的上升、下降速度,有效抑制噪声。在器件上电、掉电时的噪声就是由该偏置电压的瞬间跳变所致。
6、减少输出耦合电容。此电容的作用有二:隔直 + 耦合。隔断直流电压,直流电压过大有可能会损坏喇叭线圈;耦合音频的交流信号。它与扬声器负载构成了一阶高通滤波器。减小该电容值,可使噪声能量冲击的幅度变小、宽度变窄;
7
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
太低还会使截止频率(fc=1/(2π*RL*Cout))提高。分别测试,发现10uF/4.7uF最为合适,这是我的经验值。
7、电源的处理,也很关键。由于电压不同、负载不同以及并联的去耦电容不同,每组电源的上升、下降时间必有差异。可行的方法:将上电、掉电时间短的电源放到+12V处,选择上升相对较慢的电源作为LM386的Vs,但不要低于4V!
第4章 硬件设计
4.1 原理图制作
4.1.1基本结构
电子密码锁主要有密码输入、密码比较、结果输出组成。硬件结构简图下图3.1所示。
AT89C51正确开锁 输入密码 单片机错误发出警报
4.1.2 LED数码管显示电路
密码显示使用四路静态数码显示管进行显示。
1位共阴极数码管用单片机P2.0-P2.7 八个I/O口控制。 LED数码管与单片机连接电路如下图所示。
8
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
4.1.3键盘电路设计
键盘是标准的输入设备,实现键盘有两种方案:一是采用现有的一些芯片实现键盘扫描,如8279, CH451,LMC9768等,还有就是用软件实现键盘扫描。使用现成的芯片可以节省CPU的开销,但增加了成本,而用软件实现具有较强的灵活性,也只需要很少的CPU开销,可以节省开发成本。本文便使用软件实现键盘的扫描。
常见的键盘可分为独立按键式键盘和行列扫描式键盘。独立按键式键盘应用在需要少量按键的情况,按键和单片机的I/O口线直接连接。而行列扫描式键盘用在按键需求较多的情形下。考虑到血压计面向大多数人群,需操作简单,所以采用独立按键式键盘。
独立式键盘电路如下图所示。
9
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
4.1.4报警电路设计
声音报警电路通过驱动蜂鸣器发声实现,当其接通5V的电压会发出蜂鸣叫声。
第5章 软件设计
5.1软件开发流程
5.1.1启动Keil uVision3新建一个项目文件并从器件库中选择一个器件
Keil uVision3是一个标准的windows应用程序,直接点击图标就可以启动
他。要新建一个项目可以从Keil uVision3的project菜单中选择New project。会打开一个标准的windows对话框,并对此输入项目文件名。然后选择符合设计要求的芯片型号。
10
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
图5-1 新建工程
5.1.2新建一个源文件并把它加入到项目中,同时增加并配置选择的器件的启动代码
由菜单选项File-New来新建一个源文件,在空的编辑窗口中输入源代码并
把该文件另存为new.ASM的文件后Keil uVision3将显示汇编语言语法字符,创建了源文件后就可以把将其加入到项目中。之后将程序敲入,并编译调试程序直到无错通过编译。
图5-2选择器件的启动代码
5.1.5编译项目并生成可以编程PROM的HEX文件
HEX文件格式是Intel公司提出的按地址排列的数据信息,数据宽度为字节,所有数据使用16进制数字表示, 常用来保存单片机或其他处理器的目标程序代码。它保存物理程序存储区中的目标代码映像。一般的编程器都支持这种格式。打开它的所在目录,找到。Uv2的文件即可以打开先前的项目了。选Options for Target’Target1’,弹出项目选项设置窗口,同样先选中项目文件夹图标,这时在Project菜单中也有一样的菜单可选。打开项目选项窗口,转到Output选项页创建HEX文件,编译后就在信息窗口中就显示HEX文件了。
11
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
图5-3生成HEX文件
5.2系统程序流程图
系统程序流程图如图5.12所示。
开 始 初始化 输入密码 密码比较 密码正确 显示通过 密码错误 3次错误 报警
图5.12 系统程序流程图
12
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
5.3 按键功能
其中一个按键为功能键,另一个按键为数字键。在输入过程中,首先输入密码的长度,接着根据密码的长度输入密码的位数,直到所有长度的密码都已经输入完毕;或者输入确认功能键之后,才能完成密码的输入过程。进入密码的判断比较处理状态并给出相应的处理过程。初始化时,是允许按键输入密码,当有按键按下并开始进入按键识别状态时,按键禁止功能被激活,但启动的状态在3次密码输入不正确的情况下发生的。
void main(void) { unsigned char i,j; P2=dispcode[digitcount]; TMOD=0x01; TH0=(65536-500)/256; TL0=(65536-500)%256; TR0=1; ET0=1; EA=1; while(1) { if(cmpflag==0) { if(P3_6==0) //function key { for(i=10;i>0;i--) for(j=248;j>0;j--); if(P3_6==0) { if(hibitflag==0) { funcount++; if(funcount==pslen+2) { funcount=0; cmpflag=1; } P1=dispcode[funcount]; } else { second3=0; } while(P3_6==0); } }
13
上海第二工业大学 计算机与信息学院本科毕业设计(论文)
if(P3_7==0) //digit key { for(i=10;i>0;i--) for(j=248;j>0;j--); if(P3_7==0) { if(hibitflag==0) { digitcount++; if(digitcount==10) { digitcount=0; } P2=dispcode[digitcount]; if(funcount==1) { pslen=digitcount; templen=pslen; } else if(funcount>1) { psbuf[funcount-2]=digitcount; } } else { second3=0; } while(P3_7==0); } } } else { cmpflag=0; for(i=0;i 上海第二工业大学 计算机与信息学院本科毕业设计(论文) } hibitflag=0; cmpflag=0; } } 5.4密码输入错误报警功能 当密码输入正确之后,锁就打开,如果输入的三次的密码不正确,就锁定按键3秒钟,同时发现报警声,直到没有按键按下3种后,才打开按键锁定功能;否则在3秒钟内仍有按键按下,就重新锁定按键3秒时间并报警。 void t0(void) interrupt 1 using 0 { TH0=(65536-500)/256; TL0=(65536-500)%256; if((errorflag==1) && (rightflag==0)) { bb++; if(bb==800) { bb=0; alarmflag=~alarmflag; } if(alarmflag==1) { P0_0=~P0_0; } aa++; if(aa==800) { aa=0; P0_1=~P0_1; } second3++; if(second3==6400) { second3=0; hibitflag=0; errorflag=0; rightflag=0; cmpflag=0; P0_1=1; alarmflag=0; 15 上海第二工业大学 计算机与信息学院本科毕业设计(论文) bb=0; aa=0; } } if((errorflag==0) && (rightflag==1)) { P0_1=0; cc++; if(cc<1000) { okflag=1; } else if(cc<2000) { okflag=0; } else { errorflag=0; rightflag=0; hibitflag=0; cmpflag=0; P0_1=1; cc=0; oka=0; okb=0; okflag=0; P0_0=1; } if(okflag==1) { oka++; if(oka==2) { oka=0; P0_0=~P0_0; } } else { okb++; if(okb==3) { okb=0; 16 上海第二工业大学 计算机与信息学院本科毕业设计(论文) P0_0=~P0_0; } } } } 第6章 系统调试 6.1 硬件调试 我首先用protel画好原理图,正确无误后去购买电子元器件。我使用的是 面包板,所以就是手工的对电子元件进行布局,这是一个十分讲究的事,第一次我没有考虑到这个细节,结果各引脚靠的太近使我无法继续下去,只能又重新做了一块板,在吸取了教训之后,我进行了合理的布局,在焊接的时候轻松了许多。由于对元件的不熟悉以及焊接时候的粗心,弄坏了好几个元件,不得不去了好几次电子广场。 6.2 软件调试 在软件调试过程中,出现了一系列错误,首先对一些打错,漏打之类的问题 进行检查和排除。遇到了一些不能解决的问题,我通过网络和书籍努力寻找问题的所在,继而寻求老师的帮助,终于顺利的通过了编译。 第7章 设计特点与不足 7.1 设计思路 首先需要对各个芯片引脚地址进行初始化。在初始化完成后,重置系统。通 过输入密码进行验证,将信号传输给AT89C51芯片,进行密码比较,密码正确则通过,3次不正确通过LM386N-1芯片发出报警声。 17 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 7.2 设计不足 由于设计时的偷懒,想借用其他有串口的电路板对我的芯片进行烧录程和修 改,没有考虑到芯片的脆弱性,在插拔芯片的过程中弄坏了好几块芯片,浪费了不少时间。另外,由于使用面包板,所以导线之间的干扰是避免不了的。 第8章 结论 在完成这次毕业实际的过程中,我遇到了不少困难,因为是第一次做一个完整的51单片机,在经验和知识运用上都缺乏有效的结合。在这样的情况下,我不得不去借了很多关于51单片机方面的书,还到网上找了很多的有关资料,结合自己上课所学的课程,在不断的失败错误中摸索着,终于完成了自己的毕业设计,也为我在原有的基础上得到了巩固。 我做到尽我所能,找了很多有关的资料书籍,对51单片机的功能特点进行了详细的了解。先用protel dpx 2004绘制电路原理图,并焊接了电路板,再通过keil3编译所需要的程序,运用flip下载烧录程序到芯片上,并不断调试寻找错误,让我的毕业设计尽可能完善。 二个月的时间,让我体会到了编程者的辛酸,从各类书籍到各类资料,让我收获了很多有用的东西,收益匪浅。在解决不了之处,我寻求了导师的帮助,导师也很积极耐心的指导我,帮我纠正了一系列的错误,也让我搞懂了一些概念模糊的地方。 18 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 谢辞 在这次毕业设计中,我要衷心感谢黄丽佳老师,每周她都能对我进行有效的辅导,当遇到难题的时候,她甚至会一整天和我一起想办法解决问题,令我避免了很多设计中的错误,使我十分感动,也使我更一步巩固了我学的知识。 19 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 参考文献 [1] 曾一江.单片微机原理与接口技术.出版社:科学出版社.2006年2月 [2] 周兴华.手把手教你学单片机.出版社:北京航空航天大学出版社.2005年4月 [3] 王玉良,戴志涛,杨紫珊.微机原理与接口技术. 出版社:北京邮电大学出版社.2001 年6月 [4] 张迎新.单片微型计算机原理应用及接口技术(第2版).出版社:国防工业出版 社.2005.9 [5] 朱定华,张小惠,刘福珍.微机原理与接口技术.出版社:武汉大学出版社 [6] 徐爱钧,彭秀华.单片机高级语言C51应用程序设计.出版社:电子工业出版社.1999 [7] 陈龙三.8051单片机C语言控制与应用.出版社:清华大学出版社.1999 [8] 陈明荧.8051单片机课程设计实训教材.出版社:清华大学出版社. [9] 求是科技.单片机典型模块设计实例导航(第2版).出版社:人民邮电出版 社.2008-7 [10] 米昶.Protel 2004电路设计与仿真.出版社:机械工业出版社.2006.1 20 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 附 录 附录A:外文资料翻译—原文部分 Semiconductor A semiconductor is a solid material that has electrical conductivity between those of a conductor and an insulator; it can vary over that wide range either permanently or dynamically.[1] Semiconductors are important in electronic technology. Semiconductor devices, electronic components made of semiconductor materials, are essential in modern consumer electronics, including computers, mobile phones, and digital audio players. Silicon is used to create most semiconductors commercially, but dozens of other materials are used. Bragg reflection in a diffuse lattice A second way starts with free electrons waves. When fading in an electrostatic potential due to the cores, due to Bragg reflection some waves are reflected and cannot penetrate the bulk, that is a band gap opens. In this description it is not clear, while the number of electrons fills up exactly all states below the gap. Energy level splitting due to spin state Pauli exclusion A third description starts with two atoms. The split states form a covalent bond where two electrons with spin up and spin down are mostly in between the two atoms. Adding more atoms now is supposed not to lead to splitting, but to more bonds. This is the way silicon is typically drawn. The band gap is now formed by lifting one electron from the lower electron level into the upper level. This level is known to be anti-bonding, but bulk silicon has not been seen to lose atoms as easy as electrons are wandering through it. Also this model is most unsuitable to explain how in graded hetero-junction the band gap can vary smoothly. Energy bands and electrical conduction Like in other solids, the electrons in semiconductors can have energies only within certain bands (ie. ranges of levels of energy) between the energy of the ground state, corresponding to electrons tightly bound to the atomic nuclei of the material, and the free electron energy, which is the energy required for an electron to escape entirely from the material. The energy bands each correspond to a large number of discrete quantum states of the electrons, and most of the states with low energy (closer to the nucleus) are full, up to a particular band called the valence band. Semiconductors and insulators are distinguished from metals because the valence band in the semiconductor materials is very nearly full under usual operating conditions, thus causing more electrons to be available in the conduction band. The ease with which electrons in a semiconductor can be excited from the valence band to the conduction band depends on the band gap between the bands, and it is the size of this energy bandgap that serves as an arbitrary dividing line (roughly 4 eV) between semiconductors and insulators. 21 上海第二工业大学 计算机与信息学院本科毕业设计(论文) In the picture of covalent bonds, an electron moves by hopping to a neighboring bond. Because of the Pauli exclusion principle it has to be lifted into the higher anti-bonding state of that bond. In the picture of delocalized states, for example in one dimension that is in a wire, for every energy there is a state with electrons flowing in one direction and one state for the electrons flowing in the other. For a net current to flow some more states for one direction than for the other direction have to be occupied and for this energy is needed. For a metal this can be a very small energy in the semiconductor the next higher states lie above the band gap. Often this is stated as: full bands do not contribute to the electrical conductivity. However, as the temperature of a semiconductor rises above absolute zero, there is more energy in the semiconductor to spend on lattice vibration and — more importantly for us — on lifting some electrons into an energy states of the conduction band, which is the band immediately above the valence band. The current-carrying electrons in the conduction band are known as \"free electrons\context allows this usage to be clear. Electrons excited to the conduction band also leave behind electron holes, or unoccupied states in the valence band. Both the conduction band electrons and the valence band holes contribute to electrical conductivity. The holes themselves don't actually move, but a neighboring electron can move to fill the hole, leaving a hole at the place it has just come from, and in this way the holes appear to move, and the holes behave as if they were actual positively charged particles. One covalent bond between neighboring atoms in the solid is ten times stronger than the binding of the single electron to the atom, so freeing the electron does not imply destruction of the crystal structure. Holes: electron absence as a charge carrier The notion of holes, which was introduced for semiconductors, can also be applied to metals, where the Fermi level lies within the conduction band. With most metals the Hall effect reveals electrons to be the charge carriers, but some metals have a mostly filled conduction band, and the Hall effect reveals positive charge carriers, which are not the ion-cores, but holes. Contrast this to some conductors like solutions of salts, or plasma. In the case of a metal, only a small amount of energy is needed for the electrons to find other unoccupied states to move into, and hence for current to flow. Sometimes even in this case it may be said that a hole was left behind, to explain why the electron does not fall back to lower energies: It cannot find a hole. In the end in both materials electron-phonon scattering and defects are the dominant causes for resistance. Fermi-Dirac distribution. States with energy ε below the Fermi energy, here μ, have higher probability n to be occupied, and those above are less likely to be occupied. Smearing of the distribution increases with temperature. The energy distribution of the electrons determines which of the states are filled and which are empty. This distribution is described by Fermi-Dirac statistics. The distribution is characterized by the temperature of the electrons, and the Fermi energy or Fermi level. Under absolute zero conditions the Fermi energy can be thought of as the energy up to which available electron states 22 上海第二工业大学 计算机与信息学院本科毕业设计(论文) are occupied. At higher temperatures, the Fermi energy is the energy at which the probability of a state being occupied has fallen to 0.5. The dependence of the electron energy distribution on temperature also explains why the conductivity of a semiconductor has a strong temperature dependency, as a semiconductor operating at lower temperatures will have fewer available free electrons and holes able to do the work. Energy–momentum dispersion In the preceding description an important fact is ignored for the sake of simplicity: the dispersion of the energy. The reason that the energies of the states are broadened into a band is that the energy depends on the value of the wave vector, or k-vector, of the electron. The k-vector, in quantum mechanics, is the representation of the momentum of a particle. The dispersion relationship determines the effective mass, m , of electrons or holes in the semiconductor, according to the formula: * The effective mass is important as it affects many of the electrical properties of the semiconductor, such as the electron or hole mobility, which in turn influences the diffusivity of the charge carriers and the electrical conductivity of the semiconductor. Typically the effective mass of electrons and holes are different. This affects the relative performance of p-channel and n-channel IGFETs, for example (Muller & Kamins 1986:427). The top of the valence band and the bottom of the conduction band might not occur at that same value of k. Materials with this situation, such as silicon and germanium, are known as indirect bandgap materials. Materials in which the band extrema are aligned in k, for example gallium arsenide, are called direct bandgap semiconductors. Direct gap semiconductors are particularly important in optoelectronics because they are much more efficient as light emitters than indirect gap materials. Carrier generation and recombination When ionizing radiation strikes a semiconductor, it may excite an electron out of its energy level and consequently leave a hole. This process is known as electron–hole pair generation. Electron-hole pairs are constantly generated from thermal energy as well, in the absence of any external energy source. Electron-hole pairs are also apt to recombine. Conservation of energy demands that these recombination events, in which an electron loses an amount of energy larger than the band gap, be accompanied by the emission of thermal energy (in the form of phonons) or radiation (in the form of photons). 23 上海第二工业大学 计算机与信息学院本科毕业设计(论文) In some states, the generation and recombination of electron–hole pairs are in equipoise. The number of electron-hole pairs in the steady state at a given temperature is determined by quantum statistical mechanics. The precise quantum mechanical mechanisms of generation and recombination are governed by conservation of energy and conservation of momentum. As the probability that electrons and holes meet together is proportional to the product of their amounts, the product is in steady state nearly constant at a given temperature, providing that there is no significant electric field (which might \"flush\" carriers of both types, or move them from neighbour regions containing more of them to meet together) or externally driven pair generation. The product is a function of the temperature, as the probability of getting enough thermal energy to produce a pair increases with temperature, being approximately 1×exp(−EG / kT), where k is Boltzmann's constant, T is absolute temperature and EG is band gap. The probability of meeting is increased by carrier traps – impurities or dislocations which can trap an electron or hole and hold it until a pair is completed. Such carrier traps are sometimes purposely added to reduce the time needed to reach the steady state. Doping The property of semiconductors that makes them most useful for constructing electronic devices is that their conductivity may easily be modified by introducing impurities into their crystal lattice. The process of adding controlled impurities to a semiconductor is known as doping. The amount of impurity, or dopant, added to an intrinsic (pure) semiconductor varies its level of conductivity. Doped semiconductors are often referred to as extrinsic. Dopants The materials chosen as suitable dopants depend on the atomic properties of both the dopant and the material to be doped. In general, dopants that produce the desired controlled changes are classified as either electron acceptors or donors. A donor atom that activates (that is, becomes incorporated into the crystal lattice) donates weakly-bound valence electrons to the material, creating excess negative charge carriers. These weakly-bound electrons can move about in the crystal lattice relatively freely and can facilitate conduction in the presence of an electric field. (The donor atoms introduce some states under, but very close to the conduction band edge. Electrons at these states can be easily excited to conduction band, becoming free electrons, at room temperature.) Conversely, an activated acceptor produces a hole. Semiconductors doped with donor impurities are called n-type, while those doped with acceptor impurities are known as p-type. The n and p type designations indicate which charge carrier acts as the material's majority carrier. The opposite carrier is called the minority carrier, which exists due to thermal excitation at a much lower concentration compared to the majority carrier. For example, the pure semiconductor silicon has four valence electrons. In silicon, the most common dopants are IUPAC group 13 (commonly known as group III) and group 15 (commonly known as group V) elements. Group 13 elements all contain three valence electrons, causing them to function as acceptors when used to dope silicon. Group 15 elements have five valence electrons, which allows them to act as a donor. Therefore, a silicon 24 上海第二工业大学 计算机与信息学院本科毕业设计(论文) crystal doped with boron creates a p-type semiconductor whereas one doped with phosphorus results in an n-type material. Carrier concentration The concentration of dopant introduced to an intrinsic semiconductor determines its concentration and indirectly affects many of its electrical properties. The most important factor that doping directly affects is the material's carrier concentration. In an intrinsic semiconductor under thermal equilibrium, the concentration of electrons and holes is equivalent. That is, n = p = ni If we have a non-intrinsic semiconductor in thermal equilibrium the relation becomes: n0 * p0 = (ni) Where n is the concentration of conducting electrons, p is the electron hole concentration, and ni is the material's intrinsic carrier concentration. Intrinsic carrier concentration varies between materials and is dependent on temperature. Silicon's ni, for example, is roughly 1.6×10 cm at 300 kelvin (room temperature). In general, an increase in doping concentration affords an increase in conductivity due to the higher concentration of carriers available for conduction. Degenerately (very highly) doped semiconductors have conductivity levels comparable to metals and are often used in modern integrated circuits as a replacement for metal. Often superscript plus and minus symbols are used to denote relative doping concentration in semiconductors. For example, n denotes an n-type semiconductor with a high, often degenerate, doping concentration. Similarly, p would indicate a very lightly doped p-type material. It is useful to note that even degenerate levels of doping imply low concentrations of impurities with respect to the base semiconductor. In crystalline intrinsic silicon, there are approximately 5×1022 atoms/cm³. Doping concentration for silicon semiconductors may range anywhere from 1013 cm-3 to 1018 cm-3. Doping concentration above about 1018 cm-3 is considered degenerate at room temperature. Degenerately doped silicon contains a proportion of impurity to silicon in the order of parts per thousand. This proportion may be reduced to parts per billion in very lightly doped silicon. Typical concentration values fall somewhere in this range and are tailored to produce the desired properties in the device that the semiconductor is intended for. + − 10 -3 2 Effect on band structure Doping a semiconductor crystal introduces allowed energy states within the band gap but very close to the energy band that corresponds with the dopant type. In other words, donor impurities create states near the conduction band while acceptors create states near the valence band. The gap between these energy states and the nearest energy band is usually referred to as dopant-site bonding energy or EB and is relatively small. For example, the EB for boron in silicon bulk is 0.045 eV, compared with silicon's band gap of about 1.12 eV. Because EB is so small, it takes little energy to ionize the dopant atoms and create free carriers in the conduction or valence bands. 25 上海第二工业大学 计算机与信息学院本科毕业设计(论文) Usually the thermal energy available at room temperature is sufficient to ionize most of the dopant. Dopants also have the important effect of shifting the material's Fermi level towards the energy band that corresponds with the dopant with the greatest concentration. Since the Fermi level must remain constant in a system in thermodynamic equilibrium, stacking layers of materials with different properties leads to many useful electrical properties. For example, the p-n junction's properties are due to the energy band bending that happens as a result of lining up the Fermi levels in contacting regions of p-type and n-type material. This effect is shown in a band diagram. The band diagram typically indicates the variation in the valence band and conduction band edges versus some spatial dimension, often denoted x. The Fermi energy is also usually indicated in the diagram. Sometimes the intrinsic Fermi energy, Ei, which is the Fermi level in the absence of doping, is shown. These diagrams are useful in explaining the operation of many kinds of semiconductor devices. Preparation of semiconductor materials Semiconductors with predictable, reliable electronic properties are necessary for mass production. The level of chemical purity needed is extremely high because the presence of impurities even in very small proportions can have large effects on the properties of the material. A high degree of crystalline perfection is also required, since faults in crystal structure (such as dislocations, twins, and stacking faults) interfere with the semiconducting properties of the material. Crystalline faults are a major cause of defective semiconductor devices. The larger the crystal, the more difficult it is to achieve the necessary perfection. Current mass production processes use crystal ingots between four and twelve inches (300 mm) in diameter which are grown as cylinders and sliced into wafers. Because of the required level of chemical purity and the perfection of the crystal structure which are needed to make semiconductor devices, special methods have been developed to produce the initial semiconductor material. A technique for achieving high purity includes growing the crystal using the Czochralski process. An additional step that can be used to further increase purity is known as zone refining. In zone refining, part of a solid crystal is melted. The impurities tend to concentrate in the melted region, while the desired material recrystalizes leaving the solid material more pure and with fewer crystalline faults. In manufacturing semiconductor devices involving heterojunctions between different semiconductor materials, the lattice constant, which is the length of the repeating element of the crystal structure, is important for determining the compatibility of materials. 26 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 附录B:外文资料翻译—译文部分 半导体 半导体是一种导电性能介于导体与绝缘体之间的固体材料。它能在此之间永久地或动态地变化。 半导体在电子技术中有着非常重要的地位。半导体设备,由半导体材料制成的电子元件与现代消费电子产品诸 如电脑,移动电话和数位录放音机等有着极为密切的关联。硅是商业应用上用做制造半导体的物质,此外还有许多其他物质也被用做制造半导体。 晶格中的布拉格反射 第二种说法是自由电子流。当由于核的作用而导致静电势下降,因为布拉格反射一些自由电子流被反射而不能穿透,就形成了一个能带隙。当能量较低的价带被电子完全填满时,这种描述就不是那么清楚了。 由于自旋态包利不相容导致的能级分裂 第三种说法是两个原子。分离抬形成一个两个电子在两个原子间的自旋的共价键。新增的原子不应导致分裂,而是增加了价带。这就是硅通常被提取的方法。能隙是由一个电子获得能量从低能态跳跃至高能态而形成的。这一能态被认为是反键。但是大量的硅并没有像电子流动一样失去原子那么简单。同样,这个模型也不适合去解释在渐变抑制结中能隙是怎么样顺畅地变化。 能带和导电 就像其他固体一样,在半导体中的电子所具有的能量被限制在基态与自由电子之间的几个“能带”里,也就是电子完全离开此材料所需要的能量。当电子在基态时,相当于此电子被束缚在原子核附近。每个能带都有数个相对应的量子态,而在这些量子态中,能量较低的都已经被电子所填满,能量最高的就被称为价带。半导体和绝缘体不同与金属就是因为半导体材料中的价带与导电带之间的能隙很小,电子容易获得能量而跳跃至导电带。 半导体中的电子是否易于从价带上跳跃至导电带取决于能隙和充当半导体和绝缘体导电能力分界线(一般是4eV)的能带宽度。 图中的共价键,一个电子跳跃到邻近的价带上。因为包利不相容原理,电子 27 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 被提升到一个那个价带更高的反键态。在非域态图中,诸如在一维空间中就像在一条电线上,由于每个能量都是由电子在某一个状态下向某个方向定向移动。对一个网状电流来说,要使电子流向某一状态下的一个方向是需要一定能够的能量的。对一个金属来说,只需要一个非常小的能量,在半导体中需要一个比能隙更高的状态。这种状态经常被描述为:最高的对电导率无影响的价带。然而,当温度开始上升,高于绝对零度时,半导体中有许多能量被晶体震动和对我们来说更为重要的使电子跳入价带之上的传导带中所消耗,在传导带中的载流子被称为自由电子,尽管在文章不引起歧义的情况下,他们经常被简称为电子。 在价带内的电子获得能量后跃升至传导带时,便会在价带内留下一个空缺,也就是所谓的“电洞”。传导带中的电子和价带中的电洞都对电流传递有贡献。电洞本身不会移动,但是其他电子可以移动到这个电洞上面,并且同样留下一个电洞在其本身位置上,这样就等效于电洞本身往电子移动的相反方向移动,这样的行为就使得电洞的电性呈正电。 固体原子间的共价键的强度是单个电子与原子间约束力的十倍,所以要想让电子自由化并不是简单的打破晶体结构而已。 电洞:电子缺失而形成的电荷载体 被引入半导体理论的电洞的概念,同样也可以应用于导体传导带内的费米能阶。对大多数金属来说,霍尔效应显示电子是电荷载体,但是有一些金属具有几乎完全被填充的传导带,霍尔效应呈正电荷载体不是离子核心而是电洞。有这种特征的导体有盐水溶液,等离子体。在一个金属中,电子不需要很大的能量即可找到空缺的量子态供其跳跃、造成电流传导。。有时甚至可以说成一个电洞产生了,去解释为什么电子为什么没有落回低能状态:因为它找不到一个电洞。最后电-光子散射和逃逸是阻抗的最主要原因。 费米-狄拉克分布.当能量态ε低于费米能阶μ,就有一个较高的几率n被电子占据,而在这之上的,被电子占据的几率就小的多了。能量分布函数受到温度很大的影响。 电子的能态分布取决于其能级是否被占据。这种分布函数称为费米-狄拉克统计。这种分布函数与电子的温度有很大关系,费米能阶,在温度低于绝对零度的条件下可以被认为是能力上升之电子能态被占据。当温度高于绝对零度时,费米能阶 28 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 为所有能阶中,被电子占据几率等于0.5的能阶。 电子能量分布取决于温度同样解释了为什么半导体的导电性非常依赖于温度,如半导体在一个较低的温度工作时只有少数的自由电子和电洞可以工作。 能量-动量色散 上述关于能带结构的内容为了简化,因此跳过了一个重要的现象:称为“能量的色散”。同一个能带内之所以会有不同能量的量子态,原因是能带的电子具有不同波向量,或是k-向量。在量子力学中,k-向量即为粒子的动量 能量-动量色散关系式能决定电子或电洞的“等效质量”,以m*代表,公式如下: 等效质量对于半导体材料而言十分重要,例如它和电子或电洞的迁移率有高度的关联,电子或电洞的迁移率影响着半导体的载子传输和电导率。 电子和电洞的等效质量一般来说并不相同。这就影响了P-通道和N-通道MOSFET导电性不同。 半导体材料的传导带底部和价带顶端在能量-动量坐标上可能会处在不同的k值,这种材料叫做“间接能隙材料”,例如硅或是锗。相对地,如果某种材料的传导带底部和价带顶端有相同的k值,这种材料称为“直接能隙材料”,最常见的例子是砷化镓。直接能隙半导体在光电子学中是非常重要的,因为它的发光效率高过间接能隙材料很多。 载子的产生和复合 当离子化的辐射能量落在半导体时,可能会让价带中的电子吸收到足够能量而跃迁至传导带,并在价带中产生一个电洞,这种过程叫做“电子-电洞对的产生”。而其他够大的能量,如热能,也可以同样产生出电子-电洞对。 电子-电洞对则会经由复合的过程而被消灭。根据能量守恒的观念,在传导带中的电子必须回到价带,将所得到的能量释放出来。能量释放的形式包括热能(以声子的形式)或辐射能(以光子的形式)。 在某些状态下,电子-电洞对的产生和复合速率是相等的。对于处于稳态的电子-电洞对,在一个已给定的温度下,其数量可由量子统计求得。量子力学处理此类问题时必须同时遵守能量守恒和动量守恒。 29 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 就像电子和电洞同时相遇的概率与他们产生的数量是成比例一样,产物对在处于一个恒定温度下的稳态时,不会提供一个非常明显的电场(可能激活载流子的两种形态,促使它们向邻近的区域移动使他们相遇)或者外在的受迫对产生。产物是温度的一个作用,就如同温度可以提升得到足够的热能产生电子-电洞对的概率,近似的可用用公式1×exp(−EG / kT)表示,k是麦克斯韦-玻尔兹曼常量,T是绝对温度, EG是能隙。 载流子复合中心通过捕捉电子或电洞来完成配对来增加它们的相遇的几率,复合中心可以是杂质。像这样的载流子复合中心有时被故意添加到半导体里,以降低到稳态所需的时间。 半导体的掺杂 半导体之所以能广泛应用在今日的数位世界中,凭借的就是其能借由在其晶格中植入杂质改变其电性,这个过程称之为掺杂。掺杂进入本质半导体的杂质浓度与极性皆会对半导体的导电特性产生很大的影响。而掺杂过的半导体则称为外质半导体。 掺杂物 哪种材料适合作为某种半导体材料的掺杂物需视两者的原子特性而定。一般而言,掺杂物依照其带个被掺杂材料的电荷正负被区分为受体与施体。施体原子带来的价电子大多会与被掺杂的材料原子产生共价键,进而被束缚。而没有和被掺杂材料原子产生共价键的电子则会被施体原子微弱地束缚住,这个电子又称为施体电子。和本质半导体的价电子比起来,施体电子跃迁至传导带所需的能量较低,比较容易在半导体材料的晶格中移动,产生电流。虽然施体电子获得能量会跃迁至传导带,但并不会和本质半导体一样留下电洞,施体原子在失去了电子后会固定在半导体材料的晶格中。因此这种因为掺杂而获得多余电子提供传导的半导体称为n型半导体,和施体相对的,受体掺杂后的半导体称为p型半导体。n和p分别代表着材料中的多数载流子。相对的,另一种载流子就称为少数载流子。少数载流子的存在取决于相对多数载流子而言较低浓度的热激励。 以一个硅的本质半导体来说明杂质的影响。硅有四个价电子,常用于硅的掺杂物有三价与五价的元素。当只有三价元素掺杂至硅半导体中时,三价元素扮演 30 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 受体的角色。五价元素掺杂至硅半导体中,则五价元素扮演施体的角色。因此,一个硅半导体中掺杂了硼的就是p型半导体。若掺杂了磷的就成为n型半导体。 载子浓度 掺杂物浓度对于半导体最直接的影响在于其载子浓度。在热平衡的状态下,一个未经掺杂的本质半导体,电子与电洞的浓度相等,如下列公式所示: n = p = ni 如果我们有一个非本质半导体,在热平衡的状态下,其关系就变为: n0 * p0 = (ni)2 n是半导体内的电子浓度,p则是半导体的电洞浓度,ni则是本质半导体的载子数目。ni会随着材料或温度的不同而改变。对于室温下(300K)的硅而言, ni大约是1.6×1010 cm-3。 通常掺杂浓度越高,半导体的导电性就会变得越好,原因是能进入传导带的电子数量会随着掺杂浓度提高而增加。掺杂浓度非常高的半导体会因为导电性接近金属而被广泛应用在今日的集成电路制程来取代部分金属。高掺杂浓度通常会 +在n或是p后面附加一上标的“+”号,例如n 表示掺杂浓度非常高的n型半导 体,反之例如p 则代表轻掺杂的p型半导体。需要特别说明的是即使掺杂浓度已经高到让半导体“退化”为导体,掺杂物的浓度和原本的半导体原子浓度比起来还是差距非常大。以一个有晶格结构的硅本质半导体而言,原子的浓度大约是5×1022 atoms/cm³,而一般集成电路制程里的掺杂浓度约在1013 cm-3至1018 cm-3之间。掺杂浓度在1018 cm-3以上的半导体在室温下通常会被视为一个“简并半导体”。重掺杂的半导体中,掺杂物和半导体原子的浓度比约是千分之一,而轻掺杂则可能会到十亿分之一的比例。在半导体制程,掺杂浓度都会依照所制造出元件的需求量身打造,以合于使用者的需求。 掺杂对搬到能带结构的影响 掺杂之后的半导体的能带会有所改变。依照掺杂物的不同,本质半导体的能隙之间会出现不同的能阶。施体原子会在靠近传导带的地方产生一个新的能阶,而受体原子则是在靠近价带的地方产生新的能阶。假设掺杂硼原子进入硅,则因为硼的能阶到硅的价带之间仅有0.045电子伏特,远小于硅本身的能隙1.12电 − 31 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 子伏特,所以在室温下就可以使掺杂到硅里的硼原子完全解离化。 掺杂物对于能带结构的另一个重大影响是改变了费米能阶的位置。在热平衡的状态下费米能阶依然会保持定值,这个特性会引出很多其他有用的电特性。举例来说,一个p-n接面后其费米能阶必须保持在同样的高度,造成无论是p型半导体或是n型半导体的传导带或价带都会被弯曲以配合接面处的能带差异。 上述的效应可以用能带图来解释,在能带图里横轴代表位置,纵轴则是能量。图中也有费米能阶,半导体的本质费米能阶通常以Ei来表示。在解释半导体元件的行为时,能带图是非常有用的工具。 半导体材料的制造 为了满足量产上的需求,半导体的电性必须是可预测并且稳定的,因此包括掺杂物的纯度以及半导体晶格结构的品质都必须严格要求。常见的品质问题包括晶格的错位、双晶面、或是堆栈错误都会影响半导体材料的特性。对于一个半导体元件而言,材料晶格的缺陷通常是影响元件性能的主因。晶格越大,就越难达到其结构的要求。当今的量产过程使用的晶锭直径在四至十二英寸(300mm)之间 目前用来成长高纯度单晶半导体材料最常见的方法称为裘可拉斯基制程。这种制程将一个单晶的晶种放入溶解的同材质液体中,再以旋转的方式缓缓向上拉起。在晶种被拉起时,溶质将会沿着固体和液体的接口固化,而旋转则可让溶质的温度均匀。 在制造半导体设备的行业里,涉及到不同半导体材料之间的异质结,重复元件晶格结构的长度晶格常数,材料的兼容性是非常重要的。 32 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 附录C:主要源程序代码: #include unsigned char code ps[]={1,2,3,4,5}; unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40}; unsigned char pslen=9; unsigned char templen; unsigned char digit; unsigned char funcount; unsigned char digitcount; unsigned char psbuf[9]; bit cmpflag; bit hibitflag; bit errorflag; bit rightflag; unsigned int second3; unsigned int aa; unsigned int bb; bit alarmflag; bit exchangeflag; unsigned int cc; unsigned int dd; bit okflag; unsigned char oka; unsigned char okb; void main(void) { unsigned char i,j; P2=dispcode[digitcount]; TMOD=0x01; TH0=(65536-500)/256; TL0=(65536-500)%256; TR0=1; ET0=1; EA=1; while(1) { 33 上海第二工业大学 计算机与信息学院本科毕业设计(论文) if(cmpflag==0) { if(P3_6==0) //function key { } if(P3_7==0) //digit key { for(i=10;i>0;i--) for(j=248;j>0;j--); if(P3_7==0) { if(hibitflag==0) { digitcount++; if(digitcount==10) { } P2=dispcode[digitcount]; if(funcount==1) { } pslen=digitcount; templen=pslen; digitcount=0; for(i=10;i>0;i--) for(j=248;j>0;j--); if(P3_6==0) { } if(hibitflag==0) { } else { } while(P3_6==0); second3=0; funcount++; if(funcount==pslen+2) { } P1=dispcode[funcount]; funcount=0; cmpflag=1; 34 上海第二工业大学 计算机与信息学院本科毕业设计(论文) } else if(funcount>1) { } psbuf[funcount-2]=digitcount; else { second3=0; } while(P3_7==0); } } } else { cmpflag=0; for(i=0;i } cc=0; errorflag=0; rightflag=1; hibitflag=0; a: cmpflag=0; } } } void t0(void) interrupt 1 using 0 { TH0=(65536-500)/256; TL0=(65536-500)%256; if((errorflag==1) && (rightflag==0)) { bb++; 35 上海第二工业大学 计算机与信息学院本科毕业设计(论文) if(bb==800) { bb=0; alarmflag=~alarmflag; } if(alarmflag==1) { P0_0=~P0_0; } aa++; if(aa==800) { aa=0; P0_1=~P0_1; } second3++; if(second3==6400) { second3=0; hibitflag=0; errorflag=0; rightflag=0; cmpflag=0; P0_1=1; alarmflag=0; bb=0; aa=0; } } if((errorflag==0) && (rightflag==1)) { P0_1=0; cc++; if(cc<1000) { okflag=1; } else if(cc<2000) { okflag=0; } else { errorflag=0; 36 上海第二工业大学 计算机与信息学院本科毕业设计(论文) rightflag=0; hibitflag=0; cmpflag=0; P0_1=1; cc=0; oka=0; okb=0; okflag=0; P0_0=1; } if(okflag==1) { oka++; if(oka==2) { oka=0; P0_0=~P0_0; } } else { okb++; if(okb==3) { okb=0; P0_0=~P0_0; } } } } 37 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 附录D:原理图 38 上海第二工业大学 计算机与信息学院本科毕业设计(论文) 附录F:光盘资料说明 1.目录结构 根目录:王晓清 根目录下文件:论文,源程序,原理图 39 因篇幅问题不能全部显示,请点此查看更多更全内容