对äºæ驱å¨å¨çæ¥è¿çµæºé度æ¯ç±ä¿¡å·èå²é¢çå³å®çï¼èèªå·±è®¾è®¡é©±å¨æ¶ï¼æ¥è¿çµæºé度æ¯ç±Aï¼/A,B,/Bç¸åæ¢é度å³å®çåä¸ä¸ªç¤ºèå§ï¼P1.0~P1.3为æ¥è¿çµæºçAï¼/Aï¼Bï¼/Bï¼P1.4~P1.6为ä¸ä¸ªé®SPD EQU 30HNUMBER EQU 31HORG 0000 LJMP MAINORG 0003H LJMP INT0DEALORG 000BH LJMP T0DEAL
ORG 0030H;===================================QIDONG: MOV DPTR,#SPEEDD MOV A,SPD RL A PUSH ACC MOVC A,@A+DPTR MOV TH0,A POP ACC INC A MOVC A,@A+DPTR MOV TL0,A MOV P1,#08H MOV NUMBER,#1 SETB TR0 SETB ET0 SETB EA RET;==============================CLOSE: CLR TR0 CLR ET0 CLR EA RET;==============================;HALF STEPHSTEPTAB: DB 08H,0AH,02H,06H,04H,05H,01H,09H;==============================;TOTAL STEPSTEPTAB: DB 0AH,06H,05H,09H;==============================SPEED: DW 56320 100Hz DW 60928 200Hz DW 62464 300Hz DW 63232 400Hz DW 63693 500Hz DW 64000 600Hz DW 64219 700Hz DW 64384 800Hz DW 64512 900Hz DW 64614 1000Hz DW 64698 1100Hz DW 64768 1200Hz DW 64827 1300Hz DW 64878 1400Hz DW 64922 1500Hz DW 64960 1600Hz DW 64994 1700Hz DW 65024 1800Hz DW 65051 1900Hz DW 65075 2000Hz;------------------------------T0DEAL: CLR TR0 MOV DPTR,#SPEED MOV A,SPD RL A PUSH ACC MOVC A,@A+DPTR MOV TH0,A POP ACC INC A MOVC A,@A+DPTR MOV TL0,A MOV DPTR,#HSTEPTAB MOV A,NUMBER MOVC A,@A+DPTR ANL A,#0FH MOV P1,A MOV A,NUMBER INC A CJNE A,#8,T0DEAL1T0DEAL1: JC T0DEAL2 MOV A,#0T0DEAL2: MOV NUMBER,AT02: RETI;==============================================DELAY: MOV 3DH,#249 ;0.5ms DJNZ 3DH,$ MOV 3DH,#249 ;0.5ms DJNZ 3DH,$ DJNZ 3EH,DELAY ;3EH=?ms RET;==============================================MAIN: CLR EA CLR ET0 CLR ET1 CLR TR0 CLR ET0 CLR EX0 CLR EX1 CLR ES MOV SP,#5FH MOV 3EH,#250 LCALL DELAY MOV TMOD,#01H SETB EA MOV P1,#00HMAIN1: JB P1.4,MAIN2 ;K1:æ¹åé度 MOV 3EH,#10 LCALL DELAY JB P1.4,MAIN2 INC SPD MOV A,SPD CJNE A,#20,MAIN2MAIN2: JC MAIN3 MOV SPD,#0 SJMP MAIN1MAIN3: JB P1.5,MAIN4 ;K2ï¼å¯å¨ MOV 3EH,#10 LCALL DELAY JB P1.5,MAIN4 LCALL QIDONG SJMP MAIN1MAIN4: JB P1.6,MAIN1 ;K3ï¼åæ¢ MOV 3EH,#10 LCALL DELAY JB P1.6,MAIN1 LCALL CLOSE SJMP MAIN1;==============================================END
温馨提示:答案为网友推荐,仅供参考