CurematicCaliper icon indicating copy to clipboard operation
CurematicCaliper copied to clipboard

nice! some ideas on 3 phases

Open jschoch opened this issue 2 years ago • 0 comments

thanks for sharing this.

I tried to do this a few years ago and when I saw your version I tried again, so thanks very much!

My first board used 2 RR111 sensors (very sensitive) and while it worked it had a few issues. I found this paper:

"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4634446/"

it describes using 3 sensors 120 degrees apart and then deriving sin/cos for atan2. This works very nicely.

a quick demonstration you can run on replit.com/languages/c

#include <stdio.h>
#include <math.h>


int main() {
	const double sqT = sqrt(3);
       // square root of 2/3
	const double sqTH = 0.81649658092772603273242802490196;
        double pole_pitch = 2;

        // sensor reading 1 phase 0 degrees
	double a = .5;
       // sensor reading 2 phase 120 degrees
	double b = -1;
       // sensor reading 3 phase 240 degrees
	double c = .5;
        printf("consts: sqT %lf  %lf\n ",sqT,sqTH);
        // create virtual sine
	double v1 = sqTH * (a - (b/2) - (c/2));
        // create virtual cosine
	double v2 = sqTH * ( ((sqT*b)/2)- ((sqT*c)/2)) ;
        // atan2 as normal
	printf("v1: %lf v2 %lf \n",v1,v2);
	double ang = atan2(v1,v2) + M_PI;
        // get distance as a function of the pole pitch and the 0..(2*pi) output of atan2.  I add pi to shift from -PI..PI to 0..2_PI 
        //  so the distance is more clear from pole to pole.
	double dist = pole_pitch/(M_PI*2) * ang;

	printf("angle: %lf distance %lf",ang);
    return 0;
}

i'm still trying to understand your error correction, this seems to do quite a lot on it's own though.

jschoch avatar Aug 13 '21 23:08 jschoch