Continous Rotation Servo - How to...?
Mike C
Posts: 12
Hello,
I'm a bit confused about how these servos work. This is my code:
' {$STAMP BS2}
' {$PBASIC 2.5}
servo PIN 0
sensor PIN 1
charge_time VAR Word
main:
HIGH sensor
PAUSE 1
RCTIME sensor,1, charge_time
DEBUG DEC charge_time, CR
IF charge_time > 200 THEN
PULSOUT servo, 900
PAUSE 20
ENDIF
GOTO main
The servo would spin for a while then stop, I'm not sure why. Is it because the position has been achieved and it won't budge anymore? (since i felt that it is harder to manually spin the servo bc the servo seems to be holding it in place).
I'm connecting the servo using a voltage regulator 7805. I was also curious if I could connect a 2nd servo using the same voltage regulator or do I need to apply a 2nd one?
I was hoping that the servo would either be ON or OFF, so I'm a bit confused as to how it works.
Much appreciated for all the help (and patience) people have given me in this forum.
I'm a bit confused about how these servos work. This is my code:
' {$STAMP BS2}
' {$PBASIC 2.5}
servo PIN 0
sensor PIN 1
charge_time VAR Word
main:
HIGH sensor
PAUSE 1
RCTIME sensor,1, charge_time
DEBUG DEC charge_time, CR
IF charge_time > 200 THEN
PULSOUT servo, 900
PAUSE 20
ENDIF
GOTO main
The servo would spin for a while then stop, I'm not sure why. Is it because the position has been achieved and it won't budge anymore? (since i felt that it is harder to manually spin the servo bc the servo seems to be holding it in place).
I'm connecting the servo using a voltage regulator 7805. I was also curious if I could connect a 2nd servo using the same voltage regulator or do I need to apply a 2nd one?
I was hoping that the servo would either be ON or OFF, so I'm a bit confused as to how it works.
Much appreciated for all the help (and patience) people have given me in this forum.
Comments
' {$STAMP BS2}
' {$PBASIC 2.5}
Servo········· PIN··· 0
Sensor········ PIN··· 1
charge_time··· VAR··· Word
Setup:
· LOW Servo
Main:
· DO
··· HIGH Sensor
··· PAUSE 1
··· RCTIME Sensor, 1, charge_time
··· IF (charge_time > 200) THEN
····· PULSOUT Servo, 900
··· ELSE
····· PULSOUT Servo, 750
··· ENDIF
··· PAUSE 20
· LOOP
Two things I added: 1) The Servo pin is initialized low since the servo wants a high-going pulse (PULSOUT simply inverts a pin for the specified period, then inverts it back, and 2) I added the PULSOUT to stop the servo when the charge_time variable is less than 200.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I've implemented your code, but the servo would spin for a bit then stop, and also if the charge_time value goes back to < 200 and I turn the charge_time value back up to > 200, the servo would not move at all. I was hoping that everytime the charge_time is > 200 the servo would spin continously until the charge_time is < 200, then be able to re-initiate the process again.
Thanks again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I have tested with a debug and verified that the charge_time is fine.
I am not sure about power supply, but I'm using a Homework Board and I have a voltage regulator reducing the voltage down to 5 volts from Vin.
EDIT: Do not use the Vdd pin on th HWB -- the Vin connection is fine (servos can tolerate 9V).· Just be aware that if you do use Vin and more than one servo, you could go through your 9V battery pretty quickly.· Sorry for any confusion.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/27/2005 12:10:41 PM GMT
Would it be necessary to run the power from the battery thru the 7805 to down it from 6 volts to 5 volts?
Thanks again Jon.
P.S. If I am using two servos would I then need 10 volts of power to run them simultaneously?
Post Edited (Mike C) : 5/25/2005 11:15:05 PM GMT
With ample power now for your servos, your program should run fine.
Edit: I whipped up a quick diagram that should make things more clear.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/26/2005 12:16:24 AM GMT
Thanks for the diagram, I will post results after I get my hands on some batteries. [noparse]:)[/noparse]
At first I had trouble, the servo was just ticking in rotation and not spinning smoothly, then I realized that the sensor wasn't connected to the pin cuz there was no output on the debug screen. Hooked it up and everything works!
I'd like to thank Jon for your help and effort. I've trully found this forum to be more supportive than they needed to and people are willing to take the extra step to explain or show how things work.
THANKS!!! [noparse]:)[/noparse]