DSPRelated.com
Forums

fourier anlysis of square wave...

Started by suren November 29, 2007
Scott Seidman <namdiesttocs@mindspring.com> writes:

> "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in > news:NqKdnQQu6dSz3NLanZ2dnUVZ_o6knZ2d@centurytel.net: > >> Now, it is true that the samples in (2) might represent a perfectly >> bandlimited signal. > > > I'm still not getting it > > Let's try this... > > I(n)=1 0 0 0 0 0 0 0 0 0...... > > The FFT of that has zip to do with aliasing. > > same for I(n-1), and thus I(n)+I(n-1) > > But for some reason, the FFT of > > 1 1 0 0 1 1 0 0 1 1 0 0 ...... > > has something to do with aliasing, simply because you can get to the same > signal from a clipped sine wave?
Hi Scott, I think I see your point, and you're making me wonder. I have nothing to say to defend my previous point, at least not yet. I am thinking about it, albeit in the background, and I'll post again if something hits me. -- % Randy Yates % "So now it's getting late, %% Fuquay-Varina, NC % and those who hesitate %%% 919-577-9882 % got no one..." %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO http://www.digitalsignallabs.com
Steve Underwood <steveu@dis.org> writes:

> This "once you are digitised you are safe" idea is often used like a > mantra, for some reason. I'm puzzled where the idea even comes > from. Has some popular book pushed the idea?
Not that I'm aware of, but I can see why people get the idea: If we define aliasing to be the effect of sampling at a frequency that is too low for the frequency content of the sampled signal, then that is _not_ the effect this thread is talking about. The thread is (mostly) referring to the case where the signal is already sampled. Once a signal is sampled, the maximum frequency it can contain is pi (or 1, depending on how you define "frequency"). So is applying a nonlinearity to an already-sampled signal really aliasing (as defined above)? I agree that it has similar aspects to aliasing, but I don't think that the effect should necessarily go by the same name. Comments? Criticisms? Witticisms? Ciao, Peter "Devil's Advocate" K. -- "And he sees the vision splendid of the sunlit plains extended And at night the wondrous glory of the everlasting stars."
Ron N. wrote:

   ...

