Shop OBEX P1 Docs P2 Docs Learn Events
Finding the extreme position of servo motor — Parallax Forums

Finding the extreme position of servo motor

kah yeekah yee Posts: 2
edited 2006-12-31 21:14 in BASIC Stamp
Dear all,

I am using BS2 microcontroller with the PBasic language.

Does anyone know how to find the extreme position (i.e., 0 degree and 180 degree) of a standard servo motor?
Is there a formula in doing so?

I have both Parallax and GWservo standard servo.

I went to Parallax website and found the document 'What's a controller - Chap 4: Controlling motion' which describes the pulses that make the servo rotates, however, the pulses only rotates between 2 o'clock (1ms), 10 o'clock(2ms), and 12 o'clock(1.5ms).

I changed the pulses from (1ms) to (0.8ms), and from (2ms) to (2.2ms), and that has further the range. But i need a formula that can find a prefered position.

Also, would it be harmful to the servos for the pulses that i have used (that i modified) and is it recommended to position it at its extreme (i.e., 0 and 180 degree) ?

Do i really need to make guess in order to find the position/range of the stepper motor? What is the normal range that won't harm a servo?

Thanks

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2006-08-23 13:11
    1. Servo's were built to provide a radio-controlled movement. As such, they were designed to 'follow' the motion of a hand-held joystick. Thus, repeatability from servo to servo was not really a concern of the manufacturer. Thus, servo's can vary a bit in the actual numbers that select the range. Thus, experimentation is the only reliable way to find out.

    2. No, you really shouldn't command a servo beyond its extremes. I think this will tend to wear out the motor, or the gears. Doing it a few times in experimentation should not cause any damage.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-23 14:35
    Since the two of the same servo model can have slightly different values for their ranges you will have to experiment for a particular servo to get the PULSOUT values that give you complete range.· I once wrote a small program (which I cannot seem to find) which allowed me to step through all values from the most extreme ends of the ranges and display the values on the DEBUG screen.· I used the program to find the furthest range values on the servo.· I will see what I can dig up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-23 16:36
    Okay,

    ·· I threw this little piece of code together to help you find the extreme positions on a servo.· It's designed for the BASIC Stamp 2, but the bonus to that is that the values displayed can be used with any BASIC Stamp when you're using our PSC, since it uses BS2 compatible pulse values.· I hope you find this useful.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-23 17:13
    kah yee -

    Let me just emphasize, clarify, or reinforce something that Chris already said. Here is what he said:

    "Since the two of the same servo model can have slightly different values for their ranges you will have to experiment for a particular servo to get the PULSOUT values that give you complete range."

    EACH servo. although they are the same make and model, MAY have slightly different "extremes". Thus, it is important to test EACH R/C servo on an individual basis, if you want a firm setting for each R/C servo motor.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • kah yeekah yee Posts: 2
    edited 2006-08-24 14:19
    Million thanks to everyone !!
    Very helpful comments!!
    Kah Yee
  • CanyonMannCanyonMann Posts: 7
    edited 2006-09-03 14:55
    Feel free to laugh at this stupid problem but i'm 3 days into it and i'm getting nowhere. this is my first time using servos or the basic Stamp and all I need is for the servo to move certain directions at certain times. The problem is no matter what pulsout i use, my servo (a Futaba FP-S28) only rotates clockwise until it sticks. I must be doing something stupid like using the wrong version of PBasic. Here's my code:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'just trying to get the servo to go to mid position
    '
    [noparse][[/noparse] I/O Definitions ]
    Servo·········· PIN···· 7·············· ' Servo I/O Pin
    pulseWidth····· CON···· 750··········· 'set pulsewidth at 750 which is hopefully mid-position
    Main:
    · DO
    ··· PULSOUT Servo, pulseWidth
    ··· PAUSE 20
    · LOOP
    · ' i have a 9V connected to my stamp and the red wire from the servo goes to a 5V DC supply and the black wire goes to ground and the white wire is
    · ' plugged into P7.
    ' no matter what pulseWidth i use, be it 500, 750, 1000, or 1 it alway rotates maximally clockwise and sticks and strains. Please show me the error of my ways
  • PARPAR Posts: 285
    edited 2006-09-03 17:38
    CanyonMann said...
    .... The problem is no matter what pulsout i use, my servo (a Futaba FP-S28) only rotates clockwise until it sticks. I must be doing something stupid like using the wrong version of PBasic. Here's my code:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'just trying to get the servo to go to mid position
    '
    [noparse][[/noparse] I/O Definitions ]
    Servo·········· PIN···· 7·············· ' Servo I/O Pin
    pulseWidth····· CON···· 750··········· 'set pulsewidth at 750 which is hopefully mid-position
    Main:
    · DO
    ··· PULSOUT Servo, pulseWidth
    ··· PAUSE 20
    · LOOP
    · ' i have a 9V connected to my stamp and the red wire from the servo goes to a 5V DC supply and the black wire goes to ground and the white wire is
    · ' plugged into P7.
    ' no matter what pulseWidth i use, be it 500, 750, 1000, or 1 it alway rotates maximally clockwise and sticks and strains. Please show me the error of my ways
    CanyonMann,

    What is your BS2 plugged into (e.g., Parallax board [noparse][[/noparse]which model/version]; homemade board)?
    (What is the specific wiring of the BS2 and servo to the two power supplies? A diagram would be useful.)

    Depending on your answer, ...

    Check/change your battery (are you getting enough voltage to the BS2, or is it resetting?).

    Is your servo's DC supply really putting out 5V?

    Check your wiring (is the servo _really_ plugged into port 7?)

    Try another servo (maybe the one you're using is defective?)

    PAR
    ·
  • CanyonMannCanyonMann Posts: 7
    edited 2006-09-03 18:04
    Well there's the problem with being poor an undereducated. The board, chip, and servo were given to me. the green board says BASIC Stamp II and Parallax at the bottom. above the chip i'm using it says BS2-IC. I'm pretty sure i'm using the correct pin because if i connect it to any pin other thant the one i designate with the PIN command than nothing at all happends. I can change it to whichever pin I want but it always just rotates clockwise.

    The parallax board has a port that a 9V battery plugs directly into.

    My 5 V power supply is wired positive directly to red wire of servo
    Ground directly to black wire of servo
  • PARPAR Posts: 285
    edited 2006-09-04 17:40
    CanyonMann said...
    ...·the green board says BASIC Stamp II and Parallax at the bottom. above the chip i'm using it says BS2-IC. I'm pretty sure i'm using the correct pin because if i connect it to any pin other thant the one i designate with the PIN command than nothing at all happends. I can change it to whichever pin I want but it always just rotates clockwise.

    The parallax board has a port that a 9V battery plugs directly into.

    My 5 V power supply is wired positive directly to red wire of servo
    Ground directly to black wire of servo
    So you probably have:

    this board: http://www.parallax.com/images/prod_jpg/27120.jpg·(Rev. D, 2004 ?), schematic at http://www.parallax.com/dl/docs/prod/boards/BS2CarrierBdSchem.pdf,

    and this BS2: http://www.parallax.com/images/prod_jpg/bs2-ic.jpg·(Rev. G ?),

    plus a 9-volt battery (is it a fresh battery?) to power to BS2-IC,

    and some kind of 5-volt power supply (unregulated wall wart?, or an voltage regulator IC driven off of the (same)·9-volt battery, or ...?)·for the servo power?

    Are the BS2 supply·battery·and servo·5-volt supply·grounds connected in common? (Earlier you said about the servo, "...and the black [noparse][[/noparse]servo]·wire goes to ground" Above you state that it's connected to the 5-volt supply ground. So it's a bit unclear how the two grounds are (or are not) connected in common.

    What brand/model of servo?

    Add this PBasic statement just above the "Main:" statement in your test program:

    DEBUG "Starting",CR

    Download/Run the program while the carrier board is connected to your computer/PBasic Editor Debug window to see if you see "Starting" once, or many times (should be once if your BS2 9-volt supply is ok).

    PAR
    ·
  • CanyonMannCanyonMann Posts: 7
    edited 2006-09-04 18:45
    I put that statement in and a blue window popped up and it said Starting once and the servo did the same thing, rotated all the way clockwise and strains against the stop point. The stamp is powered by the 9V battery which plugs into the port on the board and the power supply for my 5 Volts for the servo is plugging into the 4.5 V port on my Radio Shack Electronics Learning Lab and the ground is to the ground on the learning lab. i know it sounds rigged but i don't see any reason it shouldn't work (unless are all grounds not created equal?) the electronics learning lab is just a bunch of AA's in series or parallel depending on how you arrange them. i did confirm with my voltmeter that it is in fact 4.5 V and i can't imagine the 0.5 volts short is sabatauging me...or is it?
  • CanyonMannCanyonMann Posts: 7
    edited 2006-09-04 18:50
    ...and just to be a purist i measured the voltage difference between the negative on my 9V battery and the negative on my 5V and it's zero. Whew.
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-04 23:07
    You positively, absolutely MUST tie the 9 volt battery ground to the ground on the 'learning lab'. The control signal the BS2 puts out MUST be referenced to the same ground the Servo's are using, so those grounds must be tied together. The 'plus' voltages MUST NOT be tied together, if you have two supplies.
  • CanyonMannCanyonMann Posts: 7
    edited 2006-12-31 21:14
    Yup, that was the problems. All grounds are not created equal, it's really a shame.
Sign In or Register to comment.