share
Electrical EngineeringWhat exactly are harmonics and how do they "appear"?
[+33] [7] John Quinn
[2012-05-21 07:13:29]
[ ac signal wave fourier ]
[ https://electronics.stackexchange.com/questions/32310/what-exactly-are-harmonics-and-how-do-they-appear ]

From reading so many sources online, I still cannot grasp why a different waveforms have harmonics.

For example: when designing a silly amplitude modulation (AM) circuit that puts a square wave from a microcontroller in to an antenna, how are harmonics generated? The signal is just "on" or "off", how are there first, third, and fifth harmonics and why do they get weaker?

I've heard oscilloscopes being able to measure up to the fifth harmonic of a square wave (or something similar) is important, but why would that make the reading different? Are these harmonics irrelevant in things such as data transfer (high=1, low=0) and only matter in situations such as audio or RF?

Why do sinusoidal waves not have as many harmonics? Because the waveform is always moving and not flat going up (triangle) or horizontal (square), but circular with an always changing value?

(2) I get the impression that you're using "harmonics" colloquially - higher frequency disturbance. Harmonics (frequencies) are tied into the definition of the Fourier series decomposition - so you will have harmonics if you decompose a square wave into sine waves. You could in theory use some other orthonormal basis - see @supercat's comment below. - Sridhar
"how are harmonics generated? The signal is just "on" or "off", how are there first, third, and fifth harmonics and why do they get weaker?" // Although not a satisfactory answer, you could accept the fact that any physically realizable continuous-time signal can be represented as an infinite sum of sinusoids (that's a Fourier series). Thus, any sinusoidal signal doesn't have harmonics, or it has, but only the fundamental component; and any periodic non-sinusoidal signal has harmonics, i.e. sinusoidal components whose frequency is an integer multiple of the fundamental frequency. - alejnavab
[+34] [2012-05-21 08:19:05] stevenvh [ACCEPTED]

Sinusoidal waves don't have harmonics because it's exactly sine waves which combined can construct other waveforms. The fundamental wave is a sine, so you don't need to add anything to make it the sinusoidal signal.

About the oscilloscope. Many signals have a large number of harmonics, some, like a square wave, in theory infinite.

enter image description here

This is a partial construction of a square wave. The blue sine which shows 1 period is the fundamental. Then there's the third harmonic (square waves don't have even harmonics), the purple one. Its amplitude is 1/3 of the fundamental, and you can see it's three times the fundamental's frequency, because it shows 3 periods. Same for the fifth harmonic (brown). Amplitude is 1/5 of the fundamental and it shows 5 periods. Adding these gives the green curve. This is not yet a good square wave, but you already see the steep edges, and the wavy horizontal line will ultimately become completely horizontal if we add more harmonics. So this is how you will see a square wave on the scope if only up to the fifth harmonic are shown. This is really the minimum, for a better reconstruction you'll need more harmonics.

Like every non-sinusoidal signal the AM modulated signal will create harmonics. Fourier proved that every repeating signal can be deconstructed into a fundamental (same frequency as the wave form), and harmonics which have frequencies that are multiples of the fundamental. It even applies to non-repeating waveforms. So even if you don't readily see what they would look like, the analysis is always possible.

enter image description here

This is a basic AM signal, and the modulated signal is the product of the carrier and the baseband signal. Now

\$ sin(f_C) \cdot sin(f_M) = \dfrac{cos(f_C - f_M) - cos(f_C + f_M)}{2} \$

So you can see that even a product of sines can be expressed as the sum of sines, that's both cosines (the harmonics can have their phase shifted, in this case by 90°). The frequencies \$(f_C - f_M)\$ and \$(f_C + f_M)\$ are the sidebands left and right of the carrier frequency \$f_C\$.

enter image description here

Even if your baseband signal is a more complex looking signal you can break the modulated signal apart in separate sines.


