单片机硬件实习报告模拟电梯设计Word格式文档下载.docx

上传人:b****2 文档编号:1552706 上传时间:2023-04-30 格式:DOCX 页数:15 大小:406.16KB
下载 相关 举报
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第1页
第1页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第2页
第2页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第3页
第3页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第4页
第4页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第5页
第5页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第6页
第6页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第7页
第7页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第8页
第8页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第9页
第9页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第10页
第10页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第11页
第11页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第12页
第12页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第13页
第13页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第14页
第14页 / 共15页
单片机硬件实习报告模拟电梯设计Word格式文档下载.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

单片机硬件实习报告模拟电梯设计Word格式文档下载.docx

《单片机硬件实习报告模拟电梯设计Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《单片机硬件实习报告模拟电梯设计Word格式文档下载.docx(15页珍藏版)》请在冰点文库上搜索。

单片机硬件实习报告模拟电梯设计Word格式文档下载.docx

上位机监控对电梯安全运行和故障维修具有重要意义,在减少维修管理人员的同时,可及时发现故障,缩短故障候梯时间,实现管理的自动化。

面向对象的程序设计更适合对现实生活中的描述,更加体现了软件的工业化的精神。

1.2设计内容

本文根据实验室提供的单片机实验箱,利用键盘、开关、数码管和LED模拟实现八层电梯的控制。

并且设计急停开关和断电维修开关以模拟实物电梯的更多的运行功能。

软件利用C语言,通过检测用户请求的按键信息,根据电梯运行到相应楼层送到单片机计数来确定楼层数,并送到数码管进行显示。

硬件设计简单可靠,结合软件,基本实现了八层电梯运行的模拟。

1.3硬件实习的目的

(1)利用所学过的知识,初步分析单片机原理及接口技术的能力;

(2)进一步掌握硬件电路和软件功能的设计方法;

(3)了解8255可编程并行接口芯片的工作原理,掌握8255的各种模式编程方法;

(4)实验结果调试分析、总结及撰写技术报告的能力。

2.硬件电路设计及描述

2.1电路连线及概述

P1.0-P1.7接L0-L7八个发光二极管

2.28255扫描键盘与LED接口电路图

3.软件设计流程及描述

3.1软件设计流程图

4.源程序代码

#include<

reg52.h>

absacc.h>

/*****theaddressof8255*****/

#defineC8255XBYTE[0xF22B]//8255command

#defineP8255AXBYTE[0xF228]

#defineP8255BXBYTE[0xF229]

#defineP8255CXBYTE[0xF22A]

#defineP8255XBYTE[0xF22A]

/*****threetables*****/

unsignedcharcodetable[]={//SegmentvalueforLED

0x06,0x5b,0x4f,0x66,

0x6d,0x7d,0x07,0x7f};

unsignedcharcodetable1[]={//0x7f->

LightP1^0...

0x7f,0xbf,0xdf,0xef,

0xf7,0xfb,0xfd,0xfe};

unsignedcharcodetable2[]={//P1=table1[elevator.currentlevel]|table2[elevator.currentlevel]

0x80,0x40,0x20,0x10,//->

Extinguishtheledoncurrentfloor

0x08,0x04,0x02,0x01};

voidinit();

voidkeyscan();

voidcurrentshow(unsignedchar);

voiddelay();

//2s

voiddelayms();

//20ms

unsignedintmove;

unsignedintcurrentfloor;

unsignedintdirection;

unsignedintdestination[9];

chartimes=0;

unsignedintrepairs;

//0->

donotrepair;

1->

repairing

/***************************************************************************/

voidmain()

