步進電機控制之8255A
元器件(80c51芯片,8255A芯片,74ls373鎖存芯片,l298驅(qū)動芯片,三相六線步進電機,按鈕若干,電源)??
本文引用地址:http://m.butianyuan.cn/article/201611/322106.htm匯編源程序:
ORG 0000H;
LJMP MAIN1;
ORG 0030H;(頭文件)
MAIN1:MOV DPTR,#0FF7FH;檢測PA口狀態(tài)
MOV A,#91H;
MOVX @DPTR,A;
MAIN:MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L1;
LJMP MAIN;
L1:CJNE A,#0FEH,LOOP2;
LOOP1:MOV DPTR,#0FF7DH;控制電機正轉(zhuǎn)
MOV A,#01H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L2;
LJMP MAIN;
L2:CJNE A,#0FEH,LOOP2;
MOV DPTR,#0FF7DH;
MOV A,#02H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L3;
LJMP MAIN;
L3:CJNE A,#0FEH,LOOP2;
MOV DPTR,#0FF7DH;
MOV A,#04H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L4;
LJMP MAIN;
L4:CJNE A,#0FEH,LOOP2;
L8:LJMP LOOP1;
LOOP2:MOV DPTR,#0FF7DH;控制電機反轉(zhuǎn)
MOV A,#01H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L5;
LJMP MAIN;
L5:CJNE A,#0FCH,LOOP1;
MOV DPTR,#0FF7DH;
MOV A,#04H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L6;
LJMP MAIN;
L6:CJNE A,#0FCH,LOOP1;
MOV DPTR,#0FF7DH;
MOV A,#02H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L7;
LJMP MAIN;
L7:CJNE A,#0FCH,L8;
LJMP LOOP2;
DELAY:MOV R5,#0H;延時子程序
K1:MOV R6,#02H;
K2:MOV R7,#81H;
K3:NOP;
DJNZ R7,K3;
DJNZ R6,K2;
DJNZ R5,K1;
RET;
END;
評論