Gadgeteer servo control with the extender module and the Hitec HS-55

This week I worked on learning servo control with the extender module using a cheap Hitec HS-55 servo from Amazon. 

This solution can be found on my Gadgeteer GitHub repository.

Servo control requires PWM output.  This requires the extnder module be attached to a socket containing PWM pins.  I used sockect #11 which has PWM outputs for pins 7, 8, and 9. 

Extender module setup


The board has enough power to drive the servo using the 5V pin off the extender module.

Servo Assembly

After the setup, basic programming examples are easy to find on-line. The problem with most of the examples are they don’t take the time to move the servo into account. Moving the servo 1 degree doesn’t take as long as 180. I wanted a more accurate method.

First, I setup at button to start the servo moving on a separate thread.

My RunServo method calls a MoveServo method. In this example, I move the servo through a few position then through a range by 10 degrees.

The MoveServo method uses the current position and target position to calculate the range moved.  Looking up the specs of the HS-55 shows that for 4.8V the servo will move 60 degrees in 0.18 seconds.  This is about 3.333 miliseconds per degree (or a ns 100 pulse).  I round up to 4.