Ho to detect phase shift in 2 square waves ?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi all...

I have 2 square waves that are out of phase by 90 degrees. I want to be able
to tell when the first wave shifts from "leading"  to "lagging". The second
wave will do the opposite. I'm trying to do this in software. I have some
ideas on how to do it with interrupts but  I'd like to explore other
possibilities. So, if someone can suggest where to dig out info on the
subject. It would be great. BTW the frequency of the waves varies between 0
and about 1000Hz.

Thanks in advance



Re: Ho to detect phase shift in 2 square waves ?
oN 29-Jan-04, Rodo said:

Quoted text here. Click to load it

Input one wave to the D input of a flop, and the other to the clock. As =
long as the waves are always the same frequency, the output state will =
tell you which leads and which lags. Of course, given two input pins and =
an interrupt, you could do it in software, as well.

--
Bill
Posted with XanaNews Version 1.16.1.4

Re: Ho to detect phase shift in 2 square waves ?

Quoted text here. Click to load it

  First thing is to decide just how quickly you need to make that
decision. If it needs to be on the first available edge, then you will
need to respond to all 4 edges in interrupts, or poll fast enough to
catch the change at MAX freq.
  If you can wait a cycle, then the SW can be simpler, as it becomes
a UP/DN counter problem -> just sample the level of one phase, on
a given edge of the other.
  Look for Quadrature Encoder / Qudarature Decoder info.

-jg


Re: Ho to detect phase shift in 2 square waves ?

Quoted text here. Click to load it

On the rising edge of one of the inputs, sample the state of the other
input.  If it high, then the second input leads.  If it is low, then
the first input leads.


-Robert Scott
 Ypsilanti, Michigan
(Reply through this forum, not by direct e-mail to me, as automatic reply
address is fake.)

Re: Ho to detect phase shift in 2 square waves ?
Quoted text here. Click to load it

Reading a rotary encoder? :)


Re: Ho to detect phase shift in 2 square waves ?
On Fri, 30 Jan 2004 05:00:49 GMT, the renowned "Rodo"

Quoted text here. Click to load it

If you have the bandwidth on your processor, you could sample it at a
few kHz and determine the up/down edge (or illegal state change) from
the delta from the previous snapshot of the two encoder outputs.
Obviously, there are 4 possiblities.

If you use interrupts directly, the loading on your processor varies
with the frequency, which may make debugging and bulletproofing your
code more challenging. If the frequency goes to high with polled
inputs you start to miss counts. The other way, you could conceivably
have more serious problems.  


Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
snipped-for-privacy@interlog.com             Info for manufacturers: http://www.trexon.com
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline