# square wave harmonic theory (time domain)

Discussion in 'Electronic Design' started by Thomas Magma, May 30, 2007.

1. ### Thomas MagmaGuest

Hello,
I'm trying to determine if the higher harmonics of a low frequency square
wave are actually AM modulated. For instance, I can see the harmonics of a 1
KHz square wave all the way up at 100 MHz if I zoom into them on a spectrum
analyzer. Are those harmonics really there when the 1 KHz square wave has
finished it's transition and is in a steady state for half a millisecond? If
I was to sample this steady state with a ultra fast ADC and FFT the samples,
would I see the harmonics extending up through 100 MHz?

It's a bit of a mind bender when converting between the time and frequency
domain in the case of a square wave.

Thanks,
Thomas Magma

2. ### MarraGuest

I thought a square wave could be broken down into a sum of many sine
waves?

3. ### John LarkinGuest

Assuming an ideal constant-frequency square wave, all the (odd)
harmonics are there all the time, invariant in phase or amplitude. It
is mind boggling.

In real life, any square wave has a little frequency modulation
(jitter, in the time domain) and that makes higher harmonics jump
around, essentially amplitude modulated sort of at random.

It would be hard to sample and FFT such as to resolve the 100,000th
harmonic of any waveform.

John

4. ### Phil HobbsGuest

Fourier's theorem is correct, yes.

Maybe it's easier to see in the case of a delta-function, whose
transform is 1 (i.e. unit amplitude, zero phase at all frequencies). If
you imagine starting with a lowpass filter and gradually widening it,
you'd see the central spike getting taller (because all the frequency
components add in phase there), and narrower, because they all cancel
out everywhere else, once you turn the bandwidth up sufficiently.

Now make a periodic alternating sequence of those delta-functions, which
gets rid of the frequencies that aren't harmonics of the rep
rate--you'll be left with individual unit-strength spikes in the
spectrum, placed at all the odd harmonics of the rep rate.

Now integrate. That multiplies all those spikes by 1/(j omega), and
presto, a square wave.

HTH,

-_-_-_Phil-_Hobbs-_-_-_-_-_

5. ### Jim BackusGuest

No, they aren't.
Of course you would.
Yes it is, but if you have any programming skills, try working the
appropriate level of 3rd, 5th, 7th etc. harmonics and see the sum of
the components gradually turning into a square wave. You'll see that
each frequency term is present continuously.

HTH

Jim

6. ### Thomas MagmaGuest

I was only kind of talking a theoretical ADC. Even though there are ADC's up
in the Giga samples per second, lets talk about a theoretical test with an
ADC that samples at 1Gsps with 24 bit resolution (kick-ass ADC). If I took a
1 KHz square wave and triggered my ADC on the rising edge of the
pulse...delayed a bit waiting for the transistor to settle (say
200uS)...then took 65536 samples (65uS) of the steady state and did an FFT
on them...what would I see? In the time domain it would appear I was
sampling DC. If the FFT shows high frequencies relating to 1KHz where are
they coming from?

Thomas

7. ### SteveGuest

The fundamental assumption for the FFT is that the data taken during your
sampling interval repeats from negative infinity to positive infinity. If
you take 65K samples of an unchanging DC level, you will get only DC energy
in the result, (plus all the artifacts from windowing, roundoff, etc.)

So as John pointed out - the harmonics are really there if you sample the
entire 1 kHz wave and it has instantaneous rise/fall times. But if you only
look at a piece of the signal, you get a completely different result.

To minimize the sampling artifacts, make the sample interval an exact
multiple of your waveform's period, so that the "repeating to infinity"
assumption is valid. Since its not usually practical to do that exactly,
window functions are used to reduce the artifacts that will appear when the
FFT algorithm "assumes" its seeing an integral number of periods of an
infinitely repeating waveform.

Steve

8. ### JamieGuest

In theory, an ideal square wave should generate infinite frequencies in
harmonics.
But then again, we don't exist in a ideal world! .

9. ### Thomas MagmaGuest

I was only kind of talking a theoretical ADC. Even though there are ADC's
So now I'm really confused, are you saying that during certain times of a
square wave there is no harmonic content? Would that not imply that the high
frequency harmonics are stronger at certain instances of time compared to
others?

Thomas

10. ### John LarkinGuest

A square wave is forever. If you examine a little time slice of a
square wave, it's not a square wave... it's a rise, or a fall, or DC.

John

11. ### Don LancasterGuest

As a general rule, if you modulate the fundamental, you modulate the
harmonics.

