Harmonics are frequency components in a signal at integer multiples of a fundamental frequency. In embedded signal processing, they appear in the output of oscillators, ADCs, DACs, and PWM generators, and can indicate either intentional signal content or distortion introduced by nonlinearity or quantization.
In practice
When a DAC or ADC processes a periodic signal at frequency f₀, nonlinearities in the converter, amplifier, or analog front end typically produce spurious tones at 2f₀, 3f₀, 4f₀, and so on. These are harmonic distortion products. Depending on converter architecture, operating region, reference quality, and input frequency, second and third harmonics are often among the dominant distortion products, and datasheets report them as THD (Total Harmonic Distortion) in percent or dB, or as individual harmonic levels in dBc or dBFS. The post "Find Aliased ADC or DAC Harmonics (with animation)" illustrates how harmonics above the Nyquist frequency alias back into the baseband, making them appear as unexpected tones at frequencies that are not obvious integer multiples of the input.
PWM signals are a common source of deliberate harmonics in embedded systems. A PWM signal's harmonic content depends on its duty cycle: a 50% duty-cycle square wave contains energy only at odd harmonics (f₀, 3f₀, 5f₀, ...) with amplitudes that fall off as 1/n, while duty cycles away from 50% also introduce even harmonics. Motor drives, class-D amplifiers, and switching power supplies all rely on low-pass filtering to suppress these harmonics before they reach the load. Insufficient filtering or layout parasitics can cause harmonics to radiate as EMI or couple into sensitive analog circuitry on the same board.
In audio and vibration applications, harmonics carry useful information. A missing fundamental -- where the lowest-frequency harmonic is absent but higher-order ones remain -- can still allow pitch reconstruction, a psychoacoustic phenomenon discussed in the post "Autocorrelation and the case of the missing fundamental." Detecting and tracking harmonics in real time on constrained MCUs is a common DSP task, often implemented with FFT-based peak detection or autocorrelation rather than a bank of narrowband filters.
Harmonic suppression is sometimes addressed with notch filters tuned to specific harmonic frequencies. The post "Harmonic Notch Filter" covers one implementation approach. Care is needed because a notch filter aggressive enough to suppress a harmonic can also distort the phase response near the fundamental, which matters in control loops and audio codecs.
Learn this in DSP Foundations
Discussed on DSPRelated
Frequently asked
How do I tell whether a spurious tone in my FFT output is a harmonic or an alias?
Check whether the tone appears at an integer multiple of your fundamental frequency. If it does, it is likely a harmonic (or a harmonic that has aliased). To distinguish a true in-band harmonic from an aliased one, change the
sample rate slightly and observe whether the tone moves in frequency relative to the fundamental. An aliased harmonic will shift in absolute frequency because its alias location depends on the sample rate, while a true in-band harmonic tracks the fundamental and will remain at the same integer-multiple relationship to it. The post 'Find Aliased
ADC or
DAC Harmonics (with animation)' walks through this process with examples.
Why does a square wave contain only odd harmonics?
A square wave with 50% duty cycle has half-wave symmetry: the negative half-cycle is an exact mirror of the positive half-cycle. This symmetry causes all even-order Fourier coefficients to cancel, leaving only odd harmonics (f₀, 3f₀, 5f₀, ...). Changing the duty cycle away from 50% breaks this symmetry and introduces even harmonics. PWM signals in motor control and power conversion are often not at 50% duty, so both odd and even harmonics are present.
What is THD and how is it measured on an embedded system?
Total Harmonic Distortion (THD) is the ratio of the RMS sum of all harmonic distortion products to the RMS amplitude of the fundamental, usually expressed in percent or dB. To measure it on an embedded system, generate a clean sine wave input (or use an external source), capture samples with the
ADC, compute an
FFT, identify the fundamental and harmonic bins, and calculate the ratio. Accuracy depends heavily on FFT length, windowing choice, and the quality of the test signal source. Many ADC and
DAC datasheets provide THD figures at specific input frequencies and amplitudes as a starting baseline.
Can harmonics be useful rather than just a noise problem?
Yes. In vibration monitoring and motor fault detection, the pattern of harmonics in a vibration spectrum is a diagnostic signature -- bearing faults, rotor imbalance, and gear mesh problems each produce characteristic harmonic families. In audio, the balance of harmonics shapes timbre. In power electronics, intentional injection of third-harmonic components into three-phase PWM references (third-harmonic injection) allows higher modulation depth without overmodulation. The post 'In Search of The Fourth Wave' explores waveform synthesis and how harmonic content defines wave shape.
How does quantization noise relate to harmonics?
Quantization noise and harmonic distortion are distinct phenomena. Quantization noise results from rounding a continuous signal to discrete levels and is spread across the spectrum (approximately white for high-resolution, dithered converters). Harmonic distortion comes from nonlinear transfer characteristics -- integral nonlinearity (INL) in a converter is a primary cause. At low signal levels or with poor INL, the quantization error becomes correlated with the input signal and can appear as harmonic-like tones rather than broadband noise, blurring the boundary between the two.
Differentiators vs similar concepts
Harmonics are integer multiples of a fundamental frequency and arise from periodicity and nonlinearity. Intermodulation distortion (IMD) products, by contrast, appear at sum and difference frequencies of two or more input tones (e.g., f₁ + f₂, 2f₁ - f₂) and are produced by the same nonlinear mechanisms. Subharmonics are frequencies at integer fractions of the fundamental (f₀/2, f₀/3) and appear in some nonlinear systems such as period-doubling oscillators or parametric resonance, but are not the same as harmonics. Spurs is a broader informal term covering any spurious spectral tone, including harmonics, aliases, and clock feed-through, but it is not synonymous with harmonics specifically.