Having trouble with servo control
I need to move a servo a very very short distance forward, and then make the horn go back up to its original position, and keep doing that every 50 seconds. (it's to push a digital camera shutter button)
I wrote the program to input pulse duration and number of pulses so I ran many trials and I still can't figure out how those two variables relate to servo position. (The book is a little vague)
Here's what I kinda concluded so far:
Long duration (close to 1,000) = Shorter distance traveled?
Low number of pulses (1-100) also = Shorter distance traveled
Short duration (close to 500) = Horn turns a full 180 degrees.
High number of pulses (300+) = Servo attempts to rotate beyond its limit
Pause 20 = No idea what happens if I change this
If I pulse a servo to move, can I always make it go to a set position (i.e., a certain combination of duration and pulse number will ALWAYS make a servo move to 12 0 clock, regardless if its current position). Or, do the pulses make it move to a location that is relative to its current location? (for example, if will always move 45 degrees left of where it currently is)
I still can't figure out how to make it go backwards. Can someone help me out, I'm totally lost here
I'm using the Parallax standard servo, BS2, and BOE development board Rev C.
I wrote the program to input pulse duration and number of pulses so I ran many trials and I still can't figure out how those two variables relate to servo position. (The book is a little vague)
Here's what I kinda concluded so far:
Long duration (close to 1,000) = Shorter distance traveled?
Low number of pulses (1-100) also = Shorter distance traveled
Short duration (close to 500) = Horn turns a full 180 degrees.
High number of pulses (300+) = Servo attempts to rotate beyond its limit
Pause 20 = No idea what happens if I change this
If I pulse a servo to move, can I always make it go to a set position (i.e., a certain combination of duration and pulse number will ALWAYS make a servo move to 12 0 clock, regardless if its current position). Or, do the pulses make it move to a location that is relative to its current location? (for example, if will always move 45 degrees left of where it currently is)
I still can't figure out how to make it go backwards. Can someone help me out, I'm totally lost here

I'm using the Parallax standard servo, BS2, and BOE development board Rev C.
Comments
Although standard R/C servos may APPEAR to operate in two directions (forward and reverse), they don't in reality. They will operate clockwise and counter-clockwise around a CENTER POINT, thus making them APPEAR to be truly reversible.
An R/C servo responds to positive going pulses from 1.0 to 2.0 ms in width. Thus, the "center point" is defined around a pulse duration of approximately 1.5 ms in width. This may vary slightly servo to servo, but should be near that point. Anything less than that, the servo will move one side of center, and anything more, the other side of center.
An R/C servo will also not maintian its position unless it is told to do so. Every pulse meant to maintain a servo in a given position MUST occur EVERY 20 ms or sooner. Barring receipt of such a pulse, the servo will return to the extreme-most direction, closest to the 1.0 ms side.
The PBASIC command to cause this pulse to occur is PULSOUT. PULSOUT needs the pin port number, and the width of the pulse to operate correctly. In PBASIC the pulse width is determined in units of time. The units of time differ between the various Stamp models. Check the PBASIC Reference Manual, or the PBASIC Help File for the appropriate time unit for the particular Stamp you are using.
I suspect you may have been using the PWM command which is NOT appropriate for this usage. PULSOUT is what you need here.
All that being said, if this were my project, I'd consider using a miniature DC solenoid to operate the shutter button, such as the one shown at the link below, rather than using an R/C servo, but that's just me. Such a solenoid would need to be driven by an external transistor, and NOT directly from a Stamp pin port, due to the current requirements.
http://www.allelectronics.com/cgi-bin/item/SOL-102/search/MINIATURE_12VDC_PUSH-TYPE_SOLENOID_.html
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
FOR Position= 350 TO 1150 STEP 200
FOR x = 0 TO 5
PULSOUT Servo, Position
PAUSE 20
NEXT
NEXT
Alright couple things, thanks for the code but I also wanna learn how it works I am a little confused, what are the two for loops for? From what I can tell, the outer loop runs four times, where each time it does five pulses for a certain duration. I assume the position is specified by me, right?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Team K.I.S.S
Build Safe, Build Mean, Build Strong!
· I noticed that you have min. & max.·values for the servo positions of 350 & 1150.· I was working with my new BASIC Stamp Discovery Kit for the first time today, and noticed that while the servo will physically·sweep more than 180 degrees if I move it by hand, it will only move about 90 degrees using PULSOUT duration values of 1000· & 500.
· Those two duration values should correspond to 1 & 2 msec respectively and command the servo to it's max. CCW & CW sweep postions should it not?
· By experimenting with the duration values I was able to make the servo sweep 180 degrees and ended up with values close to what you have in the code that you posted.