R/C servos have a standard pulse width range of 1000 to 2000µs1, with the zero point between the two at 1500µs. Currently, Arduino's Servo library sets:
This causes a lot of confusion2, especially since [the docs say write(90)
should correspond to the mid-point] (https://www.arduino.cc/en/Reference/ServoWrite); in actuality, it results in a call to writeMicroseconds(1472)
3.
This change adjusts the defaults to align with R/C standards. Specifically,
write(0)
now corresponds to the standard min pulse width of 1000µs.write(90)
now corresponds to the standard zero point pulse width, and aligns with the library'sDEFAULT_PULSE_WIDTH
variable.write(180)
now corresponds to the standard max pulse width of 2000µs.
Tested on an Arduino Uno with a Tower Pro Micro Servo SG90, and a Parallax Feedback 360° High-Speed Servo.
1: For example, http://www.ee.ic.ac.uk/pcheung/teaching/DE1_EE/stores/sg90_datasheet.pdf
2: For instance:
- julianduque/beaglebone-io#54
- arduino-libraries#3
- https://toolguyd.com/oscilloscope-arduino-servo-pwm-signal-mistakes/
- https://makezine.com/2014/04/23/arduinos-servo-library-angles-microseconds-and-optional-command-parameters/
I also see a lot of posts on https://forum.arduino.cc about this.
3: There is actually no way to set a standard servo to the zero-point using write(angle)
; the closest you can get is write(92)
, for a pulse of 1504µs.