> 64 cycles of period 16 (8 ones, 8 minus ones) fills 1024 > samples (the clue was the fft result filling only odd > multiples of 16 bins).
Your test square wave had a frequency of fs/16. The harmonics should fall at 3fs/16, 5fs/16 , 7fs/16 (ok so far), 9fs/16 (aliases, but 19 dB down), 11fs/16 (aliases 21 dB down), and so on. Is that what you see? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Nov 30, 6:00 pm, Jerry Avins <j...@ieee.org> wrote:
> Ron N. wrote: > > ... > > > 64 cycles of period 16 (8 ones, 8 minus ones) fills 1024 > > samples (the clue was the fft result filling only odd > > multiples of 16 bins). > > Your test square wave had a frequency of fs/16. The harmonics should > fall at 3fs/16, 5fs/16 , 7fs/16 (ok so far), 9fs/16 (aliases, but 19 dB > down), 11fs/16 (aliases 21 dB down), and so on. Is that what you see?
The harmonics fell in those bins (and only those bins), but the higher harmonics did not drop off at 1/bin_number. Maybe the harmonics from the negative frequencies were wrapping around from the opposite side of the fft and interfering constructively in the middle. That would be aliasing. But nothing appeared in non-harmonic bins. So this aliasing would not be the cause of the OP's observation of seeing "non-harmonic tones" in his FFT plot... unless his square waves were not periodic in the FFT aperture, in which case the negative frequency harmonics would not overlap the positive frequency harmonics, but appear in between them (in addition to the rectangular windowing artifacts).
Ron N. wrote:
> On Nov 30, 6:00 pm, Jerry Avins <j...@ieee.org> wrote: >> Ron N. wrote: >> >> ... >> >>> 64 cycles of period 16 (8 ones, 8 minus ones) fills 1024 >>> samples (the clue was the fft result filling only odd >>> multiples of 16 bins). >> Your test square wave had a frequency of fs/16. The harmonics should >> fall at 3fs/16, 5fs/16 , 7fs/16 (ok so far), 9fs/16 (aliases, but 19 dB >> down), 11fs/16 (aliases 21 dB down), and so on. Is that what you see? > > The harmonics fell in those bins (and only those bins), > but the higher harmonics did not drop off at 1/bin_number. > Maybe the harmonics from the negative frequencies were > wrapping around from the opposite side of the fft and > interfering constructively in the middle. That would be > aliasing. But nothing appeared in non-harmonic bins. So > this aliasing would not be the cause of the OP's observation > of seeing "non-harmonic tones" in his FFT plot... unless > his square waves were not periodic in the FFT aperture, > in which case the negative frequency harmonics would not > overlap the positive frequency harmonics, but appear > in between them (in addition to the rectangular windowing > artifacts).
That's what I figure happened. Even the positive harmonics, when folded back wouldn't land on harmonic frequencies because the folding frequency wouldn't be centered. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
suren wrote:
> On Nov 29, 10:39 pm, Jerry Avins <j...@ieee.org> wrote: > >>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. >>&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; > > > Hello All, > Thanks for the valuable suggestions. I now understand that the non > harmonic components is due to aliasing.
You may also being seeing "spectral leakage" if you have not windowed your data. See fig 1 at http://en.wikipedia.org/wiki/Window_function .
> Since, in a square wave the > amplitude of the harmonic terms goes as 1/n, where n is odd, it looks > like we need to sample at a very high rate, may be at the 1000th > harmonic rate to see accurate behvaior. > > However, in my application, I need to analyse signals in the GHz range > and using sampling rates which are very high is becoming an issue. Are > there better methods to analyse such cases? > Regards > suren
What do *YOU* mean by "analyse"? That can mean as many things as "love" -- "love your wife", "love mom's apple pie", or "love fast cars" ;)
"Peter K." <p.kootsookos@remove.ieee.org> wrote in message 
news:umysv2n3j.fsf@remove.ieee.org...
> Steve Underwood <steveu@dis.org> writes: > >> This "once you are digitised you are safe" idea is often used like a >> mantra, for some reason. I'm puzzled where the idea even comes >> from. Has some popular book pushed the idea? > > Not that I'm aware of, but I can see why people get the idea: > > If we define aliasing to be the effect of sampling at a frequency that > is too low for the frequency content of the sampled signal, then that > is _not_ the effect this thread is talking about. The thread is > (mostly) referring to the case where the signal is already sampled. > > Once a signal is sampled, the maximum frequency it can contain is pi > (or 1, depending on how you define "frequency"). > > So is applying a nonlinearity to an already-sampled signal really > aliasing (as defined above)? > > I agree that it has similar aspects to aliasing, but I don't think > that the effect should necessarily go by the same name. > > Comments? Criticisms? Witticisms?
Peter, After we sample we can talk about a Fourier Transform *or* a DFT. The DFT can be "unwound" into an infinite, discrete periodic sequence. So when you say:
> Once a signal is sampled, the maximum frequency it can contain is pi > (or 1, depending on how you define "frequency").
If there is subsampling of the temporal sequence it's pretty easy to envision what happens in frequency. If there's any overlap of nonzero spectral components then that's what we normally call "aliasing". It's the overlap that appears to be "folding" but that's perhaps an unfortunate way of looking at it. It's more a matter of the negative frequencies at the next higher sampling harmonic moving down to overlap the positive frequencies at the next lower sampling harmonic. When this happens, the frequency of individual components is "translated" in a known way - but such that the signal can't usually be reconstructed. Similarly, if there's a nonlinear operation or even a linear time-varying operation then there are new frequencies created. If the new frequencies cause overlap as above then that would be considered to be "aliasing". With the unwound DFT, that's pretty easy to see. Any time a new frequency is created (including with sampling or subsampling) then if the spectra mix with the original such that interpretation of frequency becomes ambiguous, there's aliasing. If there's no ambiguity then there's no aliasing. Examples of the latter are well known in down-shifting schemes. Fred
suren wrote:
> On Nov 29, 10:39 pm, Jerry Avins <j...@ieee.org> wrote: >> 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?
...
> Hello All, > Thanks for the valuable suggestions. I now understand that the non > harmonic components is due to aliasing. Since, in a square wave the > amplitude of the harmonic terms goes as 1/n, where n is odd, it looks > like we need to sample at a very high rate, may be at the 1000th > harmonic rate to see accurate behvaior. > > However, in my application, I need to analyse signals in the GHz range > and using sampling rates which are very high is becoming an issue. Are > there better methods to analyse such cases?
You cannot get reliable information by sampling a signal that contains baseband frequencies as high as half the sample rate. (Bandpass sampling is also possible, but I won't go into that unless you leas us there.) There are two choices: sample so fast that there is no significant energy above half the sample rate, or lowpass filter the signal before sampling it. I repeat my earlier question: Do you understand about aliasing in sampled signals? If not, you have a lot of reading to do before you can successfully deal with your problem. If I understand, you are modeling this problem with software simulation. I strongly doubt that you will actually have gigahertz square waves in practice. Examine your model more closely. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Peter K. wrote:
> Steve Underwood <steveu@dis.org> writes: > >> This "once you are digitised you are safe" idea is often used like a >> mantra, for some reason. I'm puzzled where the idea even comes >> from. Has some popular book pushed the idea? > > Not that I'm aware of, but I can see why people get the idea: > > If we define aliasing to be the effect of sampling at a frequency that > is too low for the frequency content of the sampled signal, then that > is _not_ the effect this thread is talking about. The thread is > (mostly) referring to the case where the signal is already sampled. > > Once a signal is sampled, the maximum frequency it can contain is pi > (or 1, depending on how you define "frequency"). > > So is applying a nonlinearity to an already-sampled signal really > aliasing (as defined above)? > > I agree that it has similar aspects to aliasing, but I don't think > that the effect should necessarily go by the same name. > > Comments? Criticisms? Witticisms?
Consider the signal sin(Fs/3). Square it to get [1 - cos(2Fs/3)]/2. Sample it at Fs; see the DC and the alias. Sample sin(Fs/3) at Fs and square each sample. I contend that if squaring the samples produces the same result as squaring (and not filtering) the signal, then both are aliasing. Without actually doing it, the sameness seems evident to me. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Dec 1, 9:36 am, Jerry Avins <j...@ieee.org> wrote:
> Peter K. wrote: > > Steve Underwood <ste...@dis.org> writes: > > >> This "once you are digitised you are safe" idea is often used like a > >> mantra, for some reason. I'm puzzled where the idea even comes > >> from. Has some popular book pushed the idea? > > > Not that I'm aware of, but I can see why people get the idea: > > > If we define aliasing to be the effect of sampling at a frequency that > > is too low for the frequency content of the sampled signal, then that > > is _not_ the effect this thread is talking about. The thread is > > (mostly) referring to the case where the signal is already sampled. > > > Once a signal is sampled, the maximum frequency it can contain is pi > > (or 1, depending on how you define "frequency"). > > > So is applying a nonlinearity to an already-sampled signal really > > aliasing (as defined above)? > > > I agree that it has similar aspects to aliasing, but I don't think > > that the effect should necessarily go by the same name. > > > Comments? Criticisms? Witticisms? > > Consider the signal sin(Fs/3). Square it to get [1 - cos(2Fs/3)]/2. > Sample it at Fs; see the DC and the alias. Sample sin(Fs/3) at Fs and > square each sample. I contend that if squaring the samples produces the > same result as squaring (and not filtering) the signal, then both are > aliasing. Without actually doing it, the sameness seems evident to me.
Perhaps you would first have to prove that there cannot exist any form of low-pass or bandlimiting filter that would result in a waveform producing the same samples at those pre-existing sample points, after removing the added high frequency spectra that would alias. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M