(1) "[...] on the scope if only up to the fifth harmonic are shown." - Why on earth are harmonics used to construct the form, and not "5V = high up, 0V = down", like an CRO moving the beam? Sure a square can be composed of many harmonics, but in real life a square wave is a square wave, and an oscilloscope will show that, it can be analysed in to harmonics to reconstruct it but that loses resolution if it cannot read all of those harmonics. For the AM: If there are many harmonics, they cannot integrate well (having so many "sines") and create these unwanted frequencies? - John Quinn
(9) @JohnQuinn, In real life a square wave is made up of spectral content as shown. Making a signal instantly change from 0V to 5V takes an infinite amount of power, in reality there is some rise time to the square wave and this determines the amount of spectral content required. High speed digital signals can be the devil for unwanted radiated transmission if allowed because the fast rise time means you are driving some very high frequencies. - Kortuk
(2) @JohnQuinn, Any signal that exists can be made up of sin waves, this is how we look at what the spectral content is of a signal(ie. The amount of which frequencies exist) and most circuits can be looked at as affecting frequencies differently. When I was acting as a teaching assistant I found most often teaching an understanding of frequency domain to be top 5 on things that allow an electrical engineer to be a great one. - Kortuk
(4) @John - Nobody composes the signal from harmonics, but the math says they're there. The frequency spectrum will be infinitely wide. If you pass such a signal through a low-pass filter it's shape will change because harmonics are cut off. The scope's limited bandwidth works as a low-pass filter. - stevenvh
(1) @stevenvh, and so viewing as many harmonics on top of eachother as possible (if the signal has them) will make for a clean signal on the scope? If I turn a switch on and off (gnd, DC5V, gnd, ...) will there be actual harmonics to capture (not just decomposing in to) and be clearer than some random square wave that is composed of many harmonics? came out of my mind weird, sort of makes sense. - John Quinn
(3) @John - Yes, it may look implausible, but if you switch on and off once per second that signal will have a 1Hz sine in it. And a 3Hz sine, etc. You can isolate each one of them by passing the square wave through a narrow band-pass filter. If you would filter 0.8Hz to 1.2Hz you would clearly see the 1Hz sine! It's all Fourier's fault, really! ;-) - stevenvh
@stevenvh Well I'll be, Spice agrees with you (hopefully not by coincidence). I've come up with a lot to carry on with here, thank you guys. :-) - John Quinn
(6) "because it's exactly sine waves which combined can construct other waveforms". Actually, you could use any other complete set of orthonormal waves as well (e.g. wavelets). The reason trigonometric functions / complex exponentials are most popular is that they're eigenvectors of the differential operator, which is why Fourier transform immediately solves linear differential equations. But if those weren't so important, some other transform would probably prevail. - leftaroundabout
(1) It's also worthwhile to note that your final illustration does not show AM (double sideband full power carrier) but rather double sideband suppressed carrier. In "true" AM, the carrier is at 50% of total (maximum) envelope power and the remaining 50% are distributed equally between the upper and lower sidebands. - user
(1) "Sinusoidal waves don't have harmonics because it's exactly sine waves which combined can construct other waveforms". Wrong. That's only true if the base functions used in the decomposition are sinusoidal themselves. The base functions need to be orthogonal, but there are infinite functions we can choose from. We can use square waves as the basis functions and, under that choice, pure sinusoidal functions would have inifinite frequency components. Wavelets is just another choice. - Telaclavo
@Telaclavo - "We can use square waves as the basis functions". That's correct, and I also commented on that on a previous question. Here I assumed sines, like everybody else would. - stevenvh
"every repeating signal can be deconstructed into a fundamental and harmonics" that's false and highly confusing. Surely there are two sines such that neither of them has the frequency that is an integer multiple of the other's, yet their sum will be periodic. - avakar
@avakar - Suppose you have a 3Hz sine and a 4Hz sine, so no integer multiples. Then the repeating wave will have a frequency of 1Hz (greatest common divider). That's the fundamental frequency of the sum, and the harmonics will be multiples of that. What do we have? A suppressed fundamental (amplitude zero), no second harmonic, a third harmonic and a fourth. Nothing else. "every repeating signal can be deconstructed into a fundamental and harmonics" still stands. Every harmonic has its own amplitude, and that can be zero. Look at the even harmonics in a square wave. - stevenvh
@stevenvh, I see, I didn't realize that a frequency would be called fundamental even though its amplitude is zero, though Wikipedia agrees. My apologies. - avakar
(1) @avakar - Say you have a 100Hz sawtooth wave. That has all harmonics: 100Hz, 200Hz, 300Hz, 400Hz, etc. If you would filter the fundamental out and would listen to the result you would still hear a 100Hz tone! That's because your brain "knows" 200Hz can't be the fundamental if you have also 300Hz and 500Hz, for instance. - stevenvh
@stevenvh There is something that relates the electronics to the sinusoidal waves as the basis functions. If I pass a 50Hz square wave through a 100 Hz RC low pass filter, what will I get at the output? Will I get the same square wave at the output? - 0xakhil
@oxakhil - A first order RC filter will not completely block the higher frequencies, just decrease them. The effect will be that the edges are less steep, and somewhat exponential. That's because of the time required to charge/discharge the capacitor via the resistor. - stevenvh
@stevenvh Make that a 10th order filter. I want to know if I will get that same square at the output or a square wave with its higher harmonics of frequencies greater than 100Hz blocked?? - 0xakhil
@AndrejaKo, I think we should talk more in chat if you want to discuss this, this comment chain has become too long. - Kortuk
@oxakhil - You'll only see a 50Hz sine, the 3rd harmonic is at 150Hz and that's already too far away. Remember the square wave doesn't have even harmonics, so the 100Hz harmonic doesn't exist. - stevenvh
1
[+27] [2012-05-21 08:17:31] clabacchio

Pentium100's answer is quite complete, but I'd like to give a much simpler (though less accurate) explanation.

The reason why sinewaves have (ideally) only one harmonic is because the sine is the "smoothest" periodic signal that you can have, and it's therefore the "best" in term of continuity, derivability and so on. For this reason it is convenient to express waveforms in terms of sinewaves (you can do it with other waves as well, as well as they are \$C^{\infty}\$, infinitely continuous and derivable).

Just an example: why do you usually see curved waves on water? (for the sake of the example, ignore the effects of the beach or wind) Again, it's because it's the shape that requires the least energy to form, since all the ramps are smooth.

In some cases, like the Hammond organ [1], sinewaves are actually used to compose the signal, because with decomposition is possible to synthesize a lot of (virtually all) sounds.

There is a beautiful animation by LucasVB [2] explaining the Fourier decomposition of a square wave:

These images explain better the square wave decomposition in harmonics:

enter image description here

enter image description here

[1] http://en.wikipedia.org/wiki/Hammond_organ
[2] https://en.wikipedia.org/wiki/User%3ALucasVB/Gallery

Your animation reminds Taylor series (physics.stackexchange.com/questions/226978/…) - Cloud Cho
2
[+18] [2012-05-21 07:56:48] Pentium100

You can decompose any waveform into an infinite series of sine waves added together. This is called Fourier analysis (if the original waveform is repeating) or Fourier transform (for any waveform).

In case of a repeating waveform (like a square wave), when you do Fourier analysis you find that all the sines that compose the waveform have frequencies that are an integer multiple of the frequency of the original waveform. These are called "harmonics".

A sine wave will only have one harmonic - the fundamental (well, it already is sine, so it is made up of one sine). Square wave will have an infinite series of odd harmonics (that is, to make a square wave out of sines you need to add sines of every odd multiple of the fundamental frequency).

The harmonics are generated by distorting the sine wave (though you can generate them separately).

Why is this important:

  1. You can make a sine wave out of any wave of a fixed frequency, as long as you have a filter that passes the fundamental frequency, but blocks 2x frequency (as you would be leaving only one harmonic in place).
  2. Actually, you can make a sine wave that has different frequency than the orginal - just use a bandpass filter to pass the harmonic you want. You can use this to get a sine wave of a frequency that is a multiple of the frequency of another sine - just distort the original sine and pick out the harmonic you want.
  3. RF systems have to put out waveforms that do not contain harmonics outside the allowed frequency range. This is how a PWM power supply (operating frequency ~100kHz, square wave) can interfere with FM radio (operating frequencies 88-108MHz, 11-12MHz (IF)).
  4. If you want to have a square wave with very fast rise/fall times, the bandwidth of your system will have to be much wider than the fundamental frequency of your square wave.

