I2C servo controller board

Hardware - the DIY controller board

Board PCB layout, finished:
board PCB layout board photo

CadSoft Eagle files: atmega8servo.sch atmega8servo.brd

Parts: ATMEGA8, some 8..16MHz crystal preferrably small HC49US package, LM7805 5V TO-220 regulator, LM2576 or LM2597-5V TO-220 buck regulator, any 5A 30V schottky, 330uH toroidal ferrite core inductor, 10kOhm piher/trimmer, some polypropylele pulse capacitors and good electrolytics, a couple of surface mount capacitors and resistors (easy to solder!)

Board specs: 6..20V input, configured with I2C commands, 6 controllable servos (working), servo on-board power 3A max total and with adjustable 5..6V, 2 SRF04 rangefinders (not yet coded), 4 ADC channels (not yet coded), 4 I/O (not yet coded), own power supply for servos.

Servos: the board has been tested with Hitec HS-322HD and digital Graupner 5149 DS8077, so other normal and "digital" servos should work fine too. Be careful with the servo cable pin-out. The board uses Signal Vcc GND which is the usual pin-out for Hitec and Graupner. If necessary, take out the servo cable pins by first lifting the 'clips' with a knife, then plug them back in the rearranged order.

Rangefinder: the board supplies +5V to the SRF04 rangefinder, and uses SRF04 pin-out for the trigger and echo signals. Other rangefinder modules e.g. SRF08 probably can not be used.

Power: the board should be supplied with 12V. It generates a linear regulated +5V for the logic and an adjustable higher efficiency switched mode >=+5V 3A supply for the six servos. You can take the 12V input supply from e.g. your PC. 4-pin PC power connector: black=GND, yellow=+12V, red=+5V. If you omit the LM2576 switch mode supply, you can also connect the PC +5V to the C10 capacitor for supplying the servos. Note that you must always shut down the PC before plugging in the board, otherwise hard disks etc will be hard-reset because of the power draw spike caused by the controller board capacitors. If the full 6 servos are connected, check from the servo specs that the current draw during stalling (worst case) of all 6 servos together does not exceed 3A.

Software - for ATMEGA8 and Windows

The ATMEGA8 source code as a AVR Studio 4 project atmega8-servo.aps and atmega8-servo.c. The code is based on the original servomaster written by Stefan May. A test version of a rewrite with SRF04 support can be found in devel, it is a work in progress and not yet guaranteed to work entirely.

Some comments from the ATMEGA8 source code, e.g. what is needed to compile it:

// Requirements:
//   ATMEGA8 and board in atmega8servo.brd Eagle PCB
//   WinAVR GCC   : WinAVR-20070525-install.exe
//   PonyProg     : ponyprogV207a.zip
//   AVR Studio 4 : aStudio4b528.exe
//   Parallel port programmer :
//      LPT 2->12 (direct wire), 3->11 (direct wire),
//      LPT 10->100ohm->MISO, 9->100ohm->RESET
//      LPT 7->100ohm->MOSI, 6->100ohm->SCK
//      Avr ISP I/O selected in PonyProg interface setup
//   SRF04 ultrasonic rangefinder
//   I2C interface e.g. http://www.robot-electronics.co.uk/htm/usb_i2c_tech.htm
Precompiled Intel Hex and ELF files can be found in binaries. Use PonyProg to set ATMEGA8 clock flags in the fuse bits to 8 MHZ internal RC (CKSEL3..0: 0100) and slow startup (SUT1..0: 10) (see config bits PonyProg screenshot).

Source code status: the servo control is working nicely over I2C (will write improved timing code later...). However SRF04 and ADC support is still missing.

A nice parallel port programmer that can be used together with PonyProg (set config for "Avr ISP I/O") to flash the ATMEGA8 is below. The schematic I copied from somewhere else on the net ;)

A simple Windows controller test program that accesses I2C via the Robot Electronics I2C-USB module is found under usb-i2c-testprog, together with .exe and VisualBasic 6 source code.

(C) 2007 Jan Wagner