Shop OBEX P1 Docs P2 Docs Learn Events
can any one help me to test the Servo motor with Basic Stamp — Parallax Forums

can any one help me to test the Servo motor with Basic Stamp

MblackMblack Posts: 3
edited 2009-12-25 08:20 in BASIC Stamp
Hi.
i am working on my graduation project which is about controlling a robot arm to do some kind of spiral rotation,am using the basic stamp2 microcontroller ,i have tried to test whether i can control a servo motor using BS2 SEROUT instruction, but that seems a little bit difficult, the servo does not make any movement.
please if you have any idea, that will help me much.
thank you.

Comments

  • kf4ixmkf4ixm Posts: 529
    edited 2009-12-24 22:12
    hi there, you need to use the PULSOUT command instead of the SEROUT.

    Connect your servo to pin 14.

    ' What's a Microcontroller - ServoTest.bs2
    ' Test the servo at three different position signals.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    counter VAR Word
    main:
    DEBUG "Counterclockwise 10 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 500
    PAUSE 20
    NEXT
    DEBUG "Clockwise 2 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 1000
    PAUSE 20
    NEXT
    DEBUG "Center 12 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 750
    PAUSE 20
    NEXT
    DEBUG "All done."
    GOTO main


    Post Edited (kf4ixm) : 12/25/2009 1:41:39 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-24 22:23
    The "Robotics with the BoeBot" tutorial has a good discussion of servo motors, how they work, and how to control them with a Stamp.

    Here: www.parallax.com/tabid/535/Default.aspx
  • MblackMblack Posts: 3
    edited 2009-12-25 00:15
    thank you very much kf4 and Mike.
    i was reading a book with the Aric Robot just using the "SEROUT" to control the servo motor, i have seen the PULSEOUT but i did not try it. i will try it and will give u any feedack, whether it works fine or not...

    one more thing to ask you is: how can i canvert an angle to a pulse and vice verse, what i mean is that i am just making the kinemetics of the design, i will find angles of the robot arm joints when i am done with the kinemetics and inverse kinemetics, when it comes to programming the basic stamp, it only needs a pulse as an input the move the servo motor to a posotion defined by that angle, so can you think about this...just try it and tell me your findings.
    thank you
  • kf4ixmkf4ixm Posts: 529
    edited 2009-12-25 00:49
    for most servos, a pulse width of 1.50 ms will give you a 'in the middle' servo position, this would translate to in pbasic for the bs2 to:
    pulsout 14, 750

    if you change the '750' to '1200', you will notice the servo index to the far right, 300 to the far left. i would start with taking the pulse span, 1200-300=900, divide that by 180, (most servos will go to 210 degrees, 180 will be safe), you will come up with 5. therefore if you increase the pulseout command by 5, (eg. pulsout 14, 300; pulsout 14, 305; pulsout 14, 310) this will ROUGHLY give you one degree of motion for each increase of 5. Now i say Roughly because of the fact that most servos will have some kind of 'slop' between the geartrain and the potentiometer inside the servo. age, use, brand of servo·and even temp will have some sort of effect on the actual position also.

    http://www.seattlerobotics.org/guide/servos.html

    Post Edited (kf4ixm) : 12/25/2009 1:35:32 AM GMT
  • MblackMblack Posts: 3
    edited 2009-12-25 08:20
    thnk you kf4ixm, it has worked fine really , it only needed to interface the pins, that is all.
Sign In or Register to comment.