chucktodd:

what is the voltage range of the sin wave 0…5v? IF so then an equation that replicates this would be

v=sin(angle)*2.5+2.5

sin(angle)=(v-2.5)/2.5

angle = asin((v-2.5)/2.5)

So angle is between -pi/2 and pi/2 the only way to identify quadrant 2 or quadrant 3 values is by inspection. if you know the sine wave is flowing 0, pi/2, pi, 3pi/2, 2pi you could compare current value of angle to prior value. If prior value was in quadrant 1, and angle was decreasing then angle = pi -angle.

if prior value was in quadrant 2 and and angle < 0 then angle = pi - angle. if

```
#include <Math.h>
```

static double prior=0;

/* this function only works if called with voltage values faster than f*4 */

double getPhaseAngle( double voltage){ // 0… 2pi

double angle=asin((voltage-2.5)/2.5);

if(angle>0){

if(angle>=prior){// still quadrant 1

raw=angle;

quadrant = 1;

prior=angle;

}

else { // quadrant 2

raw=angle;

quadrant = 2;

prior=angle;

angle = pi - angle;

}

}

else {

if(angle<=prior) { //

raw=angle;

quadrant = 3;

prior = angle;

angle = pi - angle; // minus a negative equals a plus

}

else {// moving through quadrant 4

raw=angle;

quadrant = 4;

prior = angle;

angle = 2*pi + angle;

}

}

return angle;

}

```
chuck.
```

Yes, i Sum 2.5V DC because arduino don’t read negative values.

Sorry , my doubts but, i don’t understand , i want to read a sinusoidal wave, and know like this:

For example:

Read : 2 0.000001 s

Read: 3 0.000002 s

. . . .

. …

I want to know the time that arduino read value, because arduino do it automatically.