adafruit/Adafruit-PWM-Servo-Driver-Library

Servo timing is wrong in example for regular servo's like sg90.

jhaand opened this issue · 0 comments

Concerns:
The example for the servo sweep in ./examples/servo/servo.ino

Expected:
Either the PWM values match the timing for the usec's below
or that they list the regular values seen with servos with the cycle time of 20 msec.
Which means a sweep between 500 and 2500 usec.

Observed:
This oversteered the maximum voltage for one of my servo's and it went spinning.
Also the maximum lower angle was not met.
The current values match the following timing

#define SERVOMIN  150  // (150 / 4096) * 20e3 = 732 usec
#define SERVOMAX  600  // (600 / 4096) * 20e3 = 2930 usec
#define USMIN  600 // These do not correspond to the calculated values above
#define USMAX  2400 //  These do not correspond to the calculated values above

Proposed:
Make the timing for the example sweep between 500 and 2500 usec.
like for instance:

#define SERVOMIN 102   // ( 500 / 20000 ) * 4096
#define SERVOMID 307   // ( 1500 / 20000 ) * 4096
#define SERVOMAX 491   // ( 2500 / 20000 ) * 4096
#define USMIN  500
#define USMAX 2500

You could change these values to sweep between 600 and 2400 usec like in the original example.
But at least keep it consistent and show how to calculate the values.