i want to check the speed and the direction of motor encoder(servo motor) via 8051... i have made the speed and direction parts of the program separately and they work fine but when i combine those parts it is not giving the direction properly.....need help urgent
org 00h
jmp main
org 0bh ;timer 0 ISR
jmp timer0
org 1bh
jmp timer1 ;timer 1 ISR
main:
mov a,#38h ; for initializing and setting fuctions of LCD
call command
mov a,#0eh
call command
mov a,#01h
call command
mov a,#06h
call command
mov a,#80h
call command
mov tmod,#66h
mov th0,#00
mov tl0,#00
mov ie,#8ah
setb tr0
setb tr1
jmp $
timer0: ;when timer 0 overflows(after 4 seconds) i divided the counter value by 4 so that it will give me pulse per second
; and direction is clockwise if timer 0 overflows before timer 1
mov a,tl0
mov b,#4
div ab
call convert
call send
call disp
jmp cw
exit2:reti
timer1: ;when timer 1 overflows(after 4 seconds) i divided the counter value by 4 so that it will give me pulse per second
mov a,tl1
mov b,#4
div ab
call convert
call send
call disp
jmp ccw ; and if timer 1 overflows before timer 0 the direction is counter clockwise
exit1:reti
cw:
mov a,#0c0h
call command
mov a,#'C'
call data_disp
mov a,#'L'
call data_disp
mov a,#'O'
call data_disp
mov a,#'C'
call data_disp
mov a,#'K'
call data_disp
mov a,#'W'
call data_disp
mov a,#'I'
call data_disp
mov a,#'S'
call data_disp
mov a,#'E'
call data_disp
mov a,#80h
call command
mov a,#01h
call command