Let's Make Robots!

Hack your servo v3.00 - Get full PID position and speed control from your hobby servo

Modify your rc-servo into a computer controlled fully funtional servomotor with 12-bit absolute feedback (4096 positions - 0.08 degrees resolution)

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:

  1. Magnetic encoder IC and a circumferential field distribution magnet. The AS5040 gives you 10-bit resolution, the AS5145 12-bit resolution (4096 positions / 360 degrees) and an SPI interface which always comes handy. The two ICs are pin-to-pin compatible. Get these directly from Austrian Microsystems - ask for a sample, they normally ship the next day.
  2. An ATMega 328P (MFL package) an on-board regulator and a 20MHz crystal (to get the control loop closing at 1KHz)
  3. A Freescale motor driver IC (MC33887) which can deliver up to 5 Amps continuous. If you need something smaller try the MCP17511 (1 Amp cont.)

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.

- If continuous rotation is required, access the servo’s top compartment where the gearbox is located and remove the mechanical stop from the output gear. Take extra care not to damage the gear’s teeth as well as, keeping any foreign particles from entering the gearbox assembly. Particles residing on any of the gears’ teeth will cause undesirable noise during operation and may also affect the performance of your servo.



- Next disassemble the potentiometer keeping the rotation shaft. Remove the potentiometer slider from the shaft. What remains is going to be used as a support shaft for the encoder’s disk magnet. The magnet is going to be glued onto it.

- Carefully flatten the potentiometer’s base using sandpaper or an abrasive disk. 

- Roughen the side of the disk magnet to be glued onto the potentiometer’s shaft by using sandpaper. This step is essential and will ensure a strong assembly.
- Take a small piece of wood, 10mm thick and drill a blind 3.5mm diameter hole approximately 5mm deep. This is going to hold the potentiometer’s shaft and the disk magnet vertically while the epoxy settles. 

- Prepare a small epoxy mix, insert the pot’s shaft to the hole and place the disk magnet on the pot’s shaft with a small drop of epoxy between them. Remove any excess epoxy. Ideally you should aim to leave a small ring of epoxy around the circumference of your magnet for lateral support. Remember that your servo has an output speed of about 60 rpm but the system that the servo is going to be installed will most likely be subjected to other sources of vibration. Accurately centre the magnet on the shaft and leave to settle for at least 6 hours (for a 5min epoxy). I know that by now you cannot wait to start using the servo on your project but you must show patience if you do not want to repeat this step in the near future.

- Insert the pot’s shaft back into the servo’s output gear. Make sure the flatten area of the shaft goes fully into the corresponding ‘pocket’ of the servo’s output gear like it did before the modification.

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.

http://code.google.com/p/zoavrlib/

http://code.google.com/p/zosupermodified/

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Do anyone know where i can find someone who makes these boards cause they are very small for me to make them.

www.01mech.com is off as is see. Is there something similar?

Im also interested in buying two of those assembled babies. So if anyone knows where to buy it, drop me a message.

Really like to get my hands on those Eagle schematics, but link is broken.

Anders

I'm not sure if i can post links here so:

search google for "supermodified jandetlefsen github" for schematics (while opening board file in eagle 6.10 i get bunch of warnings and some elements are displaced - it has problems with parsing file)

and

search google for "zosupermodified code.google.com" for official 01 Mechatronics Open Engineering SuperModified source code. For V2 go Source->Browse->Trunk. There is no datasheet for V1.

Not exactly rocket science but you got it! :))

I read both tutorials. Great job, this is something I wanted to do years ago but with Hamamatsu IR encoders, a Tiny85 and a FAN8082 bridge. Your method is far better. But I have a question, where can we get magnets?

Thanks.

Magnets are available from Austrian Microsystems or from 01 Mechatronics (my company)

Alternatively you should be searching for 6mm dia 2.5mm height circumferential field distribution magnets

Can I buy a pair of magnets and a pair of detector boards (no boards with atmega and no boards with motor driver)? I want to make encoders for regular DC motors.

Thanks.

Edit: I found it on your page, it will cost me almost $50 a pair. I'm thinking about it...

Hi there,

If cost is an issue you can always visit: http://www.didel.com/Frames.html?MainFrame=microkit/ they stock some low-res, easy to integrate quadrature incremental encoders that will do the trick (if high accuracy is not a must).

I ought to say though that absolute encoders with such resolution typically come (at least) at 15 times the cost of a single MagEnc (not to mention their enormous form-factor).

After all you can always visit 01mech to get the schematics, design your PCB, etch it, order and solder the components (including the magnetic encoder chip & the magnet (shipping costs 29 euros, encoder chip 12 euros, magnet 1.5 euros)) and easily integrate it to your project.

Hope this helps

http://www.01mech.com/supermodified    

link is broken.could you fix this.