PDA

View Full Version : [Interesting] Hack your servo v2.00 – Add 10-bit incremental / absolute encoder feedback to your hobby servo.



Antonb
02-24-2010, 06:49 AM
Modified continuous-rotation servos are used extensively by roboticists due to their small form-factor, enclosed motor-gearbox, ease of mounting and high-availability. Some users keep the original drive electronics and the potentiometer feedback element but this approach allows for limited position control and velocity control / profiling. Others tend to remove them and use external control/drive boards and custom-made encoders. Ideally one would prefer to have the feedback element and the new drive electronics enclosed inside the servo. Unfortunately hacks involving optical devices and code-wheels have very limited resolution and require a lot of precise work.

Magnetic encoders use spinning current Hall technology to measure magnetic flux distribution across the surface of the chip. They typically come in high resolutions and require very few external components. The operational setup requires a small disk magnet with circumferential field distribution to be attached on the rotating element whose angular deflection is to be measured, and in close proximity to the sensor IC.

This hack utilises Austrian Microsystems’ sensor IC as feedback element for a modified servo. The servo to be hacked is the popular Hitec HS485 HB.


http://www.01mech.com/sites/default/files/images/MagEnc.wt.Magnet.jpg


Materials list:
- Standard-size or ¼ scale hobby servo.
- AS5040 IC
- Circular Magnet with circumferential field distribution, 2.5mm high, 6mm in diameter.
- IC breakout board (download schematics from here: http://01mech.com/magenc)
- Styrene plate 2mm thick.
- Small piece of wood 10mm thick.
- Multi-strand cables.
- Heat-shrink


Tools list:
- Flat file
- Sanding paper or abrasive disk.
- 5min epoxy.
- Hand-drill or press-drill.
- Drill bits: 3.5mm and 5mm in diameter
- Heat-gun


Procedure:

- Start by removing the control / power electronics from the servo.

- Remove the feedback potentiometer.

- If continuous rotation is required remove the mechanical stop from the servo’s output gear.

- Disassemble the potentiometer keeping the rotation shaft. This is going to be used as a support shaft for the encoder’s disk magnet. The magnet is going to be glued onto it.


http://www.01mech.com/sites/default/files/images/MagEnc1.jpg


- 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.

- 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. Carefully centre the magnet on the shaft and leave to settle for at least 6 hours (for a 5min epoxy).

- Insert the pot’s shaft in 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.


http://www.01mech.com/sites/default/files/images/MagEnc2.jpg


- Take the styrene adaptor plate and ensure that it can be placed inside the servo’s casing. Use a scalpel and a small file / sanding paper to trim as necessary.

- Take the encoder board (the schematics for the AS5040 breakout board are downloadable from here: http://01mech.com/magenc) and solder the power and sensor output signal cables. I will be using the Pulse Width Modulated output since it gives a clear indication of the absolute position of the servo’s output shaft.

- There are 5 pins exposed on the encoder breakout board. 5volts, GND as well as, ChA, ChB - used for quadrature inputs and a Pulse Width Modulated output, having its width modulated according to the position of the magnet around the 360-degree obtainable range. Even though the AS5040 offers additional functionality (like: Step/Direction/Index, 3-phase commutation, and Synchronous Serial Interface) these are not used here as an effort to keep the board’s dimensions down and fit it in the servo’s tiny available space.

- Take the encoder board and the adaptor plate and bring them together making sure the IC and the slot on the encoder board align with the corresponding holes on the styrene adaptor plate. Use a glue-gun and secure the board to the adaptor plate by depositing glue laterally to the slot of the encoder board.

- Drill a 5mm diameter hole on the servo casing, 10mm directly above the original cable exit hole.

- Use heat-shrink if so desired, to cover the cables and pass them through the 5mm diameter hole.


http://www.01mech.com/sites/default/files/images/MagEnc3.jpg


- Insert the styrene adaptor plate and the encoder board into the servo according to the diagram. Insert the locating screw and secure the assembly by placing a drop of heat-glue directly opposite to the locking screw.


http://www.01mech.com/sites/default/files/images/MagEncAssemblyLabels.jpg


- After the board is secured inside the servo pull the excess cable out of the servo and once its length is appropriate (allow a small extra cable length inside the servo) use your heat-gun and secure the cable on the servo’s casing at the point it exits through the 5mm hole. Assemble the servo and enjoy servo position feedback with 0.35° resolution ;)


The Magnetic Encoder in action:


http://www.youtube.com/watch?v=-z0Giro4R7M


For a PDF version of this tutorial visit:
http://www.01mech.com/open-engineering

For Austrian Microsystems’ AS5040 datasheet visit:
http://www.austriamicrosystems.com/eng/Products/Magnetic-Encoders/Rotary-Encoders/AS5040

billyzelsnack
02-24-2010, 09:15 AM
Very very nice.

Orac
02-24-2010, 12:45 PM
Would I be right in saying that the servo's electronics are discarded and the red and black wires go to the original motor?

Thanks

jes1510
02-24-2010, 01:29 PM
Nice writeup! + reppage from me. Do you have a source for the board and magnet?

zoomkat
02-24-2010, 06:15 PM
Would I be right in saying that the servo's electronics are discarded and the red and black wires go to the original motor?
I think that would be a waste. I'd replace the origional pot with two 2.5k ohm resistors (better yet a 15 turn trim pot) so I would have variable speed bi-directional gearhead motor.

Antonb
02-25-2010, 03:45 AM
I think that would be a waste. I'd replace the origional pot with two 2.5k ohm resistors (better yet a 15 turn trim pot) so I would have variable speed bi-directional gearhead motor.

I have a better idea:happy:

I am currently preparing a second generation board that will have the H-bridge and an ATMEGA168, all inside the servo http://www.societyofrobots.com/robotforum/Smileys/default/wink.gif. I will also release assembly instructions, code for PID control and schematics. The first generation boards have already been sold out.

Check my google code page: http://code.google.com/p/zosupermodified/

I will be constantly adding stuff so keep posted

PS. You can have bi-directional control but unfortunately you cannot get speed control from the original servo electronics:veryhappy:

zoomkat
02-25-2010, 06:26 PM
"PS. You can have bi-directional control but unfortunately you cannot get speed control from the original servo electronics:veryhappy: "

Well, I've got a Tower Hobbies TS-53 modified for continous rotation and I have speed control in both directions. I also have a hitec HS-422 that seems to exhibit the same characteristics. With the TS-53 pot set to be stopped with an ssc-32 sending a 1500 control signal, I can vary the signal higher and lower to increase and decrease the rotation speed. Full rotation speeds are attained at ~1400 and ~1600.

Quantum
02-25-2010, 10:57 PM
Cool project and the addition of the ATMEGA168 theres you speed or ramping function. Plus lots more.

The addition of a better pot wont work as well as you think. Since the on board electronics are programmed for the given values of the "factory" pot. The rotary encoder already gives an output via pwm propotional to the angle. Alot more accurate than the SSC-32. No feedback.

Im sorry your SCC-32 dosent do this at all. Never will.

And what you think are speed functions are standard with any PWM servo and the controller board your using. The SCC-32 is a little slow since it cant control it's self with out the help of another controller.

Like the Atom chip that is usually used.

But at the cost of being more expensive. If you have the bot and want to up grade your servos. This is cool.

zoomkat
02-25-2010, 11:13 PM
The addition of a better pot wont work as well as you think. Since the on board electronics...
Swooooosh! :wink:

Quantum
02-25-2010, 11:22 PM
I dont see your point this is a prototype and a 168 is going on that board. Big difference.

zoomkat
02-26-2010, 01:28 AM
I dont see your point this is a prototype and a 168 is going on that board. Big difference.
The point is that you *can* get servo speed control using the origional servo electronics. Others may not want to go to the trouble and spend the $$$ to reinvent the wheel with a 168. Using the ssc-32, my servo rotation can be slowed down to ~45 sec. for one rotation in one direction and ~65 sec. in the other. This control may be enough for most to make good use of the encoder.

Antonb
02-26-2010, 10:57 AM
Nice writeup! + reppage from me. Do you have a source for the board and magnet?

Check: www.01mech.com/magenc