Servos and Propeller
Hoffa
Posts: 46
Hi
I have a parallax servo. Earlier I have used basic stamp to control that servo using:
pulsout servo, NUMBER (750 for neutral)
pause 20
How can I do the same thing in Propeller?
I have a parallax servo. Earlier I have used basic stamp to control that servo using:
pulsout servo, NUMBER (750 for neutral)
pause 20
How can I do the same thing in Propeller?
Comments
Simply use the objects available in the Propeller Object Exchange as "Servo-4" or "Servo32_Demo V1.2"
Is there samples for easy understand.
Best regards,
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
''****************************
''* Basic servo postitioning *
''****************************
''This code uses the main cog, or a new cog to toggle a pin to produce the 1.5ms pulse to run a positioning servo or a continuous rotation servo motor
''compiled and buile by Bryan K.
''Servo pinout to Prop:
'' black = ground
'' red = 5 volts
'' white = signal coupled to a 1 k resistor to prop pin
''7_500 is the theoretical center
''9_000 is full direction 1
''5_000 is full reverse direction
''these values are different for each servo.
CON
_clkmode = xtal1
_xinfreq = 5_000_000
servopin = 15
VAR
long pulse 'change this value to change the pulse duration
PUB Servo
pulse := 7_500
dira[noparse][[/noparse]servopin]~~
outa[noparse][[/noparse]servopin]:=0
Repeat
!outa[noparse][[/noparse]servopin]
waitcnt(pulse + cnt) ' High time
!outa[noparse][[/noparse]servopin]
waitcnt(120_000 + cnt) ' Low time
1. You have
_clkmode = xtal1
Why not use
_clkmode· = xtal1 + pll16x
and run your Propeller at 80 MHz?· Of course, you would need to increase your timing values 16 times.
2. Using your method, you have a fixed pulse low time of 24 ms always.· Therefore, the total width of high and low times will vary with the high time.· Wouldn't it be better to subtract the high time from the maximum low time so that the pulses are at a fixed frequency?· Also, I though 20 ms between pulses was·recommended for servos.· How about:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
For instance:
This should be accurate to the clock cycle time (12.5ns at 80MHz).
here is the details of my project..
http://forums.parallax.com/forums/default.aspx?f=25&m=161756
I hope this helps...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski