Home‎ > ‎

12 servo Hexapod using an Adafruit PWMServo Shield

Introduction

Driving 12 servos with an Arduino can be difficult.  It can be done using the default servo library but I have found that there are many library conflicts, low memory issues and not many pins left over for additional features.
The Adafruit PWM/Servo shield communicates using only two pins: A4 and A5 on an Arduino UNO.  The shield offloads all the servo signal generation...leaving the Arduino free to run other processes.

Materials used

1 x Iteaduino UNO or other Arduino UNO compatible board
1 x Battery Holder 4xAA to power the servos
1 x 9V battery holder with switch to power the Arduino and shield
1 x IR Receiver Diode to add remote control functionality
1 x TV Remote (any IR remote control will work)

Wires and double-sided tape to hold things in place.

Construction Tips

Luckily, the Hexapod is not difficult to assemble because the instructions are very sparse.  My kit didn't seem to have exactly the correct number of screws to connect the "hip" to the chassis using recommended 4 screws.  I used 3 screws for each and everything seems to be solid.  Take it slow and use a good quality screwdriver.

Another possible source of confusion is that all the servos must be installed in their center position.  This seems complicated at first but it really not an issue because each servo can easily adjusted after completion.

The Adafruit shield requires some soldering.  There are good instructions on the product page.  To facilitate the connection of the IR Receiver Diode a three pin header was added to the prototyping area on the shield.  The receiver needs to be connected to 5V, GND and pin 11.

Power


In order to keep it simple a 4xAA battery pack was directly connected to the Servo Power on the shield.  This battery pack only powers the servos.  The Arduino and shield are powered via a 9V battery through the barrel connector.

Required LIbraries

Adafruit PWM Servo Driver Library
https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library

IR Remote Control Library from CY's Tech Talk
http://tech.cyborg5.com/irlib/

This IR remote library is a rewrite of Ken Shirriff's famous library.  In many cases libraries that use Timer Interrupts can conflict with other libraries.  One of the benefits of this library is that it allows the timer that is being used to be changed.

Code for Arduino on GitHub

servoWrite(servo,pulse in microseconds) function

In order to use the shield with the original Hexapod code a function is required to send the correct pulses (in microseconds) at 50Hz to the servos.  The function servoWrite() was created for this purpose.  For example the instruction servoWrite(0,1500);  sets servo #0 to the center position (for the servos in this kit).  
Comments