[SOLVED] Need help in interfacing servo motor with 89c51!!!!!!!

Status
Not open for further replies.

itsHAIDER09

Newbie level 3
Joined
Nov 17, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Pakistan
Activity points
1,322
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
 

Show us your code

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

JMP exit2
CCW:
mov a,#0c0h
call command
mov a,#'A'
call data_disp
mov a,#'N'
call data_disp
mov a,#'T'
call data_disp
mov a,#'I'
call data_disp
mov a,#' '
call data_disp
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

jmp exit1

command:
call ready
mov p1,a
clr p2.0
clr p2.1
setb p2.2
call delay
clr p2.2
ret
data_disp:
call ready
mov p1,a
setb p2.0
clr p2.1
setb p2.2
call delay
clr p2.2
ret
ready:
setb p1.7
clr p2.0
setb p2.1
back:
clr p2.2
setb p2.2
jb p1.7,back
ret
delay:
mov r3,#50
here2:
mov r5,#255
djnz r4,$
djnz r3,here2
ret
delay_1:
mov r5,#50
l1: mov r4,#200
there:mov r3,#70
djnz r3,$
djnz r4,there
djnz r5,l1
ret
convert:
mov b,#10
div ab
mov r2,b
mov b,#10
div ab
orl a,#30h
mov r4,a
mov a,b
mov a,#30h
mov r3,a
mov a,r2
orl a,#30h
mov r2,a
ret
send:
mov a,r4
call data_disp
mov a,r3
call data_disp
mov a,r2
call data_disp
ret
disp:
mov a,#' '
call data_disp
mov a,#'P'
call data_disp
mov a,#'U'
call data_disp
mov a,#'L'
call data_disp
mov a,#'S'
call data_disp
mov a,#'E'
call data_disp
mov a,#'S'
call data_disp
mov a,#'/'
call data_disp
mov a,#'S'
call data_disp
mov a,#'E'
call data_disp
mov a,#'C'
call data_disp
ret
end

- - - Updated - - -

i'm also displaying it on LCD
 
Last edited:

Can you start of by putting comments in you code and please show us your circuit diagram
 

atlast i have completed project successfully without any help. thanx for not helping as i've learned a lot by doing it myself...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…