Servo rotating too slowly

Hello all,

I'm working on a project that requires a servo to rotate either direction in 60 degrees and then return to center quickly (a round trip back to center needs to be .4 sec or less). I have a futaba s3003 which is supposed to have a rotational speed of .19 sec/ 60 degrees on 6v power so I feel like a round trip should take close to .38 sec. However, it takes closer to 1 sec which is unacceptable. I am using 6v external power to power the servo so I don't think this is an issue.

Here is the code:

#include <SoftwareServo.h>

SoftwareServo _servo;

int SERVO_PIN = 9;
int MAX_PULSE = 2000;
int MIN_PULSE = 800;
int CENTER = 90;
int ANGLE = 70;
int DELAY = 4;


void setup(){
  _servo.attach(SERVO_PIN);
  _servo.setMaximumPulse(MAX_PULSE);
  _servo.setMinimumPulse(MIN_PULSE);
  Serial.begin(9600);
  _servo.write(90);
  delay(1000);
}


void loop(){
  
  wackClockwise();
  delay(1000);
  wackCounterClockwise();
  delay(1000);
  
}

void wackCounterClockwise(){
   for(int pos = CENTER; pos < CENTER + ANGLE; pos +=1){//move it to the right
     _servo.write(pos);
     delay(DELAY);
     SoftwareServo::refresh();
   }


   
   for(int pos = CENTER + ANGLE; pos  >= CENTER; pos -=1){//return it to center
     _servo.write(pos);
     delay(DELAY);
     SoftwareServo::refresh();
     Serial.println(pos);
   }
} 

void wackClockwise(){
   for(int pos = CENTER; pos > CENTER - ANGLE; pos -=1){//move it to the left
     _servo.write(pos);
     delay(DELAY);
     SoftwareServo::refresh();
   }
   
   for(int pos = CENTER - ANGLE; pos  <= CENTER; pos +=1){//return it to center
     _servo.write(pos);
     delay(DELAY);
     SoftwareServo::refresh();
     Serial.println(pos);
   }
 }

As you can see, this program repeatedly moves the servo 60 in one direction and then back to center, waits 1 sec then moves the servo 60 in the other direction then back to center. I am using the SoftwareServo library but the results are the same with the standard Servo.h library.

So my question is am I doing something wrong in the code? Moving a degree at a time seems like a clumsy way to control the servo but I can't seem to get it to work any other way.

Should I just invest in a faster servo? If so do you have any suggestions? Price is not a big issue, it just needs to work well.

Thanks for the help

the delay in your servo control loop is taking 4 mS per degree 240 mS (at least) to reach 60 degrees. if you just tell it to move from 90 to 150 it will go as fast as it can. You need a delay to wait for it to get there but you can tune the time so that the next command (150 to 90) comes just as it reaches 150.

//servo is at 90°
servo.write(150);
delay(190); //60 degree in 190mS spec
servo.write(90);
delay(190);

I have a futaba s3003 which is supposed to have a rotational speed of .19 sec/ 60 degrees on 6v power so I feel like a round trip should take close to .38 sec.

Lots of difference between rotation at a constant speed and the "round trip" actions.