基于單片機(jī)的步進(jìn)電機(jī)驅(qū)動電路設(shè)計(jì)
方式1源程序:
MOV 20H,#00H ;20H單元置初值,電機(jī)正轉(zhuǎn)位置指針
MOV 21H,#00H ;21H單元置初值,電機(jī)反轉(zhuǎn)位置指針
MOV P1,#0C0H ;P1口置初值,防止電機(jī)上電短路
MOV TMOD,#60H ;T1計(jì)數(shù)器置初值,開中斷
MOV TL1,#0FFH
MOV TH1,#0FFH
SETB ET1
SETB EA
SETB TR1
SJMP $
;***********計(jì)數(shù)器1中斷程序************
IT1P: JB P3.7,FAN ;電機(jī)正、反轉(zhuǎn)指針
;*************電機(jī)正轉(zhuǎn)*****************
JB 00H,LOOP0
JB 01H,LOOP1
JB 02H,LOOP2
JB 03H,LOOP3
JB 04H,LOOP4
JB 05H,LOOP5
JB 06H,LOOP6
JB 07H,LOOP7
LOOP0: MOV P1,#0D0H
MOV 20H,#02H
MOV 21H,#40H
AJMP QUIT
LOOP1: MOV P1,#090H
MOV 20H,#04H
MOV 21H,#20H
AJMP QUIT
LOOP2: MOV P1,#0B0H
MOV 20H,#08H
MOV 21H,#10H
AJMP QUIT
LOOP3: MOV P1,#030H
MOV 20H,#10H
MOV 21H,#08H
AJMP QUIT
LOOP4: MOV P1
MOV 20H,#20H
MOV 21H,#04H
AJMP QUIT
LOOP5: MOV P1,#060H
MOV 20H,#40H
MOV 21H,#02H
AJMP QUIT
LOOP6: MOV P1,#0E0H
MOV 20H,#80H
光電開關(guān)相關(guān)文章:光電開關(guān)原理
評論