# Slowing Standard Servo in Code. Affect on Torque?

I've been trying to control the speed of a standard servo by incrementing its position degree by degree over time rather than a simple write to a given position.

``````void loop() {

tnow = millis();
elapsedTime = tnow - tlast;

if (elapsedTime > motorPause) {   //check for how long motor has been stopped at a position

if (lastAngle == 0) {           //check position to know which direction to turn

if (currentAngle == finalPos) { // if destination has been reached

lastAngle = finalPos;         // reset checker variable
tlast = millis();             // reset timer to next turn

} else if (tnow % motorDelay == 0) {  // else, if destination has not been reached, every [motorDelay] milliseconds, enter this statement

myservo.write(currentAngle + 1);    // increment position by 1

}

} else if (lastAngle == finalPos) {

if (currentAngle == 0) {

lastAngle = 0;
tlast = millis();

} else if (tnow % motorDelay == 0) {

myservo.write(currentAngle - 1);

}

}
}
}
``````

I was just wondering if anyone knows of better ways to do this (I saw mention of a Variable Speed Servo Library that seemed to be doing something similar to what I coded, but don't know if there might be other benefits to using that or something else to what I wrote).

I'm also curious if anyone knows if slowing the servo motion this way negatively impacts the torque available.

Thanks!

Hi,

I'm also curious if anyone knows if slowing the servo motion this way negatively impacts the torque available.

I think the answer is "Not Much".. each servo has it's own error-motor-power characteristic.

The only difference in a large move may be the motor speed is higher as it decelerates near the set position. But Not Much.

Other opinions??