Shop OBEX P1 Docs P2 Docs Learn Events
Question using servo included with "Whats a Microcontroller?" Book — Parallax Forums

Question using servo included with "Whats a Microcontroller?" Book

crdzobacrdzoba Posts: 1
edited 2009-05-26 20:29 in BASIC Stamp
I don't find the book's explanation very helpful in understanding how to get the servo to turn how I would like it to. I've followed everything in the book very well up until now, however the servo chapter is somewhat unclear to me. Can someone explain pulsout with degrees or radians, or by any other method that might be more clear?

What I would really like to be able to do is get the servo to make one continuous, smooth circular motion. However, I am not sure if this is possible.

Comments

  • dandreaedandreae Posts: 1,375
    edited 2009-05-26 20:18
    Here is a link that will give a lot of information regarding servos:

    http://books.google.com/books?id=4_G-1X9arWMC&pg=PA93&lpg=PA93&dq=Servo+and+radians%2Bdegrees&source=bl&ots=sf1JKJMtwi&sig=sZPgJ5ZcKlwcb5jdSJRCHHhCA-U&hl=en&ei=q00cSszMOJHEMcKesJQP&sa=X&oi=book_result&ct=result&resnum=9#PPA123,M1



    I hope this helps.

    Dave



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-26 20:29
    Another tutorial, "Robotics with the BoeBot", has more information on the operation of servos.

    Servos are commanded to move based on the width of a control pulse that's repeated about 50 times a second. The width of the control pulse can vary from anywhere from 1ms-2ms to as wide a range as 0.5ms-2.5ms. There are no formal requirements for any particular range. The amount of movement that you get from any particular pulse width range also can vary from servo model to servo model and from manufacturer to manufacturer. Typically, you'll get a movement over a roughly 270 degree arc, but it can be as little as 180 degrees to greater than 360 degrees depending on the way the servo is constructed and its intended use. Some servos have the mechanical stops removed and the servo mechanism is modified to produce a continuous motion where the width of the control pulse sets the direction and speed of the motor rather than the desired end position. These are known as "continuous motion servos" and are used as wheel motors on the BoeBot.

    If the servo is at one end of its range with a steady stream of control pulses of a width corresponding to that position, the servo will remain at that position. If you change the control pulse width to correspond to the other end of the servo's range, the motor will move continuously, smoothly, and relatively quickly to the other end of its range and stay there as long as the control pulses continue at that width. If you need slower movement, you will have to issue control pulses of gradually increasing or decreasing width so the servo can piece-wise approximate a smooth full movement through that range. The PULSOUT statement on the BS2 has a resolution of 2us. Over a range of 1ms to 2ms, that's a resolution of 0.2%. Because the pulses have to be produced every 20ms, the actual resolution achievable will depend on how fast you want the servo to move through it's range. For example, you'd get an effective resolution of 4% if you want the servo to move in 1/2 second.

    for i = 0 to 25
    pulsout myPin,i*20+500
    pause 20
    next i

    This starts out with a pulse width of 1ms (500 * 2us) and, every 20ms, issues a slightly wider pulse (20 * 2us more) each time, and ends with a final pulse width of 2ms (1000 * 2us). The total time involved is about 1/2 second.

    You can slow down the movement by making the step size smaller (than 20 * 2us) and using more steps (than 25).

    You can increase the range of movement by using more steps (than 25) and by starting with a narrower pulse (than 500 * 2us).
Sign In or Register to comment.