This encoder is based on the Haddington Dynamic Analog / Digital Hybrid encoders used on the Dexter robot arm:
https://github.com/HaddingtonDynamics/Dexter/wiki/Encoders many of the goals of this project won't make sense without understanding it.
There are some changes:
- Laser cut: To avoid the need for correction in the FPGA, laser cut parts or PCBs vs 3D printing.
- Simple Electronics: NO FPGA! Just a Pi Pico (Arduino code, Uno is slower) PWM out through 15k resistors to 220uF gnd filter caps to LTE-4206 940nm IR emitters. ADC inputs from 1M trim pots (Bourn 3386 105) divider to ground with center tap to LTR-4206E to +3.3V rail.
- The analog reading is an "absolute" position in a slot. With Single Track Grey Codes we can find the slot
If you hold up a card with a square cut into it in front of a wall before the setting sun, you get a square-shaped shadow on the wall. Now if you move the card away from the wall you might expect to get a fuzzy square, but what you actually get is a circle. The sun projects, its shape, a circle, through anything which is relatively small, held a distance from the backdrop. You can see that same circular shadow with a triangle or a rectangle or any other shape. There's a great Veritasium video about this.
But only if it's held a little distance from the wall. If you want a precise mask that is not fuzzy you have to hold it right against the wall.
We want to pass a square-ish slot over a mask and get a sine wave. If the mask is a square, what we get is actually more like a triangle. If the mask is a circle we get something closer to a sine. But the actual correct shape to produce a sine wave when passing a rectangular slot over the mask, is the shape of a human eye.
We are combining the sine and cosine waves to form a circle, plotting the cosine on the x-axis and the sine on the y-axis, then drawing a line from the current point on that plot to the center, and taking the angle of that line to calculate the motion from one-sided slot to the other. If the length of that line varies, the advancement of the angle will not be consistent. We need the plot to be as circular as possible to maintain that constant distance. And that means using the correct mask to produce a sine, and cosine, wave.
Yes, yes, the CAD I'm using is :cough: Javascript. OpenJSCAD is like OpenSCAD but with a good language. Added code to make the disks (will generate STLs for printing or DXF for cutting, and I can make it do SVG as well if needed). I probably want to move the STGC track to reflective rather than trasmissive. We need the transmissive (slots) for the analog reading because it increases the bandwidth. But the STGC reading is just on / off, not analog, so reflective should work, and avoids the need to have a light source on one side and a sensor on the other.