Hack your servo v3.00 - Get full PID position and speed control from your hobby servo
Yes we like servo mods!
As promished this is the third servo hack. This builts upon the second hack - 'add 10-bit abolute/incremental feedback encoder to your hobby servo' - node/18470. Source code is open and links provided at the end of the post. Schematics are also provided. In terms of the board files... well dont be lazy! After all all three boards are two-sided and fairly easy to design once you have a look at the schematics (and the main pic:). A somewhat similar post is also found in the Components page, but here I explain more or less how you would make it yourself, the components needed, some well-thought tips and how to install it inside your servo.
So lets make a start, shall we?
To do this you need 3 basic components:
Each of these should go into a separate board and all three should stack together using low profile pin headers/sockets. The target board outline is 15.5x15.5mm - a good design exercise :) This will make it fit inside any standard size servo. If you cannot get it that small try the 1/4 scale instead. The target board outline for this is 25x32mm with plenty of height space.
When designing the magnetic encoder board bear in mind that the centre of the servo's output shaft for standard servos should be located 10mm from servo casing (15mm for 1/4-scale servos). The magnetic encoder ICs have an allignment tolerance of +/- 0.5 mm so they are pretty forgiving in terms of misallignment.
The ATMega328P board should stack directly under the magnetic encoder. It is the same processor Arduino uses. Remember to keep the programming pins near the board edge for easy access. The pins needed to get feedback from the encoder and control the motor driver should come out on the sides of the board such that all three boards can be stacked together. The remaining pins should be exposed using pads so you can solder wires and use them if your application needs them. You should have 4 digital IOs and 4 analog inputs available for other stuff. If you go for an RS485 transciever this should go at the bottom of the board. Basically you get full Arduino functionality but 4MHz faster clock and half the footprint of Arduino nano :))
The motor driver board should be on the bottom of the board assembly. Keep the bottom layer free of components with a large copper plane and use thermal vias to direct heat away from the board. Keep it free of components so you can add heatsinking if so required. Normally you should ok without, but if you go for high-performance coreless servos heatsinking becomes a must.
When everything is ready (.....) you can install the boards inside your servo. To do that first you have to connect the magnet to the servo's output shaft. I will repeat the necessary part of the procedure of my previous post (node/18470) just to avoid any confusion.
- Start by accessing the servo’s bottom compartment and by removing the control / power electronics from the servo. Unsolder the motor’s leads and proceed by removing the feedback potentiometer.
Next you need to flash the Atmel. Check Google Code page(s) below for the source code and programming guide for AVRStudio, MS Visual Studio Xpress and Eclipse. The AVR library page is a must. Currently supporting only ATMega MCUs but soon to be expanded.
Following the procedure above you need to make a hard decision: I2C, RS232 or RS485?? With I2C and RS485 you can daisy chain many controllers together. Solder the appropriate cables in place together with the motor-leads' cables and the power-cables.
At this point you should be able to drop the boards assembly inside, locate it in place using heat-glue or thermal foam and start playing :))
For the Eagle schematics go to:
http://www.01mech.com/supermodified > scroll down the page & right click on the link > Save as...
I am still waiting on my boards to arrive. Will update the post accordingly then.