PDA

View Full Version : [Question(s)] Servo - Adjustable movement speed

nik
11-19-2008, 03:22 PM
Hi,

Planing to make some multiple servo controller.

What would be a good approach to implement smooth variable speed movements for a servo?

The only solution I see is not to tell the servo immediatelly what position it should go to, but for slower movements to have a timer that will increase the servo position in small steps (step length depends on desired movement speed and uC speed).

But theoretically that would produce non-smooth movements (yanking) i guess?

any other ideas or is this the way its usually done?

:happy:

Quantum
11-19-2008, 04:09 PM
I actually have been working on this for about 2 months using a Propeller from Parallax.

I tell it the postion to move to but I compare its current postion. I take the differences between the two and divided it by 100. Then I have a looping program that adds the result to my variable as it increases I send the comand to the servo. This actually moves the servo in steps.(There is no need to go any higher resolution than 100 since the servos smallest value of movement is only .09 degrees)

It s actually pretty smooth and looks very realistic. I also have variable speeds where there is no limit on the slow side but there is a limit on how fast before the Inverse Kinematic equation donsnt have enough time to finish computing. The math engine is on a seperate COG. The spec sheet explanies what a COG is and that can be found at Parallax.com

I can make a small video clip of my current progress.

Paul

nik
11-19-2008, 04:22 PM
Quantum: Thx, that helped. I was afraid that the step by step motion would produce non-smooth movements. I just didnt understand what you meant about that second var. speed thats associated with IK :|

I can make a small video clip of my current progress.

sure :)

11-19-2008, 07:04 PM
Welcome Aboard, Nik!

If you have a look at Metaform3D's recent posts, you'll see his work on something not unrelated, and some linkage to suggestions for algorithm.

nik
11-20-2008, 03:32 AM

thx for the welcome :) I read Metaform3D's topic before but I think its another problematic, related to servo electronics and its PID control.

11-20-2008, 04:30 AM
I think the concepts still hold sway. You have a distance, you're estimating that distance, and you're figuring your current position. You have a desired time and you need to cover that distance in that time. You can overshoot or undershoot time, not just distance (as in PID)

You might also poke a bit at the SSC32's firmware source-code, since it does an outstanding job of getting the algorithm correct...

nik
11-20-2008, 03:28 PM
Thx, I wasn't aware that LM published the source code. I'm curretly brainstorming :wink: on my solution but sure, will take a quick look at the code too :happy:

metaform3d
11-20-2008, 10:23 PM
If you have a look at Metaform3D's recent posts, you'll see his work on something not unrelated, and some linkage to suggestions for algorithm.For what it's worth, I've also worked on the related problem of making servos move slow. What I did was change the pulse width at a constant rate until it matched the target pulse width (actually, with the code I was using, the target servo angle). The code is straightforward except for the complications of using fixed-point integer math.

I did run into a lot of problems with the step size, however. I'm driving servos using the software servo control class that comes with the Arduino. Delving into their code I found that they had kind of botched some math which resulted in about half the precision that was possible. Fixing that, there was still a limit of 4 microsecond resolution to the pulses due to the scale factor on the pulse-counting register (I don't have the code in front of me so I forget the name). That's about 0.5 degree steps, not the theoretical 0.1 degree. It's basically still kind of quantized when it moves.

I think it may be possible to change the default scale factor on the register, but I'm not sure how to do it, or if it could be done, how it would affect the rest of the Wiring libraries.