Hello Folks, I convert a sine wave to a square wave using a zero crossing detector function, i.e output = 1 if input >0 else output =-1. If I plot the FFT of the resulting square wave, I see lots of tones that are not harmonics of the fundamental frequency of the sine wave. Can anyone explain this. Regards suren
fourier anlysis of square wave...
Started by ●November 29, 2007
Reply by ●November 29, 20072007-11-29
suren wrote:> Hello Folks, > I convert a sine wave to a square wave using a zero crossing detector > function, i.e output = 1 if input >0 else output =-1. > If I plot the FFT of the resulting square wave, I see lots of tones > that are not harmonics of the fundamental frequency of the sine wave. > Can anyone explain this.The non-harmonic tones are aliases. Do you understand about aliasing in sampled signals? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●November 29, 20072007-11-29
Hi Suren, These are aliased harmonics. Say you start with a pure sine wave, which corresponds to a single spike in the frequency domain. When you convert it into a square wave, you generate harmonics that extend to very high frequency- far beyond one-half of the sampling rate. These harmonics therefore become aliased to a lower frequency. Regards, Steve Steve.Smith1@SpectrumSDI.com
Reply by ●November 29, 20072007-11-29
Jerry Avins <jya@ieee.org> wrote in news:TYednZYNrtiqZNPanZ2dnUVZ_s_inZ2d@rcn.net:> The non-harmonic tones are aliases. Do you understand about aliasing in > sampled signals?I would think that the signal is already sampled, so they're not aliases. The FFT of a square wave is a sinc (sin(x pi)/(x pi) in the freq domain, and has many frequency components that are not at harmonics of the sine. This is true for sampled signals and purely digital signals that have never seen a glimmer of our analog world. -- Scott Reverse name to reply
Reply by ●November 29, 20072007-11-29
Scott Seidman <namdiesttocs@mindspring.com> writes:> Jerry Avins <jya@ieee.org> wrote in > news:TYednZYNrtiqZNPanZ2dnUVZ_s_inZ2d@rcn.net: > >> The non-harmonic tones are aliases. Do you understand about aliasing in >> sampled signals? > > I would think that the signal is already sampled, so they're not > aliases.They still could be. If you perform a non-linear operation on a digital signal, you introduce harmonics that can go past the Nyquist frequency, and those get aliased. -- % Randy Yates % "I met someone who looks alot like you, %% Fuquay-Varina, NC % she does the things you do, %%% 919-577-9882 % but she is an IBM." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://www.digitalsignallabs.com
Reply by ●November 29, 20072007-11-29
On Nov 29, 8:47 am, suren <suren.r...@gmail.com> wrote:> Hello Folks, > I convert a sine wave to a square wave using a zero crossing detector > function, i.e output = 1 if input >0 else output =-1. > If I plot the FFT of the resulting square wave, I see lots of tones > that are not harmonics of the fundamental frequency of the sine wave. > Can anyone explain this.Are you doing your FFT using a vector/aperture length that is an exact multiple of the period of your sine wave and thus square wave? If not, you could be looking at rectangular windowing artifacts. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
Reply by ●November 29, 20072007-11-29
Scott Seidman wrote:> Jerry Avins <jya@ieee.org> wrote in > news:TYednZYNrtiqZNPanZ2dnUVZ_s_inZ2d@rcn.net: > >> The non-harmonic tones are aliases. Do you understand about aliasing in >> sampled signals? > > I would think that the signal is already sampled, so they're not aliases. > The FFT of a square wave is a sinc (sin(x pi)/(x pi) in the freq domain, > and has many frequency components that are not at harmonics of the sine. > > This is true for sampled signals and purely digital signals that have never > seen a glimmer of our analog world.A sample train that consists of some number of K's followed by an equal number of -K's (K = any number) and repeated might be called a square wave, but it is not a band-limited representation of a square wave, and so has a Fourier transform that surprises Suren. The Fourier transform of a single continuous pulse is a sinc; Of a continuous square wave, it is a series 4K/pi[sin(ft) + sin(3ft)/3 + sin(5ft)/5 + ...], where f=1/T and T is the period. When this continuous wave is sampled, those frequency components higher than Fs/2 become the aliases I wrote of. If you have a more descriptive name for them, I might adopt it. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●November 29, 20072007-11-29
Jerry is exactly right-- performing non-linear operations on a digital signal creates harmonics that can become aliased. It's really a very stong and interesting effect. If you look at the frequency spectrum on a log scale, the aliased harmonics might initially seem to be random noise. Upon closer inspection you can see that it is a multitude- even hundreds- of individual peaks. Here's an example in my book (the pdf probably has a better quality picture than the html): http://www.dspguide.com/ch11/5.htm Regards Steve
Reply by ●November 29, 20072007-11-29
Jerry Avins <jya@ieee.org> wrote in news:tLKdnWJLNsRMitLanZ2dnUVZ_t6onZ2d@rcn.net:> > When this continuous wave is sampled, those frequency components higher > than Fs/2 become the aliases I wrote of. If you have a more descriptive > name for them, I might adopt it.I saw the problem the other way-- sample the sine wave, and then do the window discrimination digitally. This will still give plenty of non- harmonic values, and they're not due to aliasing. It never occured to me that anyone would create a discontinuous signal from a well behaved signal, and then sample it. I'm wondering which way the OP was doing this? -- Scott Reverse name to reply
Reply by ●November 29, 20072007-11-29
On Nov 29, 1:17 pm, Randy Yates <ya...@ieee.org> wrote:> Scott Seidman <namdiestt...@mindspring.com> writes: > > Jerry Avins <j...@ieee.org> wrote in > >news:TYednZYNrtiqZNPanZ2dnUVZ_s_inZ2d@rcn.net: > > >> The non-harmonic tones are aliases. Do you understand about aliasing in > >> sampled signals? > > > I would think that the signal is already sampled, so they're not > > aliases. > > They still could be. If you perform a non-linear operation on a digital > signal, you introduce harmonics that can go past the Nyquist frequency, > and those get aliased. > -- > % Randy Yates % "I met someone who looks alot like you, > %% Fuquay-Varina, NC % she does the things you do, > %%% 919-577-9882 % but she is an IBM." > %%%% <ya...@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://www.digitalsignallabs.comYEP. it's very hard to make a "audio clipper" in the digital domain.. Mark






