Shop OBEX P1 Docs P2 Docs Learn Events
Servos — Parallax Forums

Servos

GrendelTGrendelT Posts: 23
edited 2006-01-17 19:58 in Learn with BlocklyProp
This is my first stab at a microcontroller. I have a general understanding of basic electric circuits, I'm confused (I guess the book just glosses over it) about how the Servo actually works. I'm confused about the "pulse" given to the servo.

So far, my understanding is that the servos needs 9V (Vin) to drive the motor, and listens for 5V (pin-output) to begin movement.
My problem is, how does the servo know which direction to turn in relation to its current position?
I understand it is listening for pulses, and these pulses convery information to the server driver... The book, WAM, doesn't explain this information... Can someone here explain this?

(I've been playing with the servo setup in Chap.4, thanks for any help...)

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-10 21:07
    There are two different types of servos, standard and continuous rotation.

    First the standard type, inside the servo is a motor, control circuitry, gears and a potentiometer (variable resistor). The motor turns the gears which in turn rotates the potentiometer (and also turns the servo horn which is what you see on the outside). When the servo recieves a pulse, it compares the width of that pulse with the position of the servo horn by way of the potentiometer. If the two are the same, the servo is in the correct position and no movement occurs. If the two are different, the motor turns in the direction indicated by the difference between the pulse width and the current position until the two are the same.

    The width of the pulse indicates the desired final position of the servo, the pulse can vary in width from 1ms to 2ms. A pulse of 1.5ms is called a center pulse and indicates the servo should be halfway between the two extremes (normally 180 degrees or half a full rotation). A pulse width of 1ms would direct the servo to turn to one extreme, a pulse width of 2ms would direct the servo to turn to the other extreme. It follws that a pulse width of 1.25ms would direct the servo to turn halfway between the 1ms extreme and the center position, and a pulse width of 1.75 would direct the servo to turn to halfway between the center and the other extreme. Any other value would direct the servo to turn to the equivalent position proportional to that pulse width.

    A continuous rotation servo is a standard servo whose feedback potentiometer has been cut and replaced with fixed resistors whose values make the control circuitry·think the servo it is always in the center position. So any pulse width less than 1.5ms will make the servo spin in one direction, and any pulse width greater than 1.5ms will make the servo spin in the other direction. The servo will continue to spin as long as the pulse width continues to be outside a small window around 1.5ms, the servo will stop when the pulse becomes 1.5ms wide.

    The servo pulse occurs once every 20ms.

    I hope this clears things up for you, ask if your still confused on any part.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • SN96SN96 Posts: 318
    edited 2006-01-10 21:14
    Very well said Paul! [noparse]:D[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike

    ·
  • GrendelTGrendelT Posts: 23
    edited 2006-01-10 23:21
    Excellent. That was a quick, concise answer. Thanks!

    Post Edited (GrendelT) : 1/11/2006 4:56:44 AM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-11 14:59
    Not a problem, glad to help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • ZackaryZackary Posts: 10
    edited 2006-01-12 02:23
    I'm also a newbie. Thanks a lot for the really quick tutorial!

    Problem: Servo behaves irratically. Sometimes it moves step, step, step, step, but then it goes crazy. Step, step, dies. (Long wait) Step, craziness etc.

    I'm using
    - PIC16F877
    - Parallax continuous servo
    - Coding in assembly (with MPLab)
    - 5 V on everything (except the microcontroller)

    Could it be a faulty servo? Umm, I was new with servos, so I tapped the signal wire to power (5 V), to see what would happen. Could that have killed it? I also turned the servo by hand. Could that damage the unit?

    Thanks in advance!
  • ZackaryZackary Posts: 10
    edited 2006-01-12 12:48
    I should mention my pseudocode:

    Initialize
    For inifinity
    For 4 times
    Pulse servo for 1.25 ms
    Wait 18 ms
    Pause for a second
    For 4 times
    Pulse servo for 1.75 ms
    Wait 18 ms
    Pause for a second
    Repeat
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-12 14:29
    Paul Baker,

    · So, servo motors have only one speed then?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-12 15:30
    Zackary,

    ·· You should start your own thread and not hijack this one.· Since you are not using a BASIC Stamp or other Parallax Product you should post it in the Sandbox Forum.· Thank you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Beau SchwabeBeau Schwabe Posts: 6,547
    edited 2006-01-12 15:39
    Pj Allen,

    Not necessarily, some servos sense how much error there is between the input pulses
    and the potentiometer position and ramp the output to the servo motor accordingly. More
    error equals faster servo motor ; Less error equals slower servo motor.

    As with some continuous rotation servos, the speed can be affected by sending an input
    pulse slightly higher or slightly lower than a center position pulse (usually 1.5mS).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-12 15:49
    One problem is linearity in the speed.· Servos weren't designed for contiuous rotation.· They were altered to make them do something different from the intended design.· Now, when you send a pulse of 1.5 mS and move in either direction up or down from that as Beau suggested you will start to see and increase in speed in either direction.· But within a very narrow range you will most likely reach the servos maximum error adjustment curve where the speed of the servo does not differ even though you're still moving further from 1.5 mS within the servos nromally acceptable pulse width range.· I hope I was able to adequately convey my thoughts.· =)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-12 17:10
    I haven't seen Zackary start a new thead in the Sandbox, so I'll briefly explain the obvious problem here: Servos expect a pulse every 20ms, if it is an analog servo (Parallax's are) not feeding it regular pulses can produce erratic behaviour, you must eliminate the pausing for a second from your code and make the total time period 20ms including the pulse meaning a variable pause between pulses (20ms - pulse width) some can handle the 20ms period to fluctuate a bit, in which case you can just pause a fixed time between pulses as long as both add up to approximatly 20ms.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • GrendelTGrendelT Posts: 23
    edited 2006-01-15 06:39
    Is there a way to poll the servo for its current position?

    for use in a situation like this:
    - ask servo its position
    - add/subtract small position adjustment according to data
    - send new position adjustment, either up/down

    Still learning here, but I just made 2 photoresistor RC circuits, test the two, turn the servo either left or right depending on which "eye" is brighter.
    I'd like to have it turn the servo very slowly so it can track a light source...
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-15 06:56
    Grendel -

    You can not poll an ordinary analog servos, but I understand you can with some of the newer, digital servos which have a small microprocessor on board. You can certainly save the values from the last PULSOUT command, so from that point of view, you WILL know the current position, or at least the last place you told it to go.

    Regards,

    Bruce Bates
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-17 18:19
    So, if the servo has "proportional control" circuitry then one can effect different speeds (in one direction the speed with PW=1.75ms would be faster than with 1.55ms.)·

    Do the Parallax/Futaba continuous servos have "proportional control"?· [noparse][[/noparse]There's no mention of this in the data/pdf. ]
  • Aristides AlvarezAristides Alvarez Posts: 486
    edited 2006-01-17 19:58
    Hello PJ Allen,
    ·
    You are correct about the documentation. The doc on the servo page provides only the basic specs and sample code to test the servo.
    ·
    We have detailed information on how to control the servos in the Robotics with the Boe-Bot book. You can find the free download here (at the bottom of the page):
    http://www.parallax.com/detail.asp?product_id=28125
    ·
    Chapter 2 is a thorough introduction. Depending on your experience with electronics and the BASIC Stamp you will be able to skip some of the activities as mentioned in the chapter introduction.
    ·
    Then, Chapter 3 goes even into more detail building the Transfer Curve for your Parallax continuous rotation servo (you can skip the activities about building the robot).
    ·
    After going through that information you will be able to fully control your servo speed and direction with just using a pulse width generated by your BASIC Stamp. ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Aristides Alvarez
    Education and Technical Support Manager
    aalvarez@parallax.com
    Parallax, Inc. www.parallax.com
Sign In or Register to comment.