Sg90 servo PWM settings

I have been tuning the pulse width for a really long time and I have no clue on how to get the angles correct. Every tutorial on the internet has different MIN and MAX values and I don't know which values are the best. I honestly have not much idea on how to exactly know what pulse values are needed. I use the adafruit PWM servo driver library, so... how do I get the correct values?

I determine the min and max experimentally. I write a short sketch that receives input from serial monitor and outputs to the servo. I slowly and carefully, manually, move the servo to the end stops and mark the positions on the servo. Then send values to the servo from serial monitor and note the values that line up with the marks, being careful to not hit the end stops and stall the motor. I use the Servo library and writeMicroseconds(), but the same method will work with the Adafruit board.

When you use the Adafruit calibration procedure given in what problems are you having? It seems fairly straightforward.

Personally I'd probably modify the basic Knob example to use that driver and add a switch to print the value to Serial.monitor at the points I was interested in. That's what I do to calibrate the normal Servo.h writeMicroseconds() values for particular servos.


Prob is, I don't know the proper maths involved in the code...

What maths? You try different values until you find the ones that work with your servos. Try MIN in the range 100 to 200 and MAX in the range 400 to 500.

If you want some maths then think that the Servo.h library works with a maximum range of pulse lengths from 544 microseconds MIN to 2400 microseconds MAX (in a total cycle of 20,000 microseconds). Translating that into Adafruit 12 bit PWM values gives roughly MIN 110 and MAX 490 (out of 4096 total). But you really don't need to know that, just do the tests.


Alright thanks then.
Although another problem, why does different servo motors of mine work differently? They are all the same brand...

Another thing I noticed is... with min around 150 and max around 600 at 50 Hz, the angles are awkward... 150 goes to something like 30 degree and the mid value of 150 and 600 is somehwere in 45 degree and 600 is at slightly more than 180 degree. Isn't that a bit weird?

I thoght it was due to damage servo, but most others respond the same way.