 Login Join Maker Pro

### Network # Harmonic composition of a square wave

D

#### davidd31415

Jan 1, 1970
0
I know you can make a square wave from the sum of sinusoidals, but does
this mean that if you look at a sine-wave that wasn't made by using
sinusoids (perhaps using a switch or an oscillating crystal to turn the
signal on and off) on a spectrum analyzer that you would see all of the
harmonics required to make up the square wave?

L

#### Larry Brasfield

Jan 1, 1970
0
davidd31415 said:
I know you can make a square wave from the sum of sinusoidals,

Not true, actually. See http://mathworld.wolfram.com/GibbsPhenomenon.html
but does
this mean that if you look at a sine-wave that wasn't made by using
sinusoids (perhaps using a switch or an oscillating crystal to turn the
signal on and off) on a spectrum analyzer that you would see all of the
harmonics required to make up the square wave?

Depending on the analyzer and its settings, you will see
harmonics as they would be computed in the usual way
for obtaining the Fourier series. Whether the "sine-wave"
(or square wave, for that matter) was made by composing
sinusoids or not, its harmonics depend only on its shape.

J

#### John Popelish

Jan 1, 1970
0
davidd31415 said:
I know you can make a square wave from the sum of sinusoidals, but does
this mean that if you look at a sine-wave that wasn't made by using
sinusoids (perhaps using a switch or an oscillating crystal to turn the
signal on and off) on a spectrum analyzer that you would see all of the
harmonics required to make up the square wave?

I assume you mean that if you look at a *square* wave that wasn't made
by using sinusoids...

The answer is yes. How the waveform is created has nothing to do with
its harmonic content. Only its shape determines its harmonic content.
The faster the rise and fall edges and the squarer the corners, the
higher the frequencies contained in the package.

D

#### davidd31415

Jan 1, 1970
0
Ahh yes, glad the context gave that away, *square* indeed.

So how would the sampling rate of an oscilloscope be related to what a
square wave ends up looking like on the scope? Is there a rule of
thumb for the sampling rate of an oscilloscope when sampling square
waves?

J

#### John Popelish

Jan 1, 1970
0
davidd31415 said:
Ahh yes, glad the context gave that away, *square* indeed.

So how would the sampling rate of an oscilloscope be related to what a
square wave ends up looking like on the scope? Is there a rule of
thumb for the sampling rate of an oscilloscope when sampling square
waves?

At the very least, the scope cannot show a rise time (or any thing
else) less than the time between samples. It can connect two samples
with a straight line. At two samples per square wave, it displays a
triangle.

J

#### Jonathan Kirwan

Jan 1, 1970
0
So how would the sampling rate of an oscilloscope be related to what a
square wave ends up looking like on the scope? Is there a rule of
thumb for the sampling rate of an oscilloscope when sampling square
waves?

The rule I use is to have at least a factor of 5. I get a relatively
"true" picture of the square wave with a scope (and probing setup, of
course) that passes at about 3db down at 5X the square wave frequency.
That gives you the 1X, and 3X fairly good and enough of the 5X to get
decent presentation.

....

If you want to see about what the impact of such a decision would be
on a square wave, I believe you can use Excel (or some other program)
to compute the impact on a particular square wave.

SUM [ (1/n)*SIN(n*w)/SQRT(1+(n/5)^2) ], n=1,3,5,7, ...

with w=2*PI*f

This equation, if I've got it right, assumes that the voltage is
(1/SQRT(2)) at the scope's 3db down frequency. You can see this part
in the above equation, where you see /SQRT(1+(n/5)^2). At n=5 (5X the
frequency of the square wave, which is by definition 1/5th of the
scope's bandwidth, you get /SQRT(2). I think this properly scales the
values as the frequency is increased or decreased. The leading (1/n)
part of the equation is the Fourier scaling for the components of the
square wave. Combined together and summed for some moderately sized
'n', I think this should approximate what the scope will show you,
including its roll-off behavior. Of course, I'm open to being wrong.

But regardless, my rule is 5X for the analog scopes. Works for me.

Jon

B

#### Bob Masta

Jan 1, 1970
0
I know you can make a square wave from the sum of sinusoidals, but does
this mean that if you look at a sine-wave that wasn't made by using
sinusoids (perhaps using a switch or an oscillating crystal to turn the
signal on and off) on a spectrum analyzer that you would see all of the
harmonics required to make up the square wave?

You might want to have a look at DaqGen, my freeware
sound card signal generator for Windows. You can play
around with waveforms and see the effects via the built-in
spectrum analyzer.

Best regards.

Bob Masta

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator

C

#### Charles Jean

Jan 1, 1970
0
I know you can make a square wave from the sum of sinusoidals, but does
this mean that if you look at a sine-wave that wasn't made by using
sinusoids (perhaps using a switch or an oscillating crystal to turn the
signal on and off) on a spectrum analyzer that you would see all of the
harmonics required to make up the square wave?
___
This post got me to thinking about a related subject. I'm a hobbyist,
and my math is limited to one year of calculus, but I would like to
see if I have a correct conception of what's going on here. I can see
that any periodic function can be put through the Fourier transform to
obtain an infinite series of sin and/or cos terms to completely
describe the original function. This applies to electronic circuits,
musical instruments, vibrational analysis of bridge decks, etc.
So, when one sees a "perfect square wave" on the oscope, it is
actually always a mixture of sine waves of f(fundamental-the frequency
of the square wave as seen on the oscope),3f,5f,7f...... frequencies.
A more complex wave like that produced by a violin string would look
different than either a sine wave or a square wave, because the
mixture of waves producing it are not at the amplitude/frequency
required by the Fourier transform to produce a square wave. If I were
to see what looks like a very low distortion sine wave on the oscope,
I can infer that this is a "true sine" wave, with very little
contribution from any higher harmonics, and not some weird lucky mix
of higher sin/cos frequencies that are significant compared to the
fundamental? Or would the use of a spectrum analyzer be required to be
sure?
For circuit elements like capacitors and inductors, whose reactance
varies with frequency, what happens when dealing with a square wave?
what frequency does one use in the reactance formulas, knowing that
you're dealing with a mixture of them? I would instinctively just put
in the fundamental frequency, but is this right? TIA for clearing any
of this up for me.

C

#### colin

Jan 1, 1970
0
Charles Jean said:
___
This post got me to thinking about a related subject. I'm a hobbyist,
and my math is limited to one year of calculus, but I would like to
see if I have a correct conception of what's going on here. I can see
that any periodic function can be put through the Fourier transform to
obtain an infinite series of sin and/or cos terms to completely
describe the original function. This applies to electronic circuits,
musical instruments, vibrational analysis of bridge decks, etc.
So, when one sees a "perfect square wave" on the oscope, it is
actually always a mixture of sine waves of f(fundamental-the frequency
of the square wave as seen on the oscope),3f,5f,7f...... frequencies.
A more complex wave like that produced by a violin string would look
different than either a sine wave or a square wave, because the
mixture of waves producing it are not at the amplitude/frequency
required by the Fourier transform to produce a square wave. If I were
to see what looks like a very low distortion sine wave on the oscope,
I can infer that this is a "true sine" wave, with very little
contribution from any higher harmonics, and not some weird lucky mix
of higher sin/cos frequencies that are significant compared to the
fundamental? Or would the use of a spectrum analyzer be required to be
sure?
For circuit elements like capacitors and inductors, whose reactance
varies with frequency, what happens when dealing with a square wave?
what frequency does one use in the reactance formulas, knowing that
you're dealing with a mixture of them? I would instinctively just put
in the fundamental frequency, but is this right? TIA for clearing any
of this up for me.

Dont forget any practicaly generated squarewave isnt going to need an
infinite series of sine waves to fully define it.

a squarewave isnt necessarily made up of sinewaves its just very useful
indeed to be able to consider it as a series of sinewaves.

a pure sinewave cant be split into other sinewaves. you can probably tell on
the scope if its say a 90% pure sinewave or more.

if you feed a squarewave into a circuit with a non flat frequeucny response
you can think of it by seperating it into the harmonics, then seeing how big
each harmonic is afterwards but also what phase, and then try and
reconstruct the waveform.

it all depends what you want to do with the reactive circuit, sometimes you
want to filter out the fundemental so you would chose that as the frequency,
but you might also want to use one of the other harmonics instead and filter
out one of those and you have a frequency multiplier. unless of course its
an inductor for a power supply in wich case you would want to filter out as
much as posible.

Colin =^.^=

J

#### John Popelish

Jan 1, 1970
0
Charles Jean wrote:
8<
If I were
to see what looks like a very low distortion sine wave on the oscope,
I can infer that this is a "true sine" wave, with very little
contribution from any higher harmonics, and not some weird lucky mix
of higher sin/cos frequencies that are significant compared to the
fundamental? Or would the use of a spectrum analyzer be required to be
sure?

Yes, you can infer that. Another way to this conclusion is if you
pass any other periodic waveform through a good low pass filter that
passes the periodic fundamental but greatly attenuates the second and
higher harmonics, you always get very nearly the same sine wave out of
the filter.
For circuit elements like capacitors and inductors, whose reactance
varies with frequency, what happens when dealing with a square wave?

For analysis of what happens, either you:

Assume a linear circuit, calculate the effect of each component
frequency, individually, and using the assumption of linearity, add
the various component frequency effects together to get the overall
effect or just deal with what happens to each harmonic, separately.

Use the instantaneous (differential) descriptions of all the
components and integrate the result (usually using numerical
approximations).

Most Spice programs allow both the amplitude and phase versus
frequencies that you specify (the first method) or the time response
to an arbitrarily stimulus (the second method) that simulates what you
would see on a scope.
what frequency does one use in the reactance formulas, knowing that
you're dealing with a mixture of them?

As many of them as you are interested in. Your interest may fade
because the amplitudes become insignificant, or because you have some
reason to suspect that frequencies above some point are so attenuated
or ignored by other parts of the system that they ate moot.
I would instinctively just put
in the fundamental frequency, but is this right? TIA for clearing any
of this up for me.

If the waveform is a pretty clean sinusoid, that will give you a
pretty good approximation of what is going on. If the waveform is a
pulse with an on time 1% of the period, you will learn almost nothing
useful.

B

#### Bob Myers

Jan 1, 1970
0
Dont forget any practicaly generated squarewave isnt going to need an
infinite series of sine waves to fully define it.

True, but that's just another way of saying that there are no truly
"perfect" square waves in practice, since finite limits on bandwidth
always mean that you can never get to zero rise/fall time.

a squarewave isnt necessarily made up of sinewaves its just very useful
indeed to be able to consider it as a series of sinewaves.

No, it really, really is. Any periodic signal IS composed of sinusoidal
components; the frequency domain (i.e., what you see on the screen of
a spectrum analyzer) is just as valid as the time domain (which is what you
see on the screen of an oscilloscope).

Bob M.

C

#### colin

Jan 1, 1970
0
Bob Myers said:
True, but that's just another way of saying that there are no truly
"perfect" square waves in practice, since finite limits on bandwidth
always mean that you can never get to zero rise/fall time.

yes indeed you dont get those nasty little discontinuities wich cuase the
ringing as someone mentioned. its also the squarenss of the corners wich
are never perfectly square.
No, it really, really is. Any periodic signal IS composed of sinusoidal
components; the frequency domain (i.e., what you see on the screen of
a spectrum analyzer) is just as valid as the time domain (which is what you
see on the screen of an oscilloscope).

ah, I meant made up as in 'constructed from'. (ie adding together
individualy generated sinewaves). wich is what i thought the OP was getting
confused about, if you look at an oscillator (such as LC or crystal rather
than relaxation type) generaly it will start off producing a fairly pure
sinewave that builds up in amplitude, when the amplitude exceeds the supply
rails it will be clipped, and hence the top and bottom 'round part' will be
removed. so the harmonics arise from the bits that are missing from what
would otherwise be a very large sinewave.

You have to be carefull, if you look at the spectrum of a squarewave thats
been through an all pass filter wich adds 90' phase shifts above a certain
frequency it will be different on an oscilloscope although it has the same
ampliitude of harmonics, so it will look the same on a spectrum analyser
unless its a digital one wich displays phase too, but phase information on a
FFT display can sometimes be eratic.

Basicaly I was just trying to say its valid to work in only time domain
completly if you need too, wich might be the case if your looking at a
digital waveform, however even with digital waveforms you will often need to
consider the frequency domain too, especialy if its the loop of a PLL for
instance, or the effects of the highest harmonics on crosstalk, power supply
decoupling reactance, emi etc.

If your working with RF then you would normaly only think in terms of the
frequency domain.

Its good to have the fexibilty to think in either one or the other or both
at the same time.

Colin =^.^=

B

#### Bob Masta

Jan 1, 1970
0
On Sat, 25 Jun 2005 01:35:44 GMT, Charles Jean

If I were
to see what looks like a very low distortion sine wave on the oscope,
I can infer that this is a "true sine" wave, with very little
contribution from any higher harmonics, and not some weird lucky mix
of higher sin/cos frequencies that are significant compared to the
fundamental? Or would the use of a spectrum analyzer be required to be
sure?

The trick part of your question is "looks like a very low distortion
sine wave on the scope". I have found that it is very difficult to
judge distortion from a scope trace, below a few percent. And
certain distortion combinations can be even harder to detect
visually, maybe up to 10% or so, if all they do is fatten the
sine wave a bit. So you definitely need a spectrum analyzer to
know about low distortion levels.

But in truth there is nothing in the spectrum that is not
in the waveform. In theory, you could have a *really*
large-screen high-resolution scope face and an overlay
of a perfect sine wave to match up with, and you could
detect distortion down to as low a level as you want.
Just not very practical!

Best regards,

Bob Masta

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator

C

#### Charles Jean

Jan 1, 1970
0
___
This post got me to thinking about a related subject. I'm a hobbyist,
and my math is limited to one year of calculus, but I would like to
see if I have a correct conception of what's going on here. I can see
that any periodic function can be put through the Fourier transform to
obtain an infinite series of sin and/or cos terms to completely
describe the original function. This applies to electronic circuits,
musical instruments, vibrational analysis of bridge decks, etc.
So, when one sees a "perfect square wave" on the oscope, it is
actually always a mixture of sine waves of f(fundamental-the frequency
of the square wave as seen on the oscope),3f,5f,7f...... frequencies.
A more complex wave like that produced by a violin string would look
different than either a sine wave or a square wave, because the
mixture of waves producing it are not at the amplitude/frequency
required by the Fourier transform to produce a square wave. If I were
to see what looks like a very low distortion sine wave on the oscope,
I can infer that this is a "true sine" wave, with very little
contribution from any higher harmonics, and not some weird lucky mix
of higher sin/cos frequencies that are significant compared to the
fundamental? Or would the use of a spectrum analyzer be required to be
sure?
For circuit elements like capacitors and inductors, whose reactance
varies with frequency, what happens when dealing with a square wave?
what frequency does one use in the reactance formulas, knowing that
you're dealing with a mixture of them? I would instinctively just put
in the fundamental frequency, but is this right? TIA for clearing any
of this up for me.
___
Thanks for all the great insights you folks provided! They cleared up
some of the fog. I thought John's idea of putting the signal through a
good low-pass filter was a quick, semi-quantitative test for the
presence of significant harmonics was especially neat. Any good
references on how to design/build a decent one? Is it possible to
make one that has a variable cut-off frequency? Or is there a circuit
out there somewhere for a "poor-boy" RF spectrum analyzer?(0.5-30
MHz). Please remember that any thing above elementary calculus leaves
me with puzzled look on my face-this includes differential equations!
Thanks again for the great responses.

Charlie

J

#### John Popelish

Jan 1, 1970
0
Charles said:
___
Thanks for all the great insights you folks provided! They cleared up
some of the fog. I thought John's idea of putting the signal through a
good low-pass filter was a quick, semi-quantitative test for the
presence of significant harmonics was especially neat. Any good
references on how to design/build a decent one? Is it possible to
make one that has a variable cut-off frequency? Or is there a circuit
out there somewhere for a "poor-boy" RF spectrum analyzer?(0.5-30
MHz). Please remember that any thing above elementary calculus leaves
me with puzzled look on my face-this includes differential equations!
Thanks again for the great responses.

I don't know about .5 to 30 MHz, but if you stay down in the audio
spectrum, you can make some very narrow band pass filters with opamps
that are easily tunable over a wide range while holding fairly fixed
Q. The type that is easiest to adjust is probably a state variable or
Most versions also have a low pass output and some have a high pass
and notch output, so you can do lots of experiments with them. For
instance, with the notch, you can remove the fundamental and see what
other harmonics are left from the wave.

Any of these can be made with a good quad opamp.

http://pdfserv.maxim-ic.com/en/an/AN1762.pdf

D

#### Dr Engelbert Buxbaum

Jan 1, 1970
0
davidd31415 said:
So how would the sampling rate of an oscilloscope be related to what a
square wave ends up looking like on the scope? Is there a rule of
thumb for the sampling rate of an oscilloscope when sampling square
waves?

Shannons theorem says that in order to see a signal with frequency n,
the sampling rate needs to be at least 2*n. Practical application:
Humans hear frequencies of up to 20 kHz, so the sampling frequency of a
CD player needs to be at least 40 kHz. Frequencies higher than 20 KHz
are filtered out before sampling by a low pass, in order to prevent
artefacts (beating of sampling and signal frequency).

This also means that digital equipment can only truthfully represent
sine waves. Any other signal form contains high order harmonics, which
need to be cut of at some point. The closer a square wave gets to the
sampling rate, the more harmonics are removed, and the "rounder" the
signal will appear.

Thus how much higher than the signal frequency the sampling rate needs
to be depends on how good you want the signal form represented, but 10
times is good enough for most purposes.

F

#### Fred Abse

Jan 1, 1970
0
Shannons theorem says that in order to see a signal with frequency n,
the sampling rate needs to be at least 2*n.

That's Nyquist's sampling theorem, surely.

Shannon's law deals with channel capacity and signal to noise ratio:

C = B log(base2)(1+S/N)

R

#### redbelly

Jan 1, 1970
0
Fred said:
That's Nyquist's sampling theorem, surely.

Yep. And if the 2*f sampling is 90 degrees out of phase with the
signal (namely, sampling at the zero-crossings), then the signal will
not appear even then.

Mark

Replies
10
Views
2K
Replies
2
Views
715
Replies
17
Views
2K
Replies
40
Views
13K
Replies
1
Views
1K