DSPRelated.com
Forums

convert sum of two sines to square wave?

Started by Funky February 16, 2004
Paul Russell wrote:

> Funky wrote: > >> >> But how do I use this to get the same output as multiplying the sum by >> infinity and clipping? >> Yes, I'm being stupid here. >> Funky >> > > The output only has 2 states: +1 and -1. > > (Actually there is probably at least one pathological condition where > the output will always be zero, but I leave this kind of detail as an > exercise for the reader.) > > Paul
The state switches when the magnitudes of one becomes larger than the other and they have opposite signs. How is that time determined? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Jerry Avins wrote:
> > The state switches when the magnitudes of one becomes larger than the > other and they have opposite signs. How is that time determined? >
Good point - I /thought/ I had this covered but maybe I need to try a simple implementation and see if it actually works before shooting my mouth off further. Paul
Jerry Avins wrote:
> > > The state switches when the magnitudes of one becomes larger than the > other and they have opposite signs. How is that time determined? >
OK - I missed out a step - sorry. We need to use the identity: sin(A) + sin(B) = 2 * sin((A + B) / 2) * cos((A - B) / 2) All we care about is the sign of the result, so we use the periods and initial phases of the (A + B) / 2 and (A - B) / 2 terms from which we can predict their signs based on zero crossings. The sign of the output is then just the product of these two individual signs. The pseudo code I posted earlier is still more or less correct, but the periods and phases come from the identity above, not the original sine wave periods and phases. Paul
"Paul Russell" <prussell@sonic.net> wrote in message
news:cowYb.1882$_3.30739@typhoon.sonic.net...
> Funky wrote: > > > > > Yes. I still think you need to exploit the trig identity that sum of
sines
> > equals product of sin and cos, unless you're thinking of another way. > > I don't think so. Given the intial phases and the periods all you need > is a simple state machine. (As others have noted, it gets more > complicated if the amplitudes of the two sine waves are different, but > apparently that is not the case in this instance.) > > Paul
He he he. Don't we sometimes wish we could turn back the clock;) Funky
Funky wrote:
> > > He he he. Don't we sometimes wish we could turn back the clock;) > Funky > >
Nope - read the whole thread. Paul