[Solved] Difference in servo speed

Hi, when moving a servo from 0 to 180 degrees, i realize a delay of 15-20ms must happen or otherwise it wont be able to get to 180 degrees. Meaning if i make the delay 10ms it would go 90degree then go back to its original position which i set to 0 degrees.
Now....its annoying because each degree needs 15-20ms to complete so by the time it goes from 0-180 degrees, that's kinda slow, but the funny part is when it does back from 180 degrees to its starting position, its a lot faster.....how can i reach that speed of the servo while going to my position the same way it goes back to its original position.

#include <Servo.h>
Servo myservo;

const int angleIncrement = 1;
const int incrementDelay = 10;

void setup() {
  // put your setup code here, to run once:
  myservo.attach(7);
}

void loop() {

  for (int angle = 0; angle < 180; angle += angleIncrement) { // single "degree" increments
    myservo.write (angle);
    delay (incrementDelay); // so we'll take 10 * 180 milliseconds = 1.8 seconds for the traverse.
  }

}

basically i want it to be as fast as its able to be

The servo library only updates once every 20ms.

Why are you moving it 1 degree at a time? Why not just do a:

myservo.write(180):

?

If you want to control the speed of a servo, there are the VarSpeedServo and MobaTools servo libraries that make it pretty easy to do and non-blocking, unlike your for loops.

it will still be slow, can you show me an example

is that something i can change in servo.h library?

Does it wait for 20ms to expire if there's a new servo.write() before then? I know it refreshes every 20ms (by default, and yes @nice_servo you can change that in the library source) when a new value is not sent; I've 'scoped that before. But I've never 'scoped to see if a new write causes a new signal to the servo before the normal update time.

I did, in #4.

the varSpeedServo does increase speed; would the fastest speed be 100 or other?

You could get hold of the servo spec.
If a servo is capable of 60 degrees in 0.15 seconds, that's 7.5 update cycles (0.15 / 0.02).

From the VarSpeedServo documentation:

write(value, speed) - speed varies the speed of the move to new position 0=full speed, 1-255 slower to faster

if i use speed 0= full speed, it becomes the same issue as servo.h , it doesnt complete the new position cycle, it jerks back quicker.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.