Please help me--- - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please help me---

Its an 8051 uController. You think its possible for you to develop any routines for me for which you are suggesting. Please help me do so cos I have until WED of the 20th. the latest. Better yet- could you design the entire code if possible and complete the two missing routines.





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 FASTROUTINE



CALL WAITS



CALL FORWARDSHAFT



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 REVERSESHAFT



CALL ROLLSTOP



jmp start ; ß---counterclockwise



WAITS: MOV R2, A ;FULL WAITS (SHORT) IS APPR.2 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











FORWARDSHAFT: ;Turn shaft in certain positions during FORWARD movement



MOV P1,#45 ;Turn it 45 degrees.



CALL WAITS



MOV P1,#90 ;Turn it 90 degrees.



CALL WAITS



MOV P1,#180 ;Turn it 180 degrees.



CALL WAITS



MOV P1,#270 ;Turn it 270 degrees.



CALL WAITS



LJMP START



RET



REVERSESHAFT: ;Turn shaft in certain positions during REVERSE movement



MOV P1,#10EH ;Turn it -270 degrees



CALL WAITS



MOV P1,#0B4H ;Turn it -180 degrees



CALL WAITS



MOV P1,#5AH ;Turn it -90 degrees



CALL WAITS



MOV P1,#2DH ;Turn it -45 degrees



CALL WAITS



LJMP START



RET











;FASTROUTINE: ;Maximum speed to the UNIPOLAR STEPPER



ORG 8100H ;Begins my origin



MOV TMOD, #02H ;8-bit auto/reload



MOV TH0, #-12 ;-12 reload



SETB P1.0 ;Set P1.0 high



SETB TR0 ;Start timer



LOOP: JNB TF0, LOOP ;Wait Overflow



CLR TR0 ;Stop timer



CLR TF0 ;Clear overflow



CPL P1.0 ;Toggle Port bit



MOV P1,#00000001B ;1





MOV P1,#00000010B ;2





MOV P1,#00000100B ;4





MOV P1,#00001000B ;8





RET



SJMP LOOP









;SLOWROUTINE: ;Minimum speed to the UNIPOLAR STEPPER









ROLLSTOP: MOV P1,#00000000B ;TURN OFF MOTOR

RET

END












Sign In or Register to comment.