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.
- 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.
- Flat file
- Sanding paper or abrasive disk.
- 5min epoxy.
- Hand-drill or press-drill.
- Drill bits: 3.5mm and 5mm in diameter
Step 1: Gutting the Servo
- 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.
Step 2: Preparing the Magnet
- 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.
Step 3: Preparing the Sensor Board
- 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.
Step 4: Assembly
- 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: