Calibrating My Servos

All my servos are a little bit different to each other - I’ve built a rig to measure what PWM values turn my servos to a specific angle.

In a previous post on Hackster, I wrote about how I’ve created a rig to compare how different servos from the same batch rotate, and showed that sending the same PWM signals to different servos results in some significant differences - the picture below shows servos which all started in their furthest counter clockwise position and were sent the same PWM signal - they all have slightly different behavior.

Why not use existing servo libraries for the Arduino?
I use the Adafruit PWM Servo Driver to drive a bunch of servos, and this allows me to send a different PWM signal to each servo. I could use the Servo library which is built into my Arduino installation - but I’ve a few reasons for not doing this:

With the Adafruit PWM Servo Driver, I can control my servos using just two pins over I2C, rather than having dedicate a pin on my Arduino to every servo.
I’ve sometimes found with the Arduino Servo library that when I attach to a servo and send a signal for it to rotate to the zero degree position that it rotates to the limit of travel and grinds the gears inside the servo.
Of course the 9g servos that I’m using are cheap and not designed for accuracy - but I think I can squeeze some more value from them. I want to use them for a walking robot, and need their behavior to be a bit more precise and predictable.

How can I control my hobby servos more accurately?
Confirming that my servos all behave slightly differently made me want to build a device that would allow me to calibrate a servo - what PWM values do I need to send a servo to move to a 0 degree position? Or the 90 degree center point? How do I avoid sending a PWM value which snaps the servo to an extreme position with lots of crunching and gear grinding?

I decided to combine a couple of simple concepts.

Align my servo with the center of a simple protractor, so as the servo’s wiper rotates, I can measure its position.
Connect a potentiometer to an analog input of the Arduino, so I can control the position of the servo’s wiper by adjusting the PWM value as I adjust the position of the potentiometer shaft.
For this version, I was happy to use the Serial Monitor of my Arduino IDE to tell me the value of the PWM signal, which I can record manually.

I used Autodesk 123D to design a simple rig that would hold the potentiometer, the protractor, a single servo, my Arduino, and the Adafruit PWM servo driver along with a power supply.”


Related Content