Shop OBEX P1 Docs P2 Docs Learn Events
controlling a servo motor — Parallax Forums

controlling a servo motor

ArchiverArchiver Posts: 46,084
edited 2002-04-02 17:22 in General Discussion
Does anyone know how I can control a servo motor to move
about 90 degrees clockwise and then return to its starting
position (within a time frame of about 8 seconds)? I'm working
with a basic stamp 2 and need to have a continous back and
forth motion but the only programming code I'm finding is for
continuous (modified) servo rotation. Any info is greatly
appreciated.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-04-02 02:40
    Charles E. Fromage says:

    Quite simple actually.

    The first thing you want to do is physically measure the rotation of the
    servo by *carefully* turning it by hand. Some turn ~190-200 degrees or so,
    others are slightly less that 180 degrees. If you want you can put a piece
    of paper under the horn and mark the travel with reference to one of the
    screw holes in the horn.

    Secondly you need to figure out the PULSOUT period required to move the
    servo to neutral / center / 90-degree position. The first thing you need is
    the pulsewidth in milliseconds or microseconds that the servo requires to
    move to the center position. Armed with this, divide the value for the
    neutral position with the appropriate value from the table in the Stamp
    manual in the PULSOUT section. This will give you the *approximate* value to
    use in the PULSOUT statement. Make sure you use the same units.

    For example, a Futaba 148 servo has a neutral position value of 1,520
    microseconds. If I'm using a BS2, one period is 2 microseconds. So I divide
    1520 by 2 and come up with 760. My PULSOUT statement would have a period of
    760.

    Here is sample code for moving the servo to the center position and holding
    it there -- the servo is connected to PIN 0:

    Loop:

    PULSOUT 0,760

    PAUSE 20

    GOTO Loop

    Before you run the code, turn the servo almost one way or the other -- this
    is so you can see if it actually moves. If it does, you did good. You may
    need to juggle the PERIOD value a bit to actually move the servo to the
    center position. This is why you measure the rotation beforehand.

    Now you can figure out the numbers for 0 degrees and 180 degrees (or as
    close it you can get) and write the appropriate code to move and scan.


    Original Message

    > Does anyone know how I can control a servo motor to move
    > about 90 degrees clockwise and then return to its starting
    > position (within a time frame of about 8 seconds)? I'm working
    > with a basic stamp 2 and need to have a continous back and
    > forth motion but the only programming code I'm finding is for
    > continuous (modified) servo rotation. Any info is greatly
    > appreciated.
  • ArchiverArchiver Posts: 46,084
    edited 2002-04-02 16:55
    Use the PULSOUT (pin number), (time in Millisecond)
    150 is centre
    200 is one extreme
    100 is the other
    I maybe wrong
    Ben
    silver17audiocraft <averycording@h...> wrote: Does anyone know how I
    can control a servo motor to move
    about 90 degrees clockwise and then return to its starting
    position (within a time frame of about 8 seconds)? I'm working
    with a basic stamp 2 and need to have a continous back and
    forth motion but the only programming code I'm finding is for
    continuous (modified) servo rotation. Any info is greatly
    appreciated.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and Body of
    the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/




    BEN (TEAM DBR)
    http://www.geocities.com/temdbr



    Do You Yahoo!?
    Get personalised at My Yahoo!.

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-04-02 17:22
    I actual speed of the servo is set when it is designed and can be anywhere from
    .05 sec. to .50 sec. for 120 deg. of rotation. Because of this you'll need to
    "step" the servo to increase the time of that movement to 8 sec.

    One other option, though expensive, is to use a digital servo that is
    programmable. The speed can be programmed using and external programmer. Not
    sure if you can decrease the speed down that slow even with one of these.
    Besides speed, you can also program the end points or total movement of the
    servo and activate a "fail safe" position that the servo will return to if the
    signal to it is lost.

    While I'm sure someone could figure out what is needed to program these servos,
    they are fairly new and I haven't seen that info. All of this doesn't come
    cheap, the servo is about $90.00 and the programmer is about $250.00

    Hank

    > Ben
    > silver17audiocraft <averycording@h...> wrote: Does anyone know how I
    can control a servo motor to move
    > about 90 degrees clockwise and then return to its starting
    > position (within a time frame of about 8 seconds)? I'm working
    > with a basic stamp 2 and need to have a continous back and
    > forth motion but the only programming code I'm finding is for
    > continuous (modified) servo rotation. Any info is greatly
    > appreciated.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    > BEN (TEAM DBR)
    > http://www.geocities.com/temdbr
    >
    >
    >
    >
    > Do You Yahoo!?
    > Get personalised at My Yahoo!.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
Sign In or Register to comment.