1西北农林科技大学信息工程学院微机原理与接口课程设计实习报告题目:模拟电梯设计学号姓名专业班级指导教师分数2目录一、设计任务及要求................................................错误!未定义书签。二、实现方法.............................................................错误!未定义书签。1、硬件电路图.......................................................................错误!未定义书签。2、程序流程图及程序代码...................................................错误!未定义书签。三、调试与运行........................................................错误!未定义书签。四、设计总结.............................................................错误!未定义书签。五、附录.....................................................................错误!未定义书签。3一、设计任务及要求任务:在微机及接口实验箱上实现电梯模拟运行设计。数字键设定到达楼层号,电机模拟电梯运行,七段数码管显示楼层号,开关上下控制电梯升降,开关上下模拟电梯门开、关。要求:在微机及接口实验箱上完成电梯模拟控制;完成接口电路的设计;完成对应控制程序编写。二、实现方法1、硬件电路图42、程序流程图及程序代码5程序代码见附录三、调试与运行运行程序,用键盘输入想要去的楼层(1-15,对应键盘1到F的按键),用开关控制电梯向上或下运行。按启动键此时电机转动(上楼时顺时针转,下楼时逆时针转),如在电梯运行时出现问题或突然要提前下电梯可拨动开关控制电梯暂停。正常到达要去的楼层后,LED灯闪烁,蜂鸣器响三声提醒人们下电梯。四、设计总结本次实验,我用步进电机实现了15层电梯的运转,用开关控制电梯的上下,用开关将电梯制动。并扩展了LED灯及蜂鸣器提醒功能,在到达相应楼层后LED灯闪烁、蜂鸣器鸣叫三声提示人们下电梯。设计过程中出现了很多问题,比如如何控制显示屏的显示、如何控制好电机运转,如何实现开关控制,如何让它更接近真实的情况等。显示屏的显示部分,我查了Display8的代码然后将待显示的内容放置于buffer数组中,调用Display8子程序来显示。步进电机的显示部分,借鉴了实习中的步进电机的控制方法,将要运转的楼层数的差值存储,然后乘以100作为电机运转的步数。以使电机每转动100步,上或下一层楼。这期间还遇到了步数调整的实现问题,在这里判断开关的状态,得到电梯上或下的命令,还要判断控制开关是否是暂停状态,另外要判断要去的楼层是否已经到达,如到达关中断电机停止运行然后给8255的B口赋值,让LED灯闪烁并伴随蜂鸣器鸣叫。这里的8255A口连接开关用来输入开关状态、B口用来控制LED灯和蜂鸣器、C口用来控制步进电机的运转。6本次实验,步进电机部分较难控制,我是在看懂实验代码后对其进行调整的,调整的过程中又引发了不少问题,这也让我更进一步的思考和规范自己的代码。在不断的完善电梯功能的同时,我也不断地发现错误,因此一次次地整理思路画流程图来帮助判断。尽管如此,仍然有好几次着急的想放弃但在与同学和老师们的交流中让我有了新的思路,又开始一点点的改进代码,完善功能了。在实验的同时不断纠正自己的问题,提升对硬件电路的理解,我想这才是实习课要教给我们的东西吧。很庆幸自己按时的完成了,只是在功能的扩展方面还应该再做些提升,有些小小的遗憾。不过还是要感谢老师和同学们,谢谢你们!五、附录.MODELTINYEXTRNDisplay8:NEAR,SCAN_KEY:NEARIO8259_0EQU0F000HIO8259_1EQU0F001HCon_8253EQU0E003HT0_8253EQU0E000HIO8255_ConEQU0D003H;CS3IO8255_PCEQU0D002HIO8255_PBEQU0D001HIO8255_PAEQU0D000H.STACK100.DATAStepControlDB0;下一次送给步进电机的值bufferDB8DUP(0);显示缓冲区,8个字节buffer1DB8DUP(0)buffer2DB8DUP(0)SpeedNoDB5;选择哪一级速度CountDB0StepDelayDB0;延时常数StartStepDelayDB0StartStepDelay1DB0;StartStepDelaybFirstDB0;有没有转动过步进电机bClockwiseDB0;=1顺时针方向=0逆时针方向转动bNeedDisplayDB0;已转动一步,需要显示新步数7StepCountDW0;需要转动的步数StepDelayTab:DB250,125,83,62,50,42,36,32,28,25,22,21.CODESTART:MOVAX,@DATAMOVDS,AXMOVES,AXNOPMOVbFirst,1;有没有转动过步进电机MOVbClockwise,1;顺时针方向MOVStepControl,33H;下一次送给步进电机的值CALLInit8255CALLInit8253CALLInit8259CALLWriIntverMOVbuffer,1;显示缓冲器初始化MOVbuffer2,1MOVbuffer+1,0MOVbuffer+2,1MOVbuffer+3,0MOVbuffer+4,10HMOVbuffer+5,10HMOVbuffer+6,10HMOVbuffer+7,0STAR2:LEASI,bufferLEADI,buffer1MOVCX,8MOVAL,BYTEPTR[buffer2]MOVBYTEPTR[buffer+2],ALMOVAL,BYTEPTR[buffer2+1]MOVBYTEPTR[buffer+3],ALREPMOVSBLEASI,buffer1CALLDisplay8STAR3:CALLScan_KeyJBSTAR5CMPbNeedDisplay,0JZSTAR3MOVbNeedDisplay,0CALLStep_ADJJMPSTAR2STAR5:CLI8;终止步进电机转动CMPAL,0JNZSHIJMPExecSHI:CMPAL,10JNBSTAR1MOVbuffer+1,0MOVbuffer,ALJMPJUDSTAR1:CMPAL,16JNBSTAR3MOVbuffer+1,1SUBAL,10MOVbuffer,ALJUD:MOVDX,IO8255_PAINAL,DXANDAL,02HCMPAL,0JZU1;上或下D1:MOVbyteptr[buffer+7],0MOVbClockwise,0JMPSTAR2U1:MOVbyteptr[buffer+7],1MOVbClockwise,1JMPSTAR2Direction:CMPbClockwise,0JZClockwiseMOVbClockwise,0MOVbuffer+7,1AntiClockwise:CMPbFirst,0JZAntiClockwise1MOVStepControl,91HJMPDirection1AntiClockwise1:MOVAL,StepControlRORAL,2MOVStepControl,ALJMPDirection1Clockwise:MOVbClockwise,1MOVbuffer+7,0CMPbFirst,0JZClockwise1MOVStepControl,33H9JMPDirection1Clockwise1:MOVAL,StepControlROLAL,2MOVStepControl,ALDirection1:JMPSTAR2Speed_up:MOVAL,SpeedNoCMPAL,11JZSpeed_up2Speed_up1:INCALMOVSpeedNo,ALMOVbuffer+5,ALSpeed_up2:JMPSTAR2Speed_Down:MOVAL,SpeedNoCMPAL,0JZSpeed_Down1DECALMOVSpeedNo,ALMOVbuffer+5,ALSpeed_Down1:JMPSTAR2Exec:MOVbFirst,0CALLTakeStepCountLEABX,StepDelayTabMOVAL,SpeedNoXLATMOVStepDelay,ALCMPAL,50JNBExec1MOVAL,50Exec1:MOVStartStepDelay,ALMOVStartStepDelay1,ALSTI;当前楼数S1:MOVAL,BYTEPTR[buffer+2]MOVBYTEPTR[buffer2],ALMOVAL,BYTEPTR[buffer+3];当前楼数MOVBYTEPTR[buffer2+1],ALMOVAL,90HANDAL,01HCMPAL,0JNZS110JMPSTAR2TIMER0:PUSHAXPUSHDXDECStartStepDelayJNZTIMER0_1MOVAL,StartStepDelay1CMPAL,StepDelayJZTIMER0_2DECALMOVStartStepDelay1,ALTIMER0_2:MOVStartStepDelay,ALMOVAL,StepControlMOVDX,IO8255_PCOUTDX,ALCMPbClockwise,0JNZTIMER0_3RORAL,1JMPTIMER0_4TIMER0_3:ROLAL,1TIMER0_4:MOVStepControl,ALCMPStepCount,0JZTIMER0_1MOVbNeedDisplay,1DECStepCountJNZTIMER0_1addsp,8;小写部分不允许使用单步、单步进入命令popfclipushfsubsp,8nopTIMER0_1:MOVDX,IO8259_0MOVAL,20HOUTDX,ALPOPDXPOPAXIRETStep_ADJPROCNEARMOVDX,IO8255_PAINAL,DXANDAL,01HCMPAL,1JNZCC11CLICC:INCCountMOVAL,BYTEPTR[buffer+1]CMPBYTEPTR[buffer+3],ALJNZCHUMOVAL,BYTEPTR[buffer]CMPBYTEPTR[buffer+2],ALJNZCHUCLICALLRRINGJMPSTAR2CHU:MOVBL,100MOVAL,CountMOVAH,0DIVBLCMPAH,0JNZStep_ADJ_1MOVAL,BYTEPTR[buffer+7]CMPAL,1JNZDOWNADDBYTEPTR[buffer2],ALCMPBYTEPTR[buffer2],10JBStep_ADJ_1MOVBYTEPTR[buffer2+1],1MOVAL,BYTEPTR[buffer2]SUBAL,10MOVBYTEPTR[buffer2],ALJMPStep_ADJ_1DOWN:CMPBYTEPTR[buffer2],0JNZSUBBMOVBYTEPTR[buffer2+1],0MOVBYTEPTR[buffer2],9JMPStep_ADJ_1SUBB:DECBYTEPTR[buffer2]JMPStep_ADJ_1Step_ADJ_1:RETStep_ADJENDPTakeStepCountPROCNEARMOVAL,BYTEPTR[buffer+1]MOVAH,0MOVBL,10MULBLADDAL,BYTEPTR[buffer]MOVStepCount,AXMOVAL,BY