Close
0%
0%

Mocoder - Magnetic Encoder

Build your own continuous servo, with an RC servo and a Mocoder Magnetic Encoder

Similar projects worth following
Mocoder is a magnetic encoder that rotates continuously, while giving positional feedback throughout the rotation. Use it as a drop-in replacement for many potentiometers. In particular, it replaces the pots inside RC servos, turning them into robot servos.

Mocoder is based around the AS5600 12-bit magnetic encoder. A magnetic spindle rotates freely above the chip. All the parts are held together within a plastic housing.

Below you'll find instructions for making a robot servo out of a Mocoder, as well as a few example applications.

Mocoder is currently available for purchase on Tindie.

Mocoder overview

Mocoder is a small breakout board for the AS5600 magnetic encoder IC, along with an enclosure and a magnetic spindle, so it is a complete magnetic encoder. You can read the position of the encoder out over i2c, or simply as an analog signal from an ADC. Additional features are also available over i2c, and AMS have provided an Arduino library for i2c interfacing:

http://ams.com/eng/Support/Demoboards/Magnetic-Position-Sensors/Angle-Position-On-Axis/AS5600-POTUINO

I'd also recommend checking out the datasheet for the AS5600:

http://ams.com/eng/Products/Magnetic-Position-Sensors/Angle-Position-On-Axis/AS5600

Here's a video of mocoder being read from an Arduino over i2c.

Schematic

Layout

Legend

Some things to note.

  1. The 2 pin jumper allows you to select between 5 Volt (default) and 3.3 Volt operation. For the latter solder the jumper closed, and then supply 3.3 Volts to the pin labeled 3. For 5 Volts, leave the jumper open and supply 5V to the pin labeled 5.
  2. There are already 4.7k pullups on the i2c lines.
  3. The 3 pin jumper allows you to select between incrementing or decrementing values as the magnet spins in a particular direction. To change it, sever the existing trace between the center pad and the CW pad, and solder between the center and CCW pad.
  4. There's a footprint for an 8 pin FFC connector on the board. It is unpopulated by default, however this part is known to fit if you want to add it yourself.
  5. The FFC footprint has two Not Connected mounting pads. It is okay if these come in contact with the provided pin header or your own wires.

Soup up your Servo with Mocoder

You can replace the pot in your RC servo motor with Mocoder to allow it to turn continuously and have position tracking. You read the position of the encoder from a microcontroller and move the continuous servo until it arrives at the desired destination. The microcontroller also allows you to add some intermediary intelligence. For example, you can move the motor with your hands and sample the position. Then play back these positions. Check out some examples in the following videos.

Example 1: Programming a robot by hand

Example 2: Robot servo in a gearbox - (some overlap with previous video)

Example 3: Robot servo controlling a linear slider track


Mocoder has been tested and is known to fit and work with the following servos:

  • 1
    Step 1

    Assemble the Mocoder (and disassemble again).

    Unpack the bits.

    Line up the registration points on the plastic housing with the drillouts on the PCB. Place the PCB under the one wing.

    Push down on the PCB and pull out on the other wing...the PCB will snap firmly into place.

    The assembled Mocoder:

    If you want to use the encoder in something other than a servo, you can now either solder leads to it as in Step 2, or solder the included 8 pin SMT header. This method uses the i2c interface, and AMS have been kind enough to provide an Arduino library that provides an API to all of the available functions.

    http://ams.com/eng/Support/Demoboards/Magnetic-Position-Sensors/Angle-Position-On-Axis/AS5600-POTUINO

    Alternatively, for reading the position simply as an Analog Output from an ADC, you can just hook up power and ground, and read from the OUT pin (labeled O).

    Now that you know how to assemble the Mocoder, you may want to disassemble it and reassemble it after you solder connections and fit it into your project.

  • 2
    Step 2

    Solder leads to the circuit.

    Solder leads to G (ground), 5 (5 Volts), D (SDA), C (SCL). Length depends on application, but a foot is good place to start.

    If they are stiff wires, then bend them up away from the board.

  • 3
    Step 3

    Open case and remove stop pin from gears.

    Unscrew and remove the backside of the servo case

    Remove the top of the case. Be careful not to drop the gears, as they are no longer held in place.

    Remove the stopper pin from the pinion gear. Try using wire snippers to grip the sides, and using the tip of the snippers as a lever.

    Replace the top cap over the gears, and tape it down while modifying the rest of the servo.

View all 10 instructions

Enjoy this project?

Share

Discussions

Robert Brown wrote 04/07/2020 at 02:14 point

Hi

I decided to try your project and ordered a sensor. But I have found your link to the arduino library does not work. Can you provide the library locally or a new link? The senor is pretty much useless if I cannot find a library.

  Are you sure? yes | no

ekaggrat singh kalsi wrote 03/11/2020 at 10:13 point

is it possible to use two encoders on the same arduino? how do you set the i2c address?

great work though!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates