Servo Control with PSC: Synchronizing Multiple Servos
Problem (·
opportunity
·) 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
![cool.gif](http://forums.parallax.com/images/smilies/cool.gif)
![cool.gif](http://forums.parallax.com/images/smilies/cool.gif)
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 Williams
Applications Engineer, Parallax
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.
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."
·
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.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.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 Williams
Applications Engineer, Parallax