Skip to content
Snippets Groups Projects
Select Git revision
  • 33d33be1101cbb9f2a3c9202369d5058088916b9
  • master default
2 results

README.md

Blame
  • README.md 14.82 KiB

    MachineKit Encoder

    Motivation

    I want an encoder! Encoders1 read position, generally by counting 'ticks' on some reference. For example, an Optical Encoder uses a reference with openings that allow light to pass, and count whenever a photodiode goes high or low to indicate that some motion has occurred.

    encoder-basically

    Then, you add the ticks together to get your position. In order to detect direction, a technique called 'quadrature' is used:

    quadrature-basically

    Super simple, very neat. Here's picture of a fancy encoder:

    encoder-fancy

    You'll notice this encoder has two other reference markings - those are super interesting as well, and encode absolute position into the ring - there is only one uniqe combination of holes-or-not-holes on those rings for every single indicated position. This is good news because then your joint / axis does not have to touchoff on a known reference point - aka a 'home' or 'limit' switch - before it starts counting. If this looks expensive, it's because it is. An encoder like this might run ~ $300, and they're super sensitive to dust, misalignment etc. That's no bueno.

    So my goal here is develop an encoder that I can put on whatever-I-want without spending too much money, and without fussing too much about setup. Critically, I also want to un-constrain myself from particular sizes - whenever I have to source a particular size ring or strip (for reference) I end up boxed-in in terms of the *~ design spaces ~* I can get into. I don't like that.

    Solution?

    So I'm going to try rolling2 a magnetic encoder3 with a custom array of magnets. This way I can roll a ring or line of magnets into whatever structure I want, and hover one of these encoders above it to read position.

    The chip I'm going to use is an AS5304 - a product offered by AMS that does all of the hard work on the hall-array end for me. I can read quadrature output from this ('ABI' interface - 'I' being an Index Pulse)

    So, in summary, I am basically just building a big ring magnet, and trying to read that with the AS5304.

    Problems

    I am using an AS5304 (4mm poles) or an AS5406 (2.4mm poles). Each has 160 positions per magnetic period. This translates to a resolution of 25um and 15um steps, respectively. If I wrap this around some diameter D I have that

    angular resolution = 360 / (((PI x D)/pole_length) x 160)

    Of course, I have to set the circumference equal to an integer value of magnets. I wrote a quick spreadsheet for this, and get that w/ a Diameter ~ 100mm (where the gearbox currently stands) I can get 0.017 deg/step with a 2.4mm pole pair, and ~ 0.03 deg/step with a 4mm pole spacing. Nice.

    rough spreadsheet

    Now, this is not so straightforward. The important thing to remember is that Resolution != Accuracy - while I have ~ 0.03 deg / step, those steps are not exactly mapped perfectly in a circle. I will actually be referencing magnets that are glued in place - so my glueing and magnet placement would have to be perfect4 for Resolution to = Accuracy. In addition, not all magnetic fields will be identical, etc.

    In addition to these mappings between poles, I will have some deviation, I'm sure, within the poles. As in, the magnets will likely have small gaps (finding a magnet which is perfectly 2mm across... not likely) and so I expect readings to deviate in a kind of sine-wave around actual position... one period of the wave corresponding to one period of the poles.

    This can be overcome in implementation by mapping in memory a lookup table, with respect to some 'home' position, of how measured ticks of the encoder match up with reference positions. For example, I would rotate the encoder to known positions (with some other, higher precision system) and map readings -> known values.

    This is not ideal! And it requires a deal of labor, some good routines and memory-storage games, and a reference point.

    In this exercise (which I am trying to keep bounded)5 I will try only to measure this deviation-from-perfection. Or, at least, deviation from some other, better positioning system.

    At best, I hope to cancel periodic deviation (i.e. map the sine-wave between individual poles into a more linear interpolation. my encoders have an Index pulse (on every top-of-pole) that I can use as a reference point for this.

    Design

    Without further ado, here's a sketch of how I plan to build the encoder:

    layout test

    And then, a system to put that encoder in set positions, while measuring...

    • while pole pairs are 4.0mm apart, poles are 2mm long - magnets are 2mm across.