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
Project Source on GitHub Project Gallery Return to the LEAP Catalog

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

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - 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
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.