program for a digital servo
jaspittman
Posts: 22
I tried to program for a digital servo and could not get it to function properly. I have included the code I used. On a slandered servo the program will rotate the servo clockwise one way hold for a few seconds and then rotate it the other way. With a hitec hs-5645mg the servo will move clockwise and then it stutters as it very slowly tries to moves counter clockwise. Any idea why.
'
[noparse][[/noparse]initialization]
reset:
LOW servo
'
[noparse][[/noparse]initialization]
Main:
counter = 0
FOR counter = 1 TO 1000
PULSOUT servo, (1000*/ pwAdj)
PAUSE 20
NEXT
FOR counter = 1 TO 1000
PULSOUT servo, (2000*/ pwAdj)
PAUSE 20
NEXT
END
'
[noparse][[/noparse]initialization]
reset:
LOW servo
'
[noparse][[/noparse]initialization]
Main:
counter = 0
FOR counter = 1 TO 1000
PULSOUT servo, (1000*/ pwAdj)
PAUSE 20
NEXT
FOR counter = 1 TO 1000
PULSOUT servo, (2000*/ pwAdj)
PAUSE 20
NEXT
END
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
' {$PBASIC 2.5}
'
[noparse][[/noparse]I/O]
servo PIN 8
'
[noparse][[/noparse]constants]
pwAdj CON $0080 ' pulse width adjust = .5
'
[noparse][[/noparse]initialization]
reset:
LOW servo
'
[noparse][[/noparse]initialization]
Main:
counter = 0
FOR counter = 1 TO 1000
PULSOUT servo, (1000*/ pwAdj)
PAUSE 20
NEXT
FOR counter = 1 TO 1000
PULSOUT servo, (2000*/ pwAdj)
PAUSE 20
NEXT
END