資源描述:
《案例一 直流電機測速.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在學術(shù)論文-天天文庫。
1、案例一直流電機測速程序;直流電機轉(zhuǎn)速測量與控制實驗SCNTEQU51H;為送到0832的值CKCNEQU53HSETPEQU54H;轉(zhuǎn)數(shù)timesequ46htemp1equ47hOUTBITequ0e101h;位控制口CLK164equ0e102h;段控制口(接164時鐘位)DAT164equ0e102h;段控制口(接164數(shù)據(jù)位)INequ0e103h;鍵盤讀入口LEDBufequ39h;顯示緩沖ORG0000HSTRT:LJMPMAINORG0003H;LJMPPINT0ORG000BH;LJMPPTF0ORG0030H;PT
2、F0:MOVTH0,#07EHPUSHACCPUSHPSWPUSHBSETBPSW.3inctimesmova,timescjnea,#40,ptfj;判斷時間是否到了movtimes,#0mova,ckcnmovtemp1,amovckcn,#0subba,setpjnctt3mova,scnt;加速adda,#2movscnt,aljmptt4tt3:mova,scnt;減速subba,#2movscnt,att4:mova,temp1;speedmovb,#10divabmov3ah,amova,bmov39h,aPTFJ:N
3、OPPOPBPOPPSWPOPACCRETIMAIN:movsp,#60hmovdptr,#0e100h;8155初始化mova,#03hmovx@dptr,aMOVTMOD,#01H;定時器初始化MOVTH0,#07EHMOVTL0,#00HCLREA;關(guān)中斷MOVR0,#39HMOVR7,#06HMLP0:MOV@R0,#10H;關(guān)掉所有LEDINCR0DJNZR7,MLP0LCALLDIR;調(diào)顯示MOVCKCN,#00H;轉(zhuǎn)數(shù)初始化為0NOPMLP1:CALLDIRcallTestKey;有鍵入?jzMLp1;無鍵入,繼續(xù)顯示
4、callGetKey;讀入鍵碼CLRCMOVR4,ASUBBA,#0aH;判斷輸入的值是不是0-9JNCMLP1MOVA,R4MOV3EH,A;保存輸入的值(高位)LCALLDIRMLP2:CALLDIRcallTestKey;有鍵入?jzMLP2;無鍵入,繼續(xù)顯示callGetKey;讀入鍵碼CLRCMOVR4,ASUBBA,#0aH;判斷輸入的值是不是0-9JNCMLP2MOVA,R4MOV3DH,A;保存輸入的值(低位)MOVA,3EHMOVB,#0AHMULABADDA,3DHMOVSETP,A;求出我們給定的速度,并送入S
5、ETP中movdptr,#0a000hmovSCNT,#7fhmovA,SCNTMOVX@DPTR,A;啟動電流機movtimes,#0h;時間計數(shù)器SETBTR0;啟動定時器0SETBEX0;開中斷SETBET0SETBIT0SETBEANOPMOVIP,#04HML00P4:MOVDPTR,#0a000Hmova,scntMOVX@DPTR,Amovr7,#50djnzr7,$LCALLDIRLJMPML00P4PINT0:INCCKCNPIPI:RETITestKey:movdptr,#OUTBITmova,#0movx@dp
6、tr,a;輸出線置為0movdptr,#INmovxa,@dptr;讀入鍵狀態(tài)cplaanla,#0fh;高四位不用retKeyTable:;數(shù)字鍵碼定義db00h,01h,04h,07hdb0fh,02h,05h,08hdb0eh,03h,06h,09hdb0dh,0ch,0bh,0ahdb10H,10H,10H,10H,10Hdb10H,10H,10H,10H,10HGetKey:MOV13H,#06H;獲取輸入值,送入A中,然后返回MOV12H,#20HKey2:MOVA,12HCPLAMOVR7,AMOVDPTR,#0E10
7、1HMOVA,R7MOVX@DPTR,AMOVA,12HCLRCRRCAMOV12H,AMOVDPTR,#0E103HMOVXA,@DPTRMOVR7,AMOVA,R7CPLAMOVR7,AMOVA,R7ANLA,#0FHMOV14H,ADEC13HMOVR7,13HMOVA,R7JZKey1MOVA,14HJZKey2Key1:MOVA,14HJZGetKey6MOVA,13HADDA,ACCADDA,ACCMOV13H,AMOVA,14HJNBACC.1,GetKey1INC13HSJMPGetKey3GetKey1:MOVA,
8、14HJNBACC.2,GetKey2INC13HINC13HSJMPGetKey3GetKey2:MOVA,14HJNBACC.3,GetKey3MOVA,#03HADDA,13HMOV13H,AGetKey3:LCALLDIRCA