Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

controlling a servo with 8051

Status
Not open for further replies.

rauftolga

Newbie level 2
Joined
Apr 11, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
8051 servo

Hello,

I have been trying to control a servo with 8051. I am to move the servo 90 to clockwise direction, after 20 sec it is going to go counterclockwise direction. I am using a 12mhz clock.
I accomplished to move it to clockwise direction, but it does not come back. Here is my code, could anybody help me about what the problem is.
Thank you.
$DEBUG
$NOPAGING
$NOSYMBOLS
$MOD31

COUNT EQU -10000
ORG 30H



SERVOSTART: ;MOVES SERVO TO 0 DEGREE POSITION

MOV R4, #40D
SETB P3.0
CALL SHORTDELAY ;CALLS A 0.9MS DELAY
CLR P3.0
CALL LONG1DELAY ;CALLS A 19.1MS DELAY
DEC R4
CJNE R4, #00H, SERVOSTART



SERVOMID: ; MOVES SERVO TO A 90 DEGREE POSITION

MOV R4, #40D
SETB P3.0
CALL MEDIUMDELAY ;CALLS A 1.5MS DELAY
CLR P3.0
CALL LONG2DELAY ;CALL A 18.5MS DELAY
DEC R4
CJNE R4, #00H, SERVOMID


SHORTDELAY: MOV R4, #64626D
AGAIN: MOV TH0, #HIGH COUNT
MOV TL0, #LOW COUNT
SETB TR0
WAIT: JNB TF0, $
CLR TF0
CLR TR0
DJNZ R4, AGAIN
RET
LONG1DELAY: MOV R4, #46436D
AGAIN1: MOV TH0, #HIGH COUNT
MOV TL0, #LOW COUNT
SETB TR0
WAIT1: JNB TF0, $
CLR TF0
CLR TR0
DJNZ R4, AGAIN1
RET
MEDIUMDELAY:MOV R4, #64036D
AGAIN2: MOV TH0, #HIGH COUNT
MOV TL0, #LOW COUNT
SETB TR0
WAIT2: JNB TF0, $
CLR TF0
CLR TR0
DJNZ R4, AGAIN2
RET
LONG2DELAY: MOV R4, #47036D
AGAIN3: MOV TH0, #HIGH COUNT
MOV TL0, #LOW COUNT
SETB TR0
WAIT3: JNB TF0, $
CLR TF0
CLR TR0
DJNZ R4, AGAIN3
RET

END



Thank you
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top