{

unsignedchari,j;

init();

/*inittheelevator*/

currentshow(currentfloor);

while

(1)

{

while(repairs<

=250)//repairs<

=250needtorepair

repairs=P3^3;

move=P3^1;

keyscan();

while(move==254&

&

destination[0]!

=0)//movingkeywaspressed

{

while(repairs<

repairs=P3^3;

keyscan();

//andatleast1levelwanted

move=P3^1;

switch(direction)

{

case2:

if(currentfloor==0)//declining

{

move=0;

direction=1;

}

else

for(j=currentfloor;

j>

0;

j--)//weathertherearedestinationsdownstairs

{

if(destination[j]==0x1)

break;

}

if(j<

=0)

else

{

if(destination[currentfloor+1]==1)

{

move=0;

destination[0]--;

direction=0;

destination[currentfloor]=0;

P1|=table2[currentfloor];

//Extinguishthecorrespondingled

}

currentfloor--;

currentshow(currentfloor);

}//"

|"

->

bitor

break;

}

case1:

{//rising

if(currentfloor==8)//weathertherearedestinationsupstairs

direction=2;

for(j=currentfloor+1;

j<

9;

j++)

if(j>

8)

direction=2;

else

if(destination[currentfloor+1]!

=0)////////////////

destination[currentfloor+1]=0;

//Extinguishthecorrespondingled//"

currentfloor++;

}

default:

{//stationary

for(i=1;

i<

i++)//decideupordown

if(destination[i]!

break;

if(i<

currentfloor)//shoulddown

elseif(i>

currentfloor)//shouldup

destination[0]--;

direction=0;

destination[currentfloor]=0;

//thedestinationiscurrentlevel,

 //donothingbutextiguishtheled

P1|=table2[currentfloor-1];

}

}

delay();

//2s/level

}

}

}

voidinit()//timer,elevator

unsignedchari;

/****timerandexternalinterruptinit*******/

TMOD=0x01;

TH0=(65536-45872)/256;

//50ms

TL0=(65536-45872)%256;

EA=1;

ET0=1;

EX0=1;

EX1=1;

IT1=1;

/******elevatorinit******/

move=0;

/*0->

theelevatornowwillnotmove,commandscomesfromp3^0*/

for(i=0;

i++)

destination[i]=0;

//nodestination

direction=0;

//theelevatorisstationaryatthestart

currentfloor=0;

//theelevatorstopsatfirstlevelatthestart

/*****8255init*****/

C8255=0x82;

//PBin;

PA,PCout

repairs=P3^3;

}

voidkeyscan()

{/*savetotalnumberofdestinationtodestination[0]*/

/*setdestination[1-9]ifthecorrepondinglevelwanted*/

unsignedchartemp,key;

P8255C=0x2;

temp=P8255B;

if(temp!

=0xff)//keypressed

{

delayms();

temp=P8255B;

if(temp!

=0xff)//confirmed

{

switch(temp)

case0xfe:

key=0;

P1&

=table1[key];

break;

//P1=table1[key]->

lightthecorrespondingled

case0xfd:

key=1;

case0xfb:

key=2;

case0xf7:

key=3;

case0xef:

key=4;

case0xdf:

key=5;

case0xbf:

key=6;

case0x7f:

key=7;

destination[key+1]=1;

//setthecorrespondinglevel

destination[0]++;

//totalnumberofdestination

while(temp!

=0xff)

temp=P8255B;

voidcurrentshow(unsignedcharnum)

{

P8255C=0x0;

//weixuan

P8255A=table[num];

voiddelayms()

unsignedinti,j;

//delayfor20ms

for(i=20;

i>

i--)

for(j=110;

j--);

voiddelay()

TR0=1;

while(times!

=40)

times=0;

TR0=0;

voidT0_timer()interrupt1

times++;

voidextern0()interrupt0//waittorepair

EX1=0;

if(repairs==0)

repairs=1;

else

repairs=0;

voidextern1()interrupt3//emergency

//stoptheelevator

5.设计心得

本次实习我们选择了模拟日常生活中常见的电梯运行过程。

这次实习让我对程序的设计、调试有了更深刻的认识。

尤其是写单片机这类的与硬件相关的程序。

在调试的时候会有不少意想不到的结果。

这要求除了对程序充分了解,还要对硬件的特性,电路的连接也深刻认识。

关于程序,总结如下:

必须养成在写之前仔细分析需求、要求,画出流程图,先明确各个模块的作用。

最后分块细化,从底向上设计的习惯。

否则很容易出现程序写了一半发现理解出错,功能达不到的情况。

还有程序注释必须及时,不能等到写完了再注释,否则可能之后连自己也看不懂程序。

及时的修改记录也是必要的。

对于硬件、电路:

要熟练掌握如何用c、汇编语言操作芯片。

要掌握常用芯片的用法、特性,至少要熟悉其datasheet,需要使用时通过查阅手册,能快速、熟练的使用该芯片。

参考文献

[1].王玉芳钟旭.微机原理与接口技术实验教程.广东高等教育出版社.2005年5月第2次印刷.

[2]赵德安.单片机原理与应用[M].北京:

机械工业出版社,2008年5月

[3]向艳,周天彤.C语言程序设计[M].北京:

清华大学出版社,2008年9月.

[4]宁飞,王维华,孔宇.微型计算机原于是与接口实践[M].北京:

清华大学出版社,2006.

[5]周炯如,潘操.EAT单片机应用开发系统实验指导书[M].常州:

常州大学信息科学与工程学院.2010年7月.

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

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2