Servo pulse widths

I am trying to answer a question about servos in another thread.

My research into servo behaviour suggest that a pulse should be received ever 20 mS (ie. 50 Hz) and the pulse width should be from 1 mS to 2 mS for the extreme ends of the travel (ie. 1.5 mS is the middle).

http://www.societyofrobots.com/member_tutorials/node/231

In setting up a test however I found that a 1 to 2 mS pulse width only moved the servo partly around its travel.

Then I tried a test sketch from the Servo library (part of the IDE I think) namely:

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 
}

That drove the servo 180°. So I measured the pulse widths and found they were 0.5 mS to 2.5 mS which is not what all the above references suggest.

The servo is a “micro servo 99 sg90”.

I found a page that specifies the pulse width for this particular servo as:

Pulse Width: 500-2400 µs

OK, so the servo is following specs, but how come all the references above mention 1000 to 2000 µS, and how come the servo library defaults to providing the correct pulse width?

OK, so the servo is following specs, but how come all the references above mention 1000 to 2000 µS, and how come the servo library defaults to providing the correct pulse width?

I think the standard spec for RC servo equipment is only +-45 deg rotation, so that is probably the reason the 1000 to 2000 µS range is referenced. The servo.cpp library contains the "default" us values as "default min is 544, max is 2400" microseconds. The servo library allows the default values to be changed in the "servo.attach" function. One could use an o-scope to see just how far the timing limits can be pushed. I think there needs to be a minimum of ~5us wait between pulses to the servo for the servo to accept the next pulse as a new command, so the full 20ms wait is not required for a new sequence. Some of these values date back to the older analog RC equipment. The below page is somewhat old, but it gives a good idea of just what is in a servo and how it works.

http://www.seattlerobotics.org/encoder/200009/S3003C.html

The actual range of servo travel varies a lot. I concur with zoomkat's comments.

The framerate also varies among rc receivers.

Not all servos can deal with this. For example a framerate of 9 ms can destroy some analog servo's

Other servo's are made for extreme framerates (up to 560 Herz). The are used where the input comes from gyros or flightcontroller. This will ofcourse give a faster response to changes than using 50Hz

Servos and servos