摘 要 该论文是利用单片机设计一个符合PC-AT编码格式的小键盘。由于单片机的广泛应用和标准的键盘有体积大,编码位置固定,不可更换等缺陷,在许多场合下不能满足应用及研制要求,并且要求小键盘的键码可以通过标准的RS232或者手工操作方式进行设定,可以应用单片机构成嵌入式系统来设计。 因此作者尝试着用MCS-51系列单片机做键盘的扫描控制电路核心构成行列式键盘,采用程序扫描法识别按下的键,利用AT24C01A芯片来存储和需要修改时修改键盘键码。的当有按键按下时,MCS-51单片机通过键盘接口向PC传送与按键位置相对应的按键键码。当需要修改按键键码时,可以通过MCS-51单片机的串行口和PC机的串行口COM1或COM2进行通信,将键码传送给PC机并显示在相应的界面上,通过PC机的界面修改相应的键码,从而达到可以修改小键盘键码的目的。 该论文是在通过对单片机知识、PC机串行通信、键盘基本原理、以及PROTEL 99SE的学习的基础上进行电路设计,并最终完成该论文的。
关键词:单片机;串行通信;键盘接口 ABSTRACT This paper is using the monolithic integrated circuit to conform to the PC-AT code form small keyboard. Because the widespread application of monolithic integrated circuit and the standard keyboard has the volume in a big way, and codes have the position fixedly, and is not removable and so on the flaw .So it cannot satisfy the application and the development request under many situations, and requests the small keyboard key-number to be possible carries on the hypothesis through standard RS232 or the manual operation way. It may insert the type system using the monolithic integrated circuit constitution to design. Therefore I attempt making the keyboard with the MCS-51 series monolithic integrated circuit scanning control circuit core constitution determinant keyboard, Using the scanning procedure method to recognition the key which is pressed down, and use the AT24C01A to save key-number and when it needs to revise to revises keyboard key-number. When it has the key pressed down the MCS-51 monolithic integrated circuit use the keyboard connection to send the key –number which corresponds to the key pressed down. When it needs to revise key-number can carry on the correspondence through the MCS-51 monolithic integrated circuit serial mouth and PC serial mouth COM1 or COM2 to transmit key-number for PC machine and demonstration on the corresponding contact surface. And revise corresponding key-number through the PC contact surface. Thus it may achieve the goal of revising small keyboard key-number. This paper is using the monolithic integrated circuit knowledge, the PC machine serial communication, the keyboard basic principle, as well as in the PROTEL 99SE study foundation carries on the circuit design, and finally completes this paper. Key words: Monolithic integrated circuit; Serial communication: Keyboard connection 目 录 第1章 绪论 1 1.1 课题的背景和目的 1 1.2 单片机键盘介绍 2 1.3 该论文的主要工作和预期目标 3 1.3.1 主要工作 3 1.3.2 预期目标 3 1.4 本章小结 4 第2章 单片机基础知识 5 2.1 MCS-51单片机概述 5 2.2 单片机的引脚及其功能 7 2.3 单片机基础知识 10 2.3.1 单片机的结构 10 2.3.2 指令系统 12 2.4 单片机串行端口 13 2.4.1 串行端口介绍 13 2.4.2 串口工作方式 15 2.5 定时器/计数器 17 2.6 时钟电路 18 2.7 复位电路 19 2.8 Visual Basic 串行通信控件 20 2.9 本章小结 22 第3章 总体方案的选择和论证 23 第4章 系统硬件设计 26 4.1 键盘扫描部分 26 4.1.1 按键电路和消除抖动 26 4.1.2 非编码键盘的结构 27 4.1.3 非编码键盘的工作方式 29 4.1.4 AT24C01A芯片介绍 30 4.2 键盘接口部分 32 4.3 单片机串口通信部分 33 4.3.1 RS-232标准接口总线及连接方法 33 4.3.2 单片机和PC机通信的接口电路 34 4.3.3 MAX232芯片介绍 35 4.3.4 Protel 99SE介绍 37 4.4 本章小结 40 第5章 系统软件设计 41 5.1 8051单片机端的软件设计 41 5.1.1 键盘扫描部分 41 5.1.2 键盘接口部分 44 5.1.2.1 键盘向系统发送数据 45 5.1.2.2 系统向键盘发送命令 46 5.1.3单片机串口通信部分 47 5.2 PC机端软件设计 50 5.3 本章小结 52 结论 53 参考文献 54 致谢 55 第1章 绪论 1.1课题的背景和目的 在工业控制、测量仪器等领域,已大量使用嵌入式PC,如ADVANTECH公司的PC/104,AMD公司的E86嵌入式PC.。它们除了具有PC的功能外,还提供了功能强大的各种标准接口。如:平板/VGA显示控制接口,光驱接口,以太网接口,RS232/422/485接口,PC/AT键盘接口等。这就为新产品开发的标准化,模块化提供了方便,可大大缩短研发周期,降低研制成本,快速进入市场。由于嵌入式PC具有标准的PC/AT键盘接口,也就是说,可以用标准的PC/AT键盘接口对嵌入式PC进行操作和控制。但是,在许多应用中,标准的键盘有体积大,键的数量较多,而实际应用中一般只用到几个键,因此希望键盘具有体积小,便于布放等特点。为此,希望能够设计一种小巧,灵活的PC键盘,来满足各种需要。 智能键盘是利用单片机微处理机技术设计的一种多功能键盘,常被配置在定 [1] [2] 下一页 |