单片机硬件实习报告——模拟电梯设计.doc

上传人:laozhun 文档编号:2883364 上传时间:2023-03-01 格式:DOC 页数:12 大小:436.50KB
返回 下载 相关 举报
单片机硬件实习报告——模拟电梯设计.doc_第1页
第1页 / 共12页
单片机硬件实习报告——模拟电梯设计.doc_第2页
第2页 / 共12页
单片机硬件实习报告——模拟电梯设计.doc_第3页
第3页 / 共12页
单片机硬件实习报告——模拟电梯设计.doc_第4页
第4页 / 共12页
单片机硬件实习报告——模拟电梯设计.doc_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《单片机硬件实习报告——模拟电梯设计.doc》由会员分享,可在线阅读,更多相关《单片机硬件实习报告——模拟电梯设计.doc(12页珍藏版)》请在三一办公上搜索。

1、 单片机硬件实习报告题 目 : 模 拟 电 梯 设 计 学生姓名: 学号: 学院(系: 专业班级: 指导教师: 实习时间: 2011 年 2 月 21 日 2010 年 3 月 4 日目 录1.前言11.1设计背景11.2设计内容11.3硬件实习的目的12.硬件电路描述及设计12.1 电路连线及概述12.2 8255扫描键盘及与LED接口电路图23.软件电路描述及设计33.1软件设计流程图34.源程序代码45.设计心得10参考文献101.前言1.1设计背景电梯作为现代高层建筑最常用的垂直运输工具,广泛应用于社会活动的各个角落,如何保证每台电梯都能够可靠运行,已成为提高物业管理水平和电梯技术进步

2、的关键所在。电梯运行质量直接由控制系统的功能决定,而控制系统软件又直接决定着控制系统运行的好坏。上位机监控对电梯安全运行和故障维修具有重要意义,在减少维修管理人员的同时,可及时发现故障,缩短故障候梯时间,实现管理的自动化。面向对象的程序设计更适合对现实生活中的描述,更加体现了软件的工业化的精神。1.2设计内容本文根据实验室提供的单片机实验箱,利用键盘、开关、数码管和 LED模拟实现八层电梯的控制。并且设计急停开关和断电维修开关以模拟实物电梯的更多的运行功能。软件利用C语言,通过检测用户请求的按键信息,根据电梯运行到相应楼层送到单片机计数来确定楼层数,并送到数码管进行显示。硬件设计简单可靠,结合

3、软件,基本实现了八层电梯运行的模拟。1.3硬件实习的目的(1)利用所学过的知识,初步分析单片机原理及接口技术的能力;(2)进一步掌握硬件电路和软件功能的设计方法;(3)了解8255可编程并行接口芯片的工作原理,掌握8255的各种模式编程方法;(4)实验结果调试分析、总结及撰写技术报告的能力。2.硬件电路设计及描述2.1 电路连线及概述P1.0-P1.7接L0-L7八个发光二极管2.2 8255扫描键盘与LED接口电路图3.软件设计流程及描述 3.1软件设计流程图4.源程序代码#include#include/*the address of 8255*/#define C8255 XBYTE0x

4、F22B /8255command#define P8255A XBYTE0xF228#define P8255B XBYTE0xF229#define P8255C XBYTE0xF22A#define P8255 XBYTE0xF22A/* three tables */unsigned char code table= /Segment value for LED0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f;unsigned char code table1=/0x7f-Light P10 .0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0

5、xfd,0xfe;unsigned char code table2= /P1=table1elevator.currentlevel|table2elevator.currentlevel0x80,0x40,0x20,0x10, /-Extinguish the led on current floor0x08,0x04,0x02,0x01;void init();void keyscan();void currentshow(unsigned char); void delay();/2svoid delayms();/20msunsigned int move;unsigned int

6、currentfloor;unsigned int direction;unsigned int destination9;char times=0; unsigned int repairs; /0-do not repair; 1-repairing/* */ void main()unsigned char i,j;init(); /*init the elevator*/currentshow(currentfloor);while(1)while(repairs=250) / repairs=250 need to repairrepairs=P33;move=P31;keyscan

7、();while(move=254&destination0!=0) /moving key was pressed while(repairs=250) / repairs0;j-) /weather there are destinations downstairsif(destinationj=0x1)break; if(jbit orbreak;case 1: /risingif(currentfloor=8) /weather there are destinations upstairsmove=0;direction=2;else for(j=currentfloor+1;j8)

8、direction=2;elseif(destinationcurrentfloor+1!=0)/ move=0;destination0-;direction=0;destinationcurrentfloor+1=0;P1|=table2currentfloor;/Extinguish the corresponding led/ |-bit orcurrentshow(currentfloor);currentfloor+;break;default: /stationaryfor(i=1;i9;i+) /decide up or downif(destinationi!=0)break

9、; if(icurrentfloor)/should updirection=1;elsemove=0;destination0-;direction=0;destinationcurrentfloor=0;/the destination is current level, /do nothing but extiguish the ledP1|=table2currentfloor-1;delay(); /2s/levelvoid init() /timer,elevator unsigned char i;/*timer and external interrupt init*/TMOD

10、=0x01;TH0=(65536-45872)/256;/50msTL0=(65536-45872)%256;EA=1;ET0=1;EX0=1;EX1=1;IT1=1;/*elevator init*/move=0;/*0-the elevator now will not move,commands comes from p30*/for(i=0;ilight the corresponding ledcase 0xfd:key=1;P1&=table1key;break;case 0xfb:key=2;P1&=table1key;break;case 0xf7:key=3;P1&=tabl

11、e1key;break;case 0xef:key=4;P1&=table1key;break;case 0xdf:key=5;P1&=table1key;break;case 0xbf:key=6;P1&=table1key;break;case 0x7f:key=7;P1&=table1key;break;destinationkey+1=1; /set the corresponding level destination0+; /total number of destination temp=P8255B; while(temp!=0xff) temp=P8255B;void cur

12、rentshow(unsigned char num)P8255C=0x0; /wei xuanP8255A=tablenum;void delayms()unsigned int i,j;/delay for 20msfor(i=20;i0;i-)for(j=110;j0;j-);void delay()TR0=1;while(times!=40)times=0;TR0=0;void T0_timer() interrupt 1TH0=(65536-45872)/256;/50msTL0=(65536-45872)%256;times+;void extern0() interrupt 0

13、/wait to repairEX1=0;if(repairs=0)repairs=1;elserepairs=0;EX1=1;void extern1() interrupt 3 /emergencydirection=0; /stop the elevatormove=0;5.设计心得本次实习我们选择了模拟日常生活中常见的电梯运行过程。这次实习让我对程序的设计、调试有了更深刻的认识。尤其是写单片机这类的与硬件相关的程序。在调试的时候会有不少意想不到的结果。这要求除了对程序充分了解,还要对硬件的特性,电路的连接也深刻认识。关于程序,总结如下:必须养成在写之前仔细分析需求、要求,画出流程图,先

14、明确各个模块的作用。最后分块细化,从底向上设计的习惯。否则很容易出现程序写了一半发现理解出错,功能达不到的情况。还有程序注释必须及时,不能等到写完了再注释,否则可能之后连自己也看不懂程序。及时的修改记录也是必要的。对于硬件、电路:要熟练掌握如何用c、汇编语言操作芯片。要掌握常用芯片的用法、特性,至少要熟悉其datasheet,需要使用时通过查阅手册,能快速、熟练的使用该芯片。参考文献1.王玉芳 钟旭.微机原理与接口技术实验教程.广东高等教育出版社.2005年5月第2次印刷.2赵德安.单片机原理与应用M.北京:机械工业出版社,2008年5月3向艳,周天彤.C语言程序设计M.北京:清华大学出版社,2008年9月.4宁飞,王维华,孔宇.微型计算机原于是与接口实践M.北京:清华大学出版社,2006.5周炯如,潘操.EAT单片机应用开发系统实验指导书M.常州:常州大学信息科学与工程学院.2010年7月.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号