| ??? 12/08/00 05:31 Read: times |
#7085 - need additional sub routines written |
I need some additions to my program where I can variable the speed of the motor. How do I add the routines for making a stepper motor to go fast and slow in either directions-right and left. Also how do i make it so it will turn at certain angles like turn at 45,90,180,270,360 degrees. I have an L297 H-Bridge motor driver connected to the stepper motor (unipolar). I'm using 8051uC.
org 0000h jmp main org 0100h main: CALL ROLLSTOP mov p3,#11111111b START: jb p3.0,forward ;PIN 3.0 IS ON - forward jnb p3.0,reverse ;PIN 3.0 IS OFF - reverse jmp start ; FORWARD: MOV A,#98 ;WAIT 1sec TO START RUNNING CALL WAITS CALL INITFORWARD ;SET MOTOR IN FORWARD MOTION CALL WAITS CALL ROLLSTOP jmp start ; ß---clockwise ;SET MOTOR IN REVERSE MOTION REVERSE: MOV A,#98 ;WAIT 1sec TO START RUNNING CALL WAITS CALL INITREV CALL WAITS CALL ROLLSTOP jmp start ; ß---counterclockwise ; WAITS: MOV R2,A ;FULL WAITS (SHORT) IS APPR.1.62 sec WAIT2: DJNZ R0,WAIT2 MOV R0,#00000011B DJNZ R1,WAIT2 RET ; PAUSE: MOV A,#49 ;PAUSE 1/2sec AFTER MOVING CALL WAITS RET ; ;SET FORWARD MOTION INITFORWARD: ;The unipolar stepper motor begins in motion ( Phase 1) MOV P1,#00000001B ;1 CALL PAUSE MOV P1,#00000010B ;2 CALL PAUSE MOV P1,#00000100B ;4 CALL PAUSE MOV P1,#00001000B ;8 CALL PAUSE RET ; ;SET REVERSE MOTION INITREV: ;The unip. step. motor begins its backw. motion ( Phase 2) MOV P1,#00001000B ;8 CALL PAUSE MOV P1,#00000100B ;4 CALL PAUSE MOV P1,#00000010B ;2 CALL PAUSE MOV P1,#00000001B ;1 CALL PAUSE RET ; ROLLSTOP: MOV P1,#00000000B ;TURN OFF MOTOR RET END |
| Topic | Author | Date |
| need additional sub routines written | 01/01/70 00:00 | |
| RE: need additional sub routines written | 01/01/70 00:00 | |
RE: need additional sub routines written | 01/01/70 00:00 |



