Servo motor speed adjust

oric_dan(333):
servo.Write(150); // should go one direction
servo.Write(30); // should go the other direction.

servo.Write(90); // should stop.
servo.Write(80); // should go one direction slowly.
servo.Write(100); // should go the other direction slowly.

That is for a servo modified for continous rotation and not an unmodified servo.

I made a test, really didn't work like I want. I looking for a way to make that control, some idea let me know.
att
luis andrade

I made a test, really didn't work like I want.

So, what happened?

The motor went until the position called but in high speed.

I am assuming you are controlling the servos directly and not using a separate servo controller ?

An SD21 servo controller gives you an option to set a speed register but that is over kill if you are using 2 or 3 servos.

The example used in the SD 21 documentation to explain the speed is shown below, but this handled by the servo controller

The servo pulses are automatically refreshed every 20mS. If the Speed register is zero (0x00) then the servo is simply set to the requested position. On power up the Speed registers are set to zero to give full speed, so unless you need to slow them down the Speed registers can be ignored. If the Speed register is set to something other than zero then that value is added to the current position every 20mS until the target position is reached. If you wish to move from 1000 to 2000 and the Speed register is set to 10, then it will take 2 seconds to reach the set position. The formula for the time it will take to make the move is:

((Target position-Start position)/Speed Reg)*20mS

Here are some examples:

Start Position Target Position Speed Reg Time for Move
2000 1000 10 2000mS (2Sec)
1000 2000 10 2000mS (2Sec)
1000 2000 1 20000mS (20Sec)
1000 2000 100 200mS (0.2Sec)
1234 1987 69 220mS (0.22Sec)

Basically doing what your loop does but the load is moved to the servo controller.

This post may help http://arduino.cc/forum/index.php/topic,21975.0.html It is titled Servo timer so it may have the functionality you need.

That is for a servo modified for continous rotation and not an unmodified servo.

Yeah, I think I made a big mistake. My first comment should have been "is it a regular or modified servo?"
Apparently, it's regular, which is why the for-loop works.

The only way to control the movement speed of an unmodified servo is to keep updating the position values
every 20-msec or so. IE, interpolation, (start_pos - end_pos)/velocity = pos_increment per unit time.
That's probably what the long thread pointed to talks about. Either code this into the Arduino, or as indicated,
use a servo controller with this feature built-in.

I'm using a normal servo motor 0-180 degrees, I'm building a arm robot, the control is made directly without servo controller.

Try the "sweep" servo code example to see how it makes the servo move slower than usual.

The maximum speed a servo can move is strictly a function of the servo's design and what mechanical load it is attached to. However in your software you can make the servo move slower by issuing smaller step changes in position commands from start to ending desired position, and by waiting the appropriate amount of time between those issued incremental position commands. It would be pretty simple to write a user general purpose function such as:

void moveServo(int finalPosition, int stepTime);

Lefty

void moveServo(int finalPosition, int stepTime);

The hard part is integrating this thing into the rest of the program, so the updates are made on
nice even 20-msec time intervals, but it doesn't impact operation of other routines. Probably need
a timer interrupt to call the update code.

oric_dan(333):

void moveServo(int finalPosition, int stepTime);

The hard part is integrating this thing into the rest of the program, so the updates are made on
nice even 20-msec time intervals, but it doesn't impact operation of other routines. Probably need
a timer interrupt to call the update code.

The best solution is if the servo library (class) had such a function built into it so that it might be made non-blocking and closely synced up with the automatic servo framing rate being generated so that step change timing could be a even number of frame rates, 1 to 'very slow' . But alas I'm not up to the task as I just play being a programmer on this site, as solder is my real programming language. :wink:

Lefty

luis, what Arduino board are you using?

I'm using a arduino mega 2560.

I've been playing with the Arduino Servo library code today. Maybe I will be able to add velocity
control, but no guarantees as yet.

previous servo speed discussions that might be of interest.

Where were you about 8-hours ago? LOL.

What?
I didn't understand what you mean.

Sorry, I was speaking to zoomkat.

No problem.