Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/18/05 16:18
Read: times


 
#87892 - More help please.
Hi again .
I have ny stepper motor working now but I'm left with one problem.
0 is inputted from the mt8870 as 0101 (which is bin for 10)
How will I edit my code(posted below) so it will be recognised as a zero.
How also does any one recomend I control 2 led's (P2.4 & P2.6) only when there is a zero input gone in for the stepper motor.

Basically at the moment I am inputting a 6 digit code of which the first 2 are a password to get in (2 & 1) the next two are for the amount of steps I want the motor to take (tens & units) The next digit is for the direction I want the motor to go (0 is anticlockwise 1 is clockwise) the final digit is what I plan to control the leds with. (ie) I want to be able to set the motor to 0 steps and just turn on an led.

Any help or advice you have would be great .
Thanks and have a good weekend .
Ro. (code below!)

;Take in a 6 digit DTMF code

$MOD831

ORG 000h
JMP MAINCODE

; EXTERNAL INTERRUPT
ORG 0013h
push PSW
PUSH ACC
CJNE R0, #00h, DIGIT2
MOV R1, P3

INC R0
JMP EXIT

DIGIT2:
CJNE R0, #01h, DIGIT3
MOV R2, P3
INC R0
JMP EXIT

DIGIT3:
CJNE R0, #02h, DIGIT4
MOV R3, P3
INC R0
JMP EXIT

DIGIT4:
CJNE R0, #03h, DIGIT5
MOV R4, P3
INC R0
JMP EXIT

DIGIT5:
CJNE R0, #04h, DIGIT6
MOV R5, P3
INC R0
JMP EXIT

DIGIT6:
CJNE R0, #05h, EXIT
MOV R6, P3
INC R0

EXIT:
POP ACC
POP PSW
RETI


MAINCODE:
mov P2, #00H
MOV R0, #00H
MOV R1, #00H
MOV R2, #00H
MOV R3, #00H
MOV R4, #00H
MOV R5, #00H
MOV R6, #00H
SETB EX1
SETB EA
SETB IT1




JMP WAIT
REWAIT:
MOV R0, #00H
;Wait for DTMF Input
WAIT:SETB P2.0

CJNE R0, #06H, WAIT

CLR P2.0
MOV A, R1
ANL A, #0F0H
MOV R1, A

MOV A, R2
ANL A, #0F0H
MOV R2, A

; 1 = 00010000
; 2 = 00100000
; 3 = 00110000
; 4 = 01000000
; 5 = 01010000
; 6 = 01100000
; 7 = 01110000
; 8 = 10000000
; 9 = 10010000

;r1,r2 Like User Password r1 = 2 r2 = 1
CJNE R1, #20H, WRONGPWD
CJNE R2, #10H, WRONGPWD



; r3 and r4 are the number of steps required r3 - number of tens r4 - number of
;units
; Max of 20
; Add r3 and r4
; Multiply r3 by 10
MOV A, r3
CALL CONVERT
MOV r3, A


MOV A, r4
CALL CONVERT
MOV r4, A

MOV A, r3
MOV B, #0Ah
MUL AB
ADD A, r4
MOV r3, A
MOV R3, #00H
; r3 now holds number of steps

MOV A, R5
ANL A, #0F0H
SWAP A
MOV R5, A

CJNE R5,#01H, TEMP
SETB P2.1
JMP LOOP
TEMP: CLR P2.1


LOOP: CJNE R3, #00h, STEP
SETB P2.2
JMP ENDOFLOOP
STEP:SETB P2.3
CALL DELAY
CLR P2.3
CALL DELAY
MOV A, r3
DEC A
MOV r3, A
JMP LOOP

ENDOFLOOP: CLR P2.2
MOV R0,#00H
JMP REWAIT

WRONGPWD:MOV R0,#00H
JMP REWAIT

; 1mS DELAY
DELAY:
push 07h
push 06h
MOV R7, #001D
rst_inner_loop: MOV R6, #250d
INNERLOOP: DJNZ R6, INNERLOOP
DJNZ R7, rst_inner_loop

pop 06h
pop 07h
RET





CONVERT:
ANL A, #0F0h
SWAP A
RET





END



List of 7 messages in thread
TopicAuthorDate
More help please.            01/01/70 00:00      
   Advice !!!!            01/01/70 00:00      
      lookup table ?            01/01/70 00:00      
   a bit of advise            01/01/70 00:00      
      thanks            01/01/70 00:00      
   new binary codes?            01/01/70 00:00      
   second bit of help :-)            01/01/70 00:00      

Back to Subject List