>
> Maybe I am being stupid, but I've been banging my head against a problem for
> a bit and I just haven't seen any light....
>
> Given:
>
> Two digital inputs (A and B), each of which carries a square wave signal.
> This signals will be very close to 50% duty cycle. Their frequency varies
> (rather slowly) over a range of at most 3:1 (ie: if the lowest frequency is
> 40 Hz, the highest is 120 Hz).
>
> I need to compute a value that represents the phase angle between the two
> signals. I want a value of 0 to represent 0 degrees difference, 0x4000 for
> 90 degrees, 0x8000 for 180 degrees difference and 0xC000 for 270 degrees.
>
> 1: When A and B are at the same frequency the output value should be very
> stable.
>
> 2: When A and B are near the same frequency (within about 5 Hz) the output
> value should change smoothly to represent the phase difference changing.
>
> 3: It is ok to 'give up' if the frequency of A and B differ by too much. In
> this case an 'error' output will be set.
>
> 4: At no time should the output value 'jump' other than to reflect, as
> accurately as possible, the changing phase relationship of the two signals.
>
> Assume a 20Mhz midrange PIC with 2 CCPs is available, if that helps.
>
> Bob Ammerman
> RAm Systems
> (contract development of high performance, high function, low-level
> software)
>
> --
>
http://www.piclist.com hint: The list server can filter out subtopics
> (like ads or off topics) for you. See
http://www.piclist.com/#topics