Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nice! some ideas on 3 phases #1

Open
jschoch opened this issue Aug 13, 2021 · 0 comments
Open

nice! some ideas on 3 phases #1

jschoch opened this issue Aug 13, 2021 · 0 comments

Comments

@jschoch
Copy link

jschoch commented Aug 13, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant