Re: fourier anlysis of square wave...



On Nov 29, 2:46 pm, "Fred Marshall" <fmarshallx@xxxxxxxxxxxxxxxxxxxx>
wrote:
"Ron N." <rhnlo...@xxxxxxxxx> wrote in message

news:7a7b3869-8b24-40fa-9f57-9de8a2b0ca6a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Nov 29, 8:47 am, suren <suren.r...@xxxxxxxxx> 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.

My thought exactly. It's one simple explanation for what you're doing if
the window isn't matched to an integral number of cycles of the "square
wave".

Also, if the sine wave is already sampled there will also be "modulation" of
the apparent frequency of the "square wave" because the axis crossings will
dither unless the sampling frequency is an integer multiple of the signal
frequency. This effect may even be stronger than grabbing a sub-period in
the window interval as mentioned above.

Many folks have mentioned what happens if there is a nonlinear operation on
a sequence of samples. Think of it like this:

1) Take a continuous signal and hard clip it. Then lowpass filter it. Then
sample it.

2) Take a sampled signal and hard clip it.

Compare the resulting samples. They won't be the same because of the
lowpass filter on the hard-clipped continuous signal. Without the filter
there will be aliasing.

3) Let's assume that the sample rate is high enough and/or the sample
frequency is matched to the underlying signal such that the samples
resulting from (2) are the same as the samples resulting from (1) if the
lowpass filter had not been applied.

The comparison in (3) clearly shows that the resulting samples in (2) must
have aliasing included.

In the general case, this can occur. But in the case of a
waveform which is perfectly anti-symmetric around all it's
zero crossings (such as a sinusoid without any DC bias), the
non-linear sgn() function will produce in the same resulting
samples whether done before linear phase bandlimiting and
sampling, or done after the sampling.

Note the sgn(0) returns 0. If the OP biased his sgn()
function, then he will add biased impulse noise at all
his zero crossings that align with sample points.



IMHO. YMMV.
--
rhn A.T nicholson d.0.t C-o-M
.



Relevant Pages

  • Re: Hang-Time??? Ping: Rich Koerner
    ... that everything is based on the application of the SINE wave. ... We have an amp operating at max rating. ... tracks the square wave on the left. ...
    (alt.guitar.bass)
  • Re: fourier anlysis of square wave...
    ... I convert a sine wave to a square wave using a zero crossing detector ... lowpass filter on the hard-clipped continuous signal. ...
    (comp.dsp)
  • Re: The Limits of the LP
    ... what my ears tell me, ... This square wave bullshit has been debunked AGAIN ... less your ear actually hears a square and it actually hears a sine wave. ...
    (rec.audio.opinion)
  • Re: square to sine
    ... > triangle wave from the square wave. ... Run the triangle wave into an automatic ... > This scheme creates a sine and triangle wave out of the square wave and can ...
    (sci.electronics.basics)
  • Re: The Limits of the LP
    ... This square wave bullshit has been debunked AGAIN ... less your ear actually hears a square and it actually hears a sine wave. ... design of the filter, 44.1 or 48k are perfectly adequate to COMPLETELY ...
    (rec.audio.opinion)