Shop OBEX P1 Docs P2 Docs Learn Events
Servo Control with PSC: Synchronizing Multiple Servos — Parallax Forums

Servo Control with PSC: Synchronizing Multiple Servos

Rick KRick K Posts: 18
edited 2005-06-06 21:17 in Robotics
Problem (·cool.gif opportunity cool.gif·) definition:

Multiple servos under control of a PSC. Currently under control directly from a PC, but eventually·will be controlled via both a PC and Stamp. I want, for example, two servos to move different distances over the same period of time, so they end up at their new positions at the same point in time. (and move at the same ratio over their range of motion)

When it occurs: robots with a lot of degrees of freedom require synchronized movement of many servos to make up a more complex movement.

Solutions I've tried:

Solution one:

I've written a relatively simple brute force algorithm that repeatedly calculates which servo is farthest from its destination and moves that one a configurable amount. This one works pretty nicely, but it·jogs a bit, though as the servos are moving, and can result in a lot of instructions to the servo controller when set at a high precision (low jump distance).

Solution two:

Calculate the relationship between the distance to be moved and adjust the speed of the servos which have less distance to travel, for example:

servo 1: pos 300 to pos 1000 = distance to travel = 700
servo 2: pos 300 to pos 600 = distance to travel = 300

If I'm interested in executing this motion as fast as possible, than I could step servo 2 down 700/300, leaving servo one to cover the last 100 positions after servo two has stopped.

*************

I started to sketch more elaborate solutions with multiple synchonization points or non-linear approaches to issuing the speed changes.

Anyone hit this and come up with a solution? Am I making this more complicated than it is?

Any pointers would be appreciated.

thx

-r

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-06 16:15
    Just a thought: Use the ramp feature to slow the servo that has to travel the shorter distance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rick KRick K Posts: 18
    edited 2005-06-06 17:53
    Right. That's the essence of solution two above. (I used the term adjust speed instead of ramp in the original post)

    The follow on to that is to determine the ramp value to make them arrive at the same time, or move in a ratio as close as possible to linear over the travel distance.

    It's obvious if the slower servo has to travel a distance that is 1/2, 1/3 or 1/x of the longer one where x is an integer, but if it's 3/7, then the math is just a bit more involved (if you don't want to slow all the servos).

    I think I've got the basics for such an algorithm that will come close and be configurable, but was wondering if there was a "commonly used" solution. If noone posts something much simpler, I'll post the basic algorithm and folks can react to that.
  • BeanBean Posts: 8,129
    edited 2005-06-06 20:25
    One problem you are going to have is that RC servos don't provide feedback about their position. That is you don't know where they are. You can tell them to go to a certain position, but you don't know when they get there.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    Product web site: www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."
    ·
  • Rick KRick K Posts: 18
    edited 2005-06-06 21:15
    Yes, I realize that I won't achieve perfection, but figured I could make the movements as smooth and predictable as possible with a solid understanding of exactly what the ramp command and position report commands are doing.

    For example, if the a ramp value of 2 is two times slower than a ramp value of one (a linear relationship), then I can split up a series of commands that will achieve a relatively smooth transition, I think.·Here's an example:

    Example: One servo has to travel 700, the other 300 (in 2us units)

    With these numbers and some assumptions, if both servos are set in motion...
    First command:
    • slower servo (2): ramp value 2, distance 200
    • faster servo (1): ramp value 1, distance 400
    Second command:
    • slower servo (2): ramp value 3, distance 100
    • faster servo (1): ramp value 1, distance 300
    Then the servos should have traveled their respective distances in close to the same amount of time. A number of simple adjustments and possibly polling the positions could be used to help things along if, for example I wanted the servos to reach their halfway points at the same time. These numbers are straightforward to calculate (I think. I checked a number of examples)

    1. Figure the speeds for the slower servo
    1.1 Integer(700/300) Rounded down for speed one = 2

    1.2 Integer(700/300) Rounded up for speed two = 3

    2. Figure the distances for the slower (ramped) servo to travel at the two different speeds
    2.1 700 mod 300 = 100 distance units at speed two(for the slower servo)
    2.2 300 - 100 = 200 distance units at speed one (again, for the slower servo)

    This math could be adjusted for any stable relationship between ramp values, I think.

    So looking at the PSC doc, it says that the ramp is a value between 3/4 of a second and 60 secs. Is this just evenly chopping up the 59 1/4 seconds into 63 equal parts? How is the PSC figuring when the servo has completed its travel?

    This kind of control would be quite useful in designing, for example, gaits on walkers (my project is a humanoid), or a generalized motion editor. I guess the general question is "is this the kind of thing envisioned by the designers of the PSC or am I thinking about things it wasn't designed for?"

    Thanks again.





    Post Edited (Rick K) : 6/6/2005 9:30:06 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-06 21:17
    Remember that the PSC is "seeking a position" -- so it uses the ramp information to update the current position value as it moves toward the target position. If the ramp is zero, it goes directly from current postion to target position without any intermediate values.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.