You are on page 1of 2

;**************************************************************

; Program for moving the wheel on the car


; 27 /10/04
; Kevin Dixon
;*************************************************************
$mod652
start: mov r4, #0 ;table1 pointer
mov dptr, #stepper ; initialise dptr to point to start of table
again: mov a, r4 ; update table offset
movc a, @a+dptr ; mov the table values into a
mov p1, a ; mov value to the output port
mov a, r4 ; table offset used to locate table 2
add a, #stepper1-stepper ;locate the second part of the table
movc a, @a+dptr
mov p3, a
mov a, #10 ; place value for delay
call delay ; call delay
inc r4 ; increment offset
mov a, r4 ; mov count to acc to check if 15 reached
subb a, #stepper1-stepper ; subtract 3
jnz again ; keep repeating until 4 reached
jmp start ; if 4 reached repeat cycle
;************************************************************************
; delay routine, the period given in register multiplied by 10 mSeconds
;***********************************************************************
delay: mov r1, a ; value placed in the acc before call
delay1: call delay10ms ; routine called to delay 10mS
djnz r1, delay1 ; keep decrementing to Acc = 0
ret ; return from subroutine
;*************************************************************************
; delay 10ms routine waits for a period of 10 mSeconds
;************************************************************************
delay10ms: mov r2, #200 ; use value in r2 for outer loop
delay10ms1: mov r3, #12 ; use value in r3 for inner loop
again10ms2: nop ; do nothing to create delay
nop ; do nothing to create more delay
djnz r3, again10ms2 ; inner loop
djnz r2, delay10ms1 ; outer loop
ret ; return to the delay routine
;***********************************************************************
; table of data values
; used for stepper motor movement
;***********************************************************************
; Stepper motor wiring
; 7->p1.7
; 6->p1.6
; 5->p1.5
; 4->p1.4
; 3->p1.3
; 2->p1.2
; 1->p3.3
; 0->p3.4
; unused pin = high = input=p1.0,p1.1
;
; steps for motor p1
stepper: db 11001111b ; step 1a
db 01100111b ; step 2a
db 00110011b ; step 3a
db 10011011b ; step 4a
; steps for p3
stepper1: db 11100111b ; step 1b
db 11101111b ; step 2b
db 11111111b ; step 3b
db 11110111b ; step 4b
table_end:
; table of values
end

You might also like