I learned in school that typical servos use a simple PWM system to control a servo. To do this, we would generate a 1000ms pulse to put the servo at 0 degrees and 2000ms pulse to set it at 180 degrees. Simple basics, right?
I recently tried configuring my HS-311 with these values and I found the servo moving less than 90 degrees.
I switched to the Servo.h
library and it worked fine. I peeked at Servo.h
file and found the following:
#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo
#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
544? 2400? Where are these numbers coming from?
I looked at an old datasheet for this servo and found
OPERATING TRAVEL: 40�/ONE SIDE PULSE TRAVELING 400usec
DIRECTION: CLOCK WISE/PULSE TRAVELING 1500 TO 1900usec
A bit hard to tell what does numbers mean but they are definitely not 1000 to 2000!
Then I took a look at the specs on servocity.com and I see:
Max PWM Signal Range 575-2460μsec
This matches up with the Servo.h
source code!
What's going on here? Do manufacturers normally move outside of the 1000us-2000us range? These values that I see far exceed what I'd think are acceptable tolerances. Please help me figure out where these numbers came from!
analogWrite()
.