Here is the program to control simple servo motor in both direction. I test it today and think that i should also share it with you people so that you can also enjoy and can take benefit. This program will rotate servo motor in both clock wise and anti clock wise direction you can modify it according to your requirement and according to your wish as suite to you.
Here is Proteus schematic layout.
Simple you need in this circuit one AT89C2051.
One 11.0592MHz crystal connect it to pin 4 and pin 5
29pF capacitors
One servo motor
connect all as shown in figure above.
After that use Keil software or any other software which you know how to use it for assembly language run this program and create hex file
and make changes as you wish then burn it into your controller and enjoy......
Program for Servo motor
;***SERVO MOTOR FREE CLK & ANTI CLKWISE ***
;OUTPUT=P1.0
;CRYSTAL=11.0592MHz
ORG 00H
MAIN:
MOV R2,#0FAH
MOV R3,#03H
RUNN:
ACALL START
DJNZ R3,RUNN
MOV R3,#0FFH
DEC R2
MOV A,R2
CJNE A,#0F6H,RUNN
RUNN1:
ACALL START
INC R3
MOV A,R3
CJNE A,#0FFH,RUNN1
MOV R3,#0H
INC R2
MOV A,R2
CJNE A,#0FEH,RUNN1
MOV R3,#05H
SJMP RUNN
START:
MOV TMOD,#11H
MOV TH0,#0FBH
MOV TL0,#0FBH
SETB TR0
CLR P1.0
AGAIN:
JNB TF0,$
CLR TF0
CLR TR0
HIGH1:
MOV TH1,R2
MOV TL1,R3
SETB P1.0
SETB TR1
AGAIN1:
JNB TF1,$
CLR TF1
CLR TR1
RET
END
Here is Proteus schematic layout.
Simple you need in this circuit one AT89C2051.
One 11.0592MHz crystal connect it to pin 4 and pin 5
29pF capacitors
One servo motor
connect all as shown in figure above.
After that use Keil software or any other software which you know how to use it for assembly language run this program and create hex file
and make changes as you wish then burn it into your controller and enjoy......
Program for Servo motor
;***SERVO MOTOR FREE CLK & ANTI CLKWISE ***
;OUTPUT=P1.0
;CRYSTAL=11.0592MHz
ORG 00H
MAIN:
MOV R2,#0FAH
MOV R3,#03H
RUNN:
ACALL START
DJNZ R3,RUNN
MOV R3,#0FFH
DEC R2
MOV A,R2
CJNE A,#0F6H,RUNN
RUNN1:
ACALL START
INC R3
MOV A,R3
CJNE A,#0FFH,RUNN1
MOV R3,#0H
INC R2
MOV A,R2
CJNE A,#0FEH,RUNN1
MOV R3,#05H
SJMP RUNN
START:
MOV TMOD,#11H
MOV TH0,#0FBH
MOV TL0,#0FBH
SETB TR0
CLR P1.0
AGAIN:
JNB TF0,$
CLR TF0
CLR TR0
HIGH1:
MOV TH1,R2
MOV TL1,R3
SETB P1.0
SETB TR1
AGAIN1:
JNB TF1,$
CLR TF1
CLR TR1
RET
END
No comments:
Post a Comment