Shop OBEX P1 Docs P2 Docs Learn Events
Servo direction question? — Parallax Forums

Servo direction question?

Electron JeffElectron Jeff Posts: 3
edited 2010-01-05 14:25 in BASIC Stamp
Does a servo automatically switch directions (clockwise / counter clockwise) as output pin is set to high?

Any help would be appreciated.

Thank You,

Parkview

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2010-01-04 03:52
    No. The servo control signal is a 1.0 to 2.0 mSec high-pulse, repeated every 20 to 30 milli-seconds, where the width of the control pulse determines the position of the servo. For a 'modified' servo like in the BOE-Bot, numbers below 1.5 milliseconds result in spin one way, over 1.5 milliseconds spins the other, and AT 1.5 milliseconds means "stop".
  • Oper8r AlOper8r Al Posts: 98
    edited 2010-01-04 05:17
    I found that the "What is a Microcontroller?" book available for free from parallax to be a great way to learn about servos. I believe chapters 4 and 5 deal with servos and ways to control servos. You can download a PDF of the book here : http://www.parallax.com/Portals/0/Downloads/docs/books/edu/Wamv2_2.pdf
  • James LongJames Long Posts: 1,181
    edited 2010-01-04 05:20
    allanlane5 said...
    No. The servo control signal is a 1.0 to 2.0 mSec high-pulse, repeated every 20 to 30 milli-seconds, where the width of the control pulse determines the position of the servo. For a 'modified' servo like in the BOE-Bot, numbers below 1.5 milliseconds result in spin one way, over 1.5 milliseconds spins the other, and AT 1.5 milliseconds means "stop".

    Allan,

    It should be noted that 1.5ms is center (regular servo) or stop (continuous rotation servo). That way you do not confuse people with that statement.

    The farther from 1.5ms, with respect to frequency, you get, the further a regular servo will "travel". For example, 1.0ms pulse width will be totally one direction while 2.0 will be an equal "travel" in the opposite direction from center. These pulse widths will depend on the servo in question. Some servos will take a higher or lower bandwidth of pulse. But usually the center is around 1.5ms. Also, most servos turn left with a smaller frequency, but that is not an absolute.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
  • BallNmIKEBallNmIKE Posts: 7
    edited 2010-01-04 21:52
    I am really confused as to how the servo knows which directions to turn as well. Is there any information out there that can help me to better understand it? The theory behind it? The Books and PDFs do not dwell on this subject. I dont like moving forward in the book if im not understanding what I have done so far. Thanks!!
  • James LongJames Long Posts: 1,181
    edited 2010-01-04 22:06
    BallNmIKE said...
    I am really confused as to how the servo knows which directions to turn as well. Is there any information out there that can help me to better understand it? The theory behind it? The Books and PDFs do not dwell on this subject. I dont like moving forward in the book if im not understanding what I have done so far. Thanks!!

    It is really pretty easy......

    A regular servo uses a wave form which can vary from 1.0ms to 2.0 ms. When the wave has a frequency of 1.5ms the servo will go to it's center position. If the frequency goes up or down the servo will travel one direction or another depending on the frequency being higher or lower than the center freq. When a regular servo travels, it is not a continuous rotation, it travels to a determined angle from center. This depends on the difference of the provided frequency compared to the center frequency. The greater the difference, the further from center it will travel. For example......you provide a servo with 1.0ms frequency. The servo will turn 45 degree to the left (from center). If you provide 2.0ms it will turn 45 degree to the right (from center). These are just for example, and not necessarily the exact amount of travel.

    Now........a continuous rotation servo is just a regular servo which has been modified. It has no center, so if it sees a frequency lower than center will will turn one way, and turn the opposite if seeing a frequency higher than center.

    Because a continuous rotation servo has no reference to center, it doesn't know where it is at. Therefore you can not tell it where to stop. It will stop when you provide it center frequency, and will continue to turn while it's provided a frequency above or below center.

    Now....here is where it can get confusing. The frequency that you feed to it doesn't have to be continuous (on at all times). It does however need to be fed to the servo every 20ms or so.

    I hope this helps........

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!

    Post Edited (James Long) : 1/4/2010 10:12:16 PM GMT
  • BallNmIKEBallNmIKE Posts: 7
    edited 2010-01-04 23:03
    Thanks for the speedy reply. I did continue searching and found another similar topic with some hand drawn pics that really helped clarify servo theory for me. I have a couple more specific questions now. 1.) I dont understand why the servos have 3 leads on them. 2.) This is the first time in this book "What's a microcontroller" that we use the Vin power terminals how does that relate? Theres some more questions, but I just dont know how to word them for everyone to understand. Thanks.
  • Austin S.Austin S. Posts: 5
    edited 2010-01-04 23:19
    Consider the command:

    PULSOUT 12, 750

    "750" represents 1.5mS and "12" represents pin 12 for the servo. Anything above 750 will make the servo turn counter-clockwise. Anything below 750 will make the servo turn clockwise. Also, if you keep 750, that means your motor shouldn't be moving in any direction. That's used to center your servo.
  • James LongJames Long Posts: 1,181
    edited 2010-01-04 23:22
    BallNmIKE said...
    Thanks for the speedy reply. I did continue searching and found another similar topic with some hand drawn pics that really helped clarify servo theory for me. I have a couple more specific questions now. 1.) I dont understand why the servos have 3 leads on them. 2.) This is the first time in this book "What's a microcontroller" that we use the Vin power terminals how does that relate? Theres some more questions, but I just dont know how to word them for everyone to understand. Thanks.

    Ok.......

    The three leads are the following (not necessarily in this order):

    input signal (control signal)
    Power (usually 5-6 volts)
    Ground (common,earth,etc)

    The input is only for the signal to tell the servo where to go.
    The power is to power the servo circuitry and the drive motor.
    Ground ......self explanatory.

    The reason the servo doesn't use the input line for power........a servo is usually connected to a RC receiver. That receiver outputs the signal to tell the servo where to move. If all the servos were powered through the signal, the output circuitry of the receiver would have to deal with a huge amount of current in it's signal circuitry. The separate power line allows the current to bypass the signal circuitry in the typical RC receiver. The power line also goes through the receiver, just not though it's signal circuitry.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!

    Post Edited (James Long) : 1/4/2010 11:37:09 PM GMT
  • James LongJames Long Posts: 1,181
    edited 2010-01-04 23:27
    Austin S. said...
    Consider the command:


    PULSOUT 12, 750



    "750" represents 1.5mS and "12" represents pin 12 for the servo. Anything above 750 will make the servo turn counter-clockwise. Anything below 750 will make the servo turn clockwise. Also, if you keep 750, that means your motor shouldn't be moving in any direction. That's used to center your servo.

    Austin,

    I like the example, but you should note why 750 represents 1.5ms. This would help the readers understand better what relationship 750 has to 1.5ms.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
  • Austin S.Austin S. Posts: 5
    edited 2010-01-04 23:44
    Thank you James for reminding me, that is a important note to mention.

    To find the actual duration that the servo is running, you do (2uS x 750) which is 0.000002 x 750·= 0.0015 or 1.5mS.
  • Electron JeffElectron Jeff Posts: 3
    edited 2010-01-05 01:45
    Thanks to everyone for your help. What you all said on your post made way more sense that the manual.

    Parkview
  • James LongJames Long Posts: 1,181
    edited 2010-01-05 02:00
    I missed answering a question......

    @BallNmIKE,

    Vin usually refers to the voltage supplying a board. Typically you will have two to three voltages on a board.

    You may have:

    Vin (Voltage in.......the raw power coming directly from the supply......a battery or a power adapter)
    VDD (Voltage for a digital device.....this can be 5 volts or 3.3 volts, but is usually low and regulated)
    GND (the common return for both of the above.

    The stamp uses VDD 5 volt power. I'm not sure what the Vin rating is for your board. There are different ratings for different boards.

    Hope this helps,

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
  • BallNmIKEBallNmIKE Posts: 7
    edited 2010-01-05 14:25
    Wow thanks everybody. This really helps. Since "Whats a microcontroller" is a starter book it really should explain more of the theory. That might be something for them to consider revising the starter books. Also my comp did not have a serial port so I had to buy a usb serial cable. They really should include those in these kits, or an option to just use usb on these boards.
Sign In or Register to comment.