《步进电机驱动.doc》由会员分享,可在线阅读,更多相关《步进电机驱动.doc(6页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流步进电机驱动.精品文档.步进电机驱动利用8255的PC口PC0-PC3轮流输出脉冲序列,实验机上键盘控制步进电机的转速和转动方向。电路CS8255接200H,CS8279接至208H。PC0-PC3接至SMA-SMD。程序是供四相步进电机使用。使用的步进电机用直流+12V电压,电机线圈由A、B、C、D四相组成。驱动方式为四相单四拍方式,各线圈通电顺序如下表。表中首先向A相线圈输入驱动电流,接着向B,C,D线圈通电,最后又返回到A相线圈驱动,按这种顺序轮流切换,电机轴按顺时针方向旋转。若通电顺序相反,则电机轴按逆时针方向旋转。顺序/相ABCD0
2、01111101121101311103. 在运行过程中,可按动小键盘的“09”数码键,控制步进电机的转速,按“B或C”键控制步进电机的方向,按“F”键退出。程序框图程序C8279 EQU 209HD8279 EQU 208HC8255 EQU 206HP8255C EQU 204HCODE SEGMENTASSUME CS:CODE,DS:CODESTART:PUSH CSPOP DSINI:MOV DX,C8255MOV AL,80HOUT DX,ALMOV DX,C8279MOV AL,00HOUT DX,ALMOV AL,2AHOUT DX,ALMOV AL,90HOUT DX,ALM
3、OV AL,0D1HOUT DX,ALWAIT1:IN AL,DX ;读8279状态字,判是否有键按下MOV AH,ALAND AL,80HJNZ WAIT1MOV AL,AHAND AL,0FHCMP AL,00HJE WAIT1LEA BX,STEPRUN:CALL CHKKEYCALL DISPLAYMOV CX,08HLOOP3:MOV DX,P8255CMOV AL,SIOUT DX,ALINC SICALL DELAYLOOP LOOP3JMP RUNCHKKEY PROC NEARRDKEY:MOV DX,C8279IN AL,DXMOV AH,ALAND AL,80HCMP A
4、L,80HJE RDKEYMOV AL,AHAND AL,0FHCMP AL,00HJE RTNMOV AL,40HOUT DX,ALMOV DX,D8279IN AL,DXCHK:CMP AL,0FHJE QUITCMP AL,0AH ;判是否大于A键JNC DIREMOV DELAYTIME,ALJMP RTNDIRE:CMP AL,0BHJNE NEXTMOV DIRDSP,40HLEA BX,STEPJMP RTNNEXT:CMP AL,0CHJNE RTNMOV DIRDSP,46HLEA BX,STEPADD BX,07HRTN:MOV SI,BXRETCHKKEY ENDPDEL
5、AY PROC NEARPUSH CXMOV CX,0AHSUB CL,DELAYTIMELOOP1:PUSH CXMOV CX,03FFHLOOP2:NOPLOOP LOOP2POP CXLOOP LOOP1POP CXRETDELAY ENDPDISPLAY PROC NEARPUSH BXMOV DX,D8279MOV AL,DELAYTIMELEA BX,LEDXLATOUT DX,ALMOV AL,DIRDSPOUT DX,ALMOV CX,0006HLEA BX,DSPLOOP4:MOV AL,BXOUT DX,ALINC BXLOOP LOOP4MOV DX,C8279MOV A
6、L,0C2HOUT DX,ALPOP BXRETDISPLAY ENDPQUIT:MOV DX,C8279MOV AL,0D2HOUT DX,ALjmp $LED DB 3FH,06H,5BH,4FH,66HDB 6DH,7DH,07H,7FH,6FHDSP DB 5EH,79H,79H,73H,6DH,0EDHDELAYTIME DB 01H;STEP DB 04H,05H,01H,09H,08H; DB 0AH,02H,06H,02H,0AH; DB 08H,09H,01H,05H,04HSTEP DB 08H,0CH,04H,06H,02HDB 03H,01H,09H,01H,03HDB 02H,06H,04H,0CH,08HDIRDSP DB 40HCODE ENDSEND START