Digitize it and run a Fourier Transform.

Otherwise, phase lock to a harmonic and see what demods out.

http://www.tinaja.com/glib/magsn01.asp

--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552

Please visit my GURU's LAIR web site at http://www.tinaja.com

12. ### Phil AllisonGuest

"Thomas Magma"

** They simply do not exist in the " time domain".

** Sorry, that is not a " time domain" instrument.

** There is the sudden step change in voltage followed by a steady voltage
until the cycle repeats.

YOU asked for the " time domain" (ie real life ) view, so you cannot
simultaneously crap on about imaginary harmonics.

** No - it is just a fixed voltage.

** Has no-one ever informed you the " frequency domain " does not really
exist - except as an abstract mathematical conception.

Albeit, a very useful one.

........ Phil

13. ### J.A. LegrisGuest

Really? How about the domain of an optical Fourier plane? Seems pretty
real to me:

http://www.icm.edu.pl/vip2007/pdf/Borucki-vip2007.pdf

14. ### Phil AllisonGuest

"J.A. Legris **** Brain" "

** Yep.

........ Phil

15. ### SteveGuest

What I am saying is that if you only look at a small piece of the wave
period, you do not get any information about what frequencies are required
to produce the parts you aren't looking at. The FFT cannot analyze portions
of a waveform it never saw. If all 64K samples are at 3.34578 volts, then
the FFT has to say its looking at a 3.34578 DC voltage. How can it know
anything else? That's why I pointed out that the assumption of infinite
periodicity must be considered when you interpret the results. Otherwise
it's garbage in garbage out analysis.

Steve

16. ### Phil AllisonGuest

"Steve the Jerk Off"

Says " time domain" !!!!!!!!!!!!!!!!!!!!!!!!!!

Got the fucking faintest what that is ??????????

Obviously NOT !!!!!!!!!!! !!

** It cannot " time domain" analyse any damn thing

- you dopey fuckwit !!

Why the **HELL** are so many otherwise quite knowledgeable folk * totally*
off the PLANET on such a simple issue.

........ Phil

17. ### MooseFETGuest

On May 30, 1:50 pm, John Larkin
[....]
Here's how I first go a grip on the idea in a time domain sense. It
may help others.

Imagine you have a tuned circuit with a very high Q being driven by
the squarewave. On each edge, the tuned circuit will be "shock
excited" and then start to ring down. This is like a bell being
struck, if you want to imagine a sound for it.

If the Q is high enough, when the next edge comes along, the circuit
is still ringing. If the tuned circuit is tuned to an odd harmonic,
the next edge will be timed perfectly to pump the ringing up.

Now imagine the shape of the envelope. It jumps up and decays and
jumps up and decays. The decay rate decreases for higher Qs. In your
mind crank the Q up. Luckily, you can imagine better inductors than
you can buy. At a stupendous Q value, there is no longer any
modulation and the signal is a good sine wave.

We know that the tuned circuit is a filter so it doesn't invent
frequencies just selects them. This means that the sine wave we see
on the output must have been in the input.

18. ### MooseFETGuest

On May 30, 1:50 pm, John Larkin
[....]
Here's how I first go a grip on the idea in a time domain sense. It
may help others.

Imagine you have a tuned circuit with a very high Q being driven by
the squarewave. On each edge, the tuned circuit will be "shock
excited" and then start to ring down. This is like a bell being
struck, if you want to imagine a sound for it.

If the Q is high enough, when the next edge comes along, the circuit
is still ringing. If the tuned circuit is tuned to an odd harmonic,
the next edge will be timed perfectly to pump the ringing up.

Now imagine the shape of the envelope. It jumps up and decays and
jumps up and decays. The decay rate decreases for higher Qs. In your
mind crank the Q up. Luckily, you can imagine better inductors than
you can buy. At a stupendous Q value, there is no longer any
modulation and the signal is a good sine wave.

We know that the tuned circuit is a filter so it doesn't invent
frequencies just selects them. This means that the sine wave we see
on the output must have been in the input.

19. ### SteveGuest

I didn't get hung up on the heading. I was trying to answer his question in
ignoring what he really asked just seems like a way to exhibit personal
indignation and feel superior, but it helps no one.

Steve

20. ### Phil AllisonGuest

"Steve the ASD Fucked Jerk Off"

** You failed to even read it - FUCKWIT !!!

** You failed to n comprehend the OP's question

- FUCKWIT !!

** Exactly what ** YOU ** just did - fuckwit.

PISS OFF - BLOODY IMBECILE !!!!!!!!!!

........ Phil