(2) I read it as "fudge has harmonics, because if you cram chocolate together with extreme force, the friction melts it in to fudge", why does it matter that sines can create squares, if all I am using is a square? Is it because rise time is not instantaneous that it matters that it is not "perfect" and is equivalent to xyz number of sine waves? I still do not get why outputting a 100kHz square wave in to space can generate other frequencies, 100kHz = 100k cycles per second, how on earth do electric fields start oscillating at harmonics? Grr! May need to read these over a few more times.. - John Quinn
(1) @JohnQuinn the explanation is quite accurate, but obviously it's not so simple...try to look wiki for Fourier transform/analysis - clabacchio
@JohnQuinn, because a square wave is many frequencies. A sine wave is the fundamental; to make other waveforms you need to add other sine waves. Pentium's answer explains how a square wave is made of odd harmonics of the fundamental. That is just what it is. - Rory Alsop
(1) @RoryAlsop, "because a square wave is many frequencies". A square wave is a single frequency of 0->1->0->1, in Fourier analysis maybe many sines, but it's just a single voltage going up and down at a specific rate at one frequency! What is theoretical and "real"? Am I really this clueless? - John Quinn
(1) @JohnQuinn, you are not clueless, the frequency domain is not something anyone is expected to instantly understand. Square waves are simple to understand because you can generate one from turning on and off a switch. I dislike telling someone you need a sum of sine waves to generate a signal, the signal is being generated by some means, in this case easily with a switch, but it can be decomposed into a set of sine waves and for many problems looking at it as a set of frequencies makes things much much easier. - Kortuk
@Kortuk, Lets see.. a square wave may have many harmonics riding it, and if placed in to an antenna will be serving those harmonics (at a different dc offsets so to speak) in to the air around it? Those odd harmonics are the frequencies thrown in to space? Filtering in to a sine wave will remove these allowing a clean transmission? My mind freezes at some concepts.. - John Quinn
@JohnQuinn, antenna could not care less about the dc offsets but a square wave into an antenna is kind of a worst case for extra radiation, but there I digress. The antenna is guaranteed to be frequency dependent with how well it radiates(if its not I have a business proposition for you) and each frequency being fed it will radiate relative to its input power and the efficiency of the antenna at the frequency. If you were to place a low pass filter(frequency dependent circuit) it would only allow the signals selected to make it to the antenna and radiate. - Kortuk
@JohnQuinn, you are correct, if we filter to a single wave then we can only radiate that wave, there is not power in existence for anything else. On that note, many antennas use length as a function of signal wavelength so using harmonics you are often going to hit other frequencies it is relatively efficient at radiating at. This is why I call it a worst case. I have a network analyzer at work which performs frequency sweeps at high frequency and I could really blow your mind with some of the circuits we have made for fun. Coax trap antenna anyone? - Kortuk
@Kortuk, I am glad I can clarify what is actually happening in both physics and math here. I found Steven's answers to be enlightening too and that helped a lot. - John Quinn
@JohnQuinn, His answers always are. The principal being used is superposition and depends on the system being linear and time-invariant. - Kortuk
(1) It may be worth noting that any wave may also be decomposed into a series of many other kinds of waves as well; sine waves are hardly unique in that regard. What makes sine waves unique is that if two sine waves are combined and fed into a linear circuit, the output resulting from the combination will match the sum of the outputs that would be produced from the individual waves, minus the output (typically a DC level) that would be produced with no input. Other kinds of wave shapes would generally add additional interactions. - supercat
For example, passing any sine wave through an RC filter will yield signal whose decomposition into sine waves has one of the original frequency and no other. One could easily compute the effect of passing that through a second filter. By contrast, passing a square wave through an RC filter would yield a signal whose decomposition into square waves would be enormously complex and hard to work with; computing the effects of pass that mess through a second filter would be enormously complex. - supercat
3
[+7] [2012-05-21 23:07:06] JRobert

The derivative - rate of change - of a sinusoid is another sinusoid at the same frequency, but phase-shifted. Real components - wires, antennas, capacitors - can follow the changes (of voltage, current, field-strength, etc.) of the derivatives as well as they can follow the original signal. The rates of change of the signal, of the rate-of-change of the signal, of the rate-of-change of the rate-of-change of the signal, etc., all exist and are finite.

The harmonics of a square wave exist because the rate of change (first derivative) of a square wave consists of very high, sudden peaks; infinitely high spikes, in the limit-case of a so-called perfect square wave. Real physical systems can't follow such high rates, so the signals get distorted. Capacitance and inductance simply limit their ability to respond rapidly, so they ring.

Just as a bell can neither be displace nor distorted at the speed with which it is struck, and so stores and releases energy (by vibrating) at slower rates, so a circuit doesn't respond at the rate with which it is struck by the spikes which are the edges of the square wave. It too rings or oscillates as the energy is dissipated.

One conceptual block may come from the concept of the harmonics being higher in frequency than the fundamental. What we call the frequency of the square wave is the number of transitions it makes per unit time. But go back to those derivatives - the rates of change the signal makes are huge compared to the rates of change in a sinusoid at that same frequency. Here is where we encounter the higher component frequencies: those high rates of change have the attributes of higher frequency sine waves. The high frequencies are implied by the high rates of change in the square (or other non-sinusoid) signal.

The fast rising edge is not typical of a sinusoid at frequency f, but of a much higher frequency sinusoid. The physical system follows it the best it can but being rate limited, responds much more to the lower frequency components than to the higher ones. So we slow humans see the larger amplitude, lower frequency responses and call that f!


"The fast rising edge is not typical of a sinusoid at frequency f, but of a much higher frequency sinusoid." That's not true. In the image in my answer you can see that all the sines have the same slope. It's the infinite sum of all these slopes which makes it infinitely steep. - stevenvh
But that's my point - the slope isn't typical of a sinusoid - Ok, I overqualified it above - at any 'f'. It is much higher, the essential point being that the physical system can't track the ROC accurately. - JRobert
I had the same question OP asked. I found your answer to be the best, no offense to others but the fact that we can represent square waves as an infinite sum of sinusoids is often the first thing that we learn when dealing with Fourier analysis, it is easy to understand that the more sinusoids you add the closer it gets to a perfect square wave. What isn't intuitive is exactly what OP asked. Are there harmonics in nature or is it just a mathematical tool to help us analyze a phenomenon? Unless you start thinking about rates of change, I don't think you can answer this question properly. - João Pedro
4
[+5] [2012-05-23 16:13:34] supercat

In practical terms, the reason harmonics "appear" is that linear filtering circuits (as well as many non-linear filtering circuits) which are designed to detect certain frequencies will perceive certain lower-frequency waveforms as being the frequencies they're interested in. To understand why, imagine a large spring with a very heavy weight which is attached to a handle via fairly loose spring. Pulling on the handle will not directly move the heavy weight very much, but the large spring and weight will have a certain resonant frequency, and if one moves the handle back and forth at that frequency, one can add energy to the large weight and spring, increasing the amplitude of oscillation until it's much larger than could be produced "directly" by pulling on the loose spring.

The most efficient way to transfer energy into the large spring is to pull in a smooth pattern corresponding to a sine wave--the same movement pattern as the large spring. Other movement patterns will work, however. If one moves the handle in other patterns, some of the energy that gets put into the spring-weight assembly during parts of the cycle will be taken out during others. As a simple example, suppose one simply jams the handle to the extreme ends of travel at a rate corresponding to the resonant frequency (equivalent to a square wave). Moving the handle from one end to the other just as the weight reaches end of travel will require a lot more work than would waiting for the weight to move back some first, but if one doesn't move the handle at that moment, the spring on the handle will be fighting the weight's attempt to return to center. Nonetheless, clearly moving the handle from one extreme position to the other would nonetheless work.

Suppose the weight takes one second to swing from left to right and another second to swing back. Now consider what happens if one moves the handle from one extreme of motion to the other has before, but lingers for three seconds on each side instead of one second. Each time one moves the handle from one extreme to the other, the weight and spring will have essentially the same position and velocity as they had two seconds earlier. Consequently, they will have about as much energy added to them as they would have two seconds before. On the other hand, the such additions of energy will only be happening a third as often as they would have when the "linger time" was only one second. Thus, moving the handle back and forth at 1/6Hz will add a third as much energy per minute (power) to the weight as would moving it back and forth at 1/2Hz. A similar thing happens if one moves the handle back and forth at 1/10Hz, but since the motions will be 1/5 as often as at 1/2Hz, the power will be 1/5.

Now suppose that instead of having the linger time be an odd-numbered multiple, one makes it an even-numbered multiple (e.g. two seconds). In that scenario, the position of the weight and spring for each left-to-right move will be the same as its position on the next right-to-left move. Consequently, if the handle adds any energy to the spring in the former, such energy will be essentially cancelled out by the latter. Consequently, the spring won't move.

If, instead of doing extreme motions with the handle, one moves it more smoothly, then at lower frequencies of handle motion there are apt to be more times when one is fighting the motion of the weight/spring combo. If one moves the handle in a sine-wave pattern, but at a frequency substantially different from the resonant frequency of the system, the energy that one transfers into the system when pushing the "right" way will be pretty well balanced by the energy taken out of the system pushing the "wrong" way. Other motion patterns which aren't as extreme as the square wave will, at at least some frequencies, transfer more energy into the system than is taken out.


5
[+1] [2013-11-23 03:44:02] jon

an even simpler analogy is to imagine a trampoline.

electrifying a conductor is analogous to stretching the trampoline membrane, doing so 'stretches' (distorts) energy fields linked to that wire.

go stand in the middle of the trampoline, reach down and grab the membrane of the trampoline floor. now stand up and pull/stretch it up as you go, so there is a peak about the height of your waist.

this has of course the effect of storing some energy in the membrane.

now if you just let it go, it will not simply float gently down and stop moving. it will snap down quickly and then VIBRATE... oscillating back and forth a bunch more times 'on its own' ... as it runs down its stored energy.

if instead you gradually lower it back into place... it cant violently snap anywhere and so nothing causes/allows it to vibrate 'on its own'. the only vibrating its doing is from you moving it.

all frequencies (of any waveform) have mathematical harmonics, waveforms with sudden potential changes provide an easier opportunity for these harmonics to be expressed as real world oscillations.


(1) You've provided an analogy about how things vibrate. Vibration doesn't necessarily lead to harmonics. A vibration can be a single tone. - Nick Alexeev
6
[+1] [2013-11-23 05:23:09] Felipe_Ribas

Just a complement to this question,

Are these harmonics irrelevant in things such as data transfer (high=1, low=0) and only matter in situations such as audio or RF?

that I think nobody said: It is not irrelevant. Usually we are interested in transmitting pulses in digital circuits so in most cases we don't take this wave phenomenology into consideration. This is because even though the square wave has its harmonics (not infinity number of harmonics in real world) so it will take some time to rise/fall, your circuitry design is usually "aware" of that. This is one of the greatest advantages of digital electronics/digital communication: from a given point (voltage) up, the signal is interpreted as 1 and from a given point down, it's 0. In most cases it does not really matter the precise format of the square wave since it meets certain time specifications.

But note that whether your square signal frequency rises up to a point where the wavelength is approximately in the order of magnitude of its transmission line (may be a conductive track of a PCB), then you may take this wave phenomenology into consideration. You still have a circuit in your hand but some wave phenomena may occur. So depending on your "line" impedance, some frequencies may have different propagation speed of other frequencies. Since the square wave is composed from many harmonics (or ideally infinity) you probably will have a distorted square wave in the end of your transmission line or conductive track (because each harmonic will travel with different speed).

A good example where this may happen is when we use USB data transmission in a circuit. Note that the data rate is very high (high frequency square waves) so you must take the impedance of your transmission line into consideration. Otherwise you probably will have problems in the communication.

In short, it all does matter and it all works together but is up to you to analyze whether these things are important in your project/analysis or not.


7