Shop OBEX P1 Docs P2 Docs Learn Events
What is wrong with this servo controlling code? — Parallax Forums

What is wrong with this servo controlling code?

trendtrend Posts: 112
edited 2004-10-18 05:43 in BASIC Stamp
Sorry for the flood of posts, but I am just excited about getting started on my new project[noparse]:)[/noparse]

I have a servo with these specs:
http://www.gws.com.tw/english/product/servo/servo.htm

most notably:
[list=4][*]Pulse width range (Frame time· : 16-23 ms)
[/list]Max : 2.1 ms
Min· : 0.9 ms



and

attachment.php?attachmentid=73697


Why doesn't my program run the servo with the above specs?:


' {$STAMP BS2}
Servopin CON 7
Temp VAR Word
start:
· FOR temp = 200 TO 1200
· PULSOUT Servopin,temp
· PAUSE 17
· NEXT
· FOR temp = 1200 TO 200
· PULSOUT Servopin,temp
· PAUSE 17
· NEXT
GOTO start

? Is it because of the 200 to 1200 and 1200 to 200 declarations?

I do have my servo hooked up to the bottom left pin on my bs2 (isn't that pin7?)

thanks Lee
324 x 127 - 4K

Comments

  • Ken GraceyKen Gracey Posts: 7,387
    edited 2004-10-18 04:17
    Lee,

    We've worked a lot with the GWS servos. Your lower value of 200 (400 us) is probably out of the servo's range of motion. According to their datasheet 0.9 ms (a PULSOUT of 450) is the lowest value you can send to the servo, so you're pushing against the mechanical stop and unless you wait a long time (you are stepping 2 us at a time) it might not move. I've seen GWS servos not match the specified values exactly, so I wouldn't be surprised if their data is a bit off. In fact, that's part of the reason we've switched to Futaba (for the Boe-Bot at least). How are you powering the servo? You can't connect it to the Stamp's 5V due to current source limitations, so use an external power supply of 5-6V and connect the grounds together.

    Try this:

    ' {$STAMP BS2}

    Servopin CON 7
    Temp VAR Word

    start:
    FOR temp = 500 TO 1000 Step 5
    PULSOUT Servopin,temp
    PAUSE 30
    NEXT

    FOR temp = 1000 TO 500 Step 5
    PULSOUT Servopin,temp
    PAUSE 30
    NEXT
    GOTO start

    Once you have it working you can experiment with different values. This range will play it safe between 1 and 2 ms, which is clearly within their range of motion if the datasheet is almost correct.

    Ken Gracey
    Parallax, Inc.
  • trendtrend Posts: 112
    edited 2004-10-18 04:22
    I used the above code, and the servo still didn't move.



    I am powering the servo with a seperate power supply (6v· 1.5amp) (power supply is known good).

    The pins I am using are known good.



    When I plug in the servo to the power supply, I hear it move for an instance.



    What can I do?



    thanks for all your help!
  • cyberbiotacyberbiota Posts: 79
    edited 2004-10-18 04:47
    Trend-

    Are your ground lines connected (from the stamp power·to the servo power)?

    Peter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dr. Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • trendtrend Posts: 112
    edited 2004-10-18 04:52
    No,

    servo:
    power supply + > servo +
    power supply - > servo -
    bs2 pin 7 > servo Signal Line

    then.. all the basic stamp's grounds are connected to the 9v battery and ground for the serial port.


    Should it be different?
  • cyberbiotacyberbiota Posts: 79
    edited 2004-10-18 05:28
    Trend-

    All the ground lines should be tied together (Stamp, Serial Comms and Servo power supply).· That should solve the problem.

    peter



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dr. Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • trendtrend Posts: 112
    edited 2004-10-18 05:43
    YEAH!!!

    That fixed it.

    Thanks cyberbiota and Ken, I would of NEVER figured this out without ya'll

    I am so excited [noparse]:)[/noparse]
Sign In or Register to comment.