Fork me on GitHub

Project Notes

#042 ServoTest

Test the positioning accuracy of an SG90 servo motor driven by an Arduino

Notes

I’m testing the control of a TowerPro SG90 9g Micro Servo. According the the datasheet, this has a 180 degree sweep.

ServoTest accepts a range of commands over the serial interface to perform various servo positioning tasks. See the spash screen when you open the console window for options.

console

Cable connections

The three cable connections to the servo are identified as follows:

Connection Wire
PWM orange
Vcc red
Ground brown

Powering the Servo

The servo operates at 4.8V/5V. While you can tap power directly from 5V Arduino pin, this is not really recommended (especially if more than one servo connected) as the current requirements can overwhelm the Arduino.

Performance

First up, the servo is pretty zippy.

But as can be seen in the chart below, the default positioning using the Servo library with this specific servo is a bit off. Specifically:

  • The full sweep is accurate - very close to 180 degrees.
  • When positioning at 0 or 180, it overshoots by 5 degrees or so before rebounding to the correct position. It doesn’t have this behaviour for intermediate settings. Curious.
  • The step positioning between 0 and 180 under by about 15 degrees e.g. the request top position at 45 degrees results in an actual position of about 30 degrees.
  • I tried a few different SG90 units, and the all exhibit similar but not exactly identical behaviour.

Here is my little positioning chart:

Performance

I suspect the positioning accurcy may be largely fixed by tuning the Servo pulse width settings. TODO: that’s an investigation for another day..

Performance - Refined

So I came back to the issue of accuracy, with some interesting findings:

  • for the particular servo in hand, the min/max pulse widths needed some modification. Using myservo.attach(SERVO_PIN,600,2320); gives a much high degree of accuracy fo 0-180 degree sweep than with the default settings (544/2400).
  • the servo appear quite sensitive to power. If a battery is running out of juice, will start to get trembling in the positioning.

Construction

The Breadboard

The Schematic

The Build

Credits and References

About LEAP#42 ServoArduino

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics projects - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader