Re: Simple Servo Position Control Program - Is this right?
I've made some code that might help you.
It was for a high voltage SPDT servo switch for my research.
It sends a 1 second burst signal to the servo and then release it.
Usually thats more than enough time for the servo to react
Code:
'//ON INITIAL CONFIG
A VAR BYTE 'counter
SerPos var word 'servo position variable
sers var PORTB.0 'servo signal pin out
'//ON MAIN PROGRAM ROUTINE
'-Set servo position
serpos = 1300 'uS pulse width: 0º -> 1000uS / 180º -> 2000uS
gosub servout 'send pulse for 1 second
'//ON SUBROUTINES
servOUT: 'sends servo a PWM position signal for 1 sec.
for a = 0 to 59 '60hz
Sers = 1
pauseus serpos
Sers = 0
PAUSEUS 2000-serpos '2ms TOTAL
pauseus 14667 '2+14.667ms = 16.667ms -> 60hz -> 1seg total refresh time
next a
return
"If at first doesn't work, kicking it wont help either"
Bookmarks