Closed JamesNewton closed 5 years ago
Actually, it turns out that a circle is not the ideal shape. It's much better, but not perfect. The perfect shape is actually sort of an inside out circle, as we found years ago, mid 2019.
var jw = { points: [], color: 'black', type: 'poly' };
for (var i = 0; i < Math.PI * 2; i += Math.PI / 8) {
let x = i >= Math.PI ? Math.PI * 2 - i : i; //over to the right, then back
x /= Math.PI * mask; //scale to the size of the mask
jw.points.push([x, (Math.sin(i) + 1.0001) / 2]);
}
jw.points.push(jw.points[0]); //close the path
The difference is subtle and may not actually matter in operation, but it's been added in https://github.com/JamesNewton/HybridDiskEncoder/commit/6fc47649e3411f9941605c82fe5232267a1f0699
So the point of this is to get a round "eye" or circle when you plot the two sensors as X and Y on a graph. But that requires that the two sensors each put out a sin wave. It turns out that when the mask and slots are both rectangles, the resulting waveform is more of a triangle or a trapezoid, depending on their relative size.
Fig. 1: Rectangle passing over rectangle.
Fig. 1: Rectangle passing over circle.
The question of what shape results when you plot the area of intersection between two shapes out of phase on X and Y graph was interesting so I wrote a program to simulate it: https://stackblitz.com/edit/enc-slot-shape-area (change the code in any way to reload if you get an error about google not being defined). It's a bit of a mess because I started with rectangular shapes only and then added support for polygons to approximate any shape.
It's node.js so here is the package.json file
And the actual program, index.js