DSPRelated.com

Frequency Domain

Category: Fundamentals

The frequency domain is a representation of a signal in terms of its constituent complex spectral components (capturing both amplitude and phase at each frequency), as opposed to how the signal's amplitude varies over time. Transforming a signal into the frequency domain reveals spectral content that is often difficult or impossible to see in the time domain.

In practice

In embedded signal processing, the frequency domain is most commonly accessed via the Discrete Fourier Transform (DFT), typically computed efficiently using an FFT algorithm. The result is a set of complex-valued bins, each corresponding to a specific frequency; the magnitude of each bin indicates how strongly that frequency is present in the signal. On Cortex-M4/M7 class MCUs with a hardware FPU and CMSIS-DSP, a 256-point real FFT can complete in under a millisecond at typical clock speeds with optimized library builds, making on-device spectral analysis practical for applications such as motor diagnostics, vibration monitoring, and audio processing.

A key concept when working in the frequency domain on discrete systems is that the spectrum of a sampled signal is periodic, repeating at multiples of the sample rate (a consequence of the way sampling replicates the baseband spectrum at each harmonic of Fs). This means frequency components above the Nyquist frequency (half the sample rate) fold back ("alias") into the baseband spectrum. Anti-aliasing filters placed before the ADC are the standard countermeasure. The blog post "Demonstrating the Periodic Spectrum of a Sampled Signal Using the DFT" illustrates this periodicity directly.

Interpreting DFT output correctly requires understanding bin spacing and resolution. For a DFT of N points taken at sample rate Fs, each bin represents a frequency resolution of Fs/N Hz. A tone that does not fall exactly on a bin boundary causes spectral leakage, spreading energy across adjacent bins. Windowing functions (Hann, Blackman, flat-top, etc.) are applied to the time-domain data before the DFT to reduce leakage at the cost of slightly widened main lobes. "DFT Bin Value Formulas for Pure Real Tones" provides exact amplitude formulas useful for calibration and testing.

Common pitfalls in embedded frequency-domain work include ignoring the DC bin (bin 0) when computing power, confusing one-sided and two-sided spectra, and forgetting that fixed-point FFT implementations accumulate rounding error that tends to grow with the number of stages (roughly log2(N) for a radix-2 FFT, though the exact growth depends on scaling strategy, data range, and implementation details). When precise instantaneous frequency is needed between bins, interpolation techniques described in "Exact Near Instantaneous Frequency Formulas Best at Peaks (Part 1)" can substantially outperform naive peak-bin detection.

 Learn this in DSP Foundations

Discussed on DSPRelated

Frequently asked

How do I convert a time-domain signal to the frequency domain on an MCU?
The most common approach is to collect N time-domain samples into a buffer and then apply an FFT. Libraries such as CMSIS-DSP (arm_rfft_fast_f32 for Cortex-M) and Kiss FFT (portable C, suitable for any MCU with enough RAM) provide ready-to-use implementations. For a real-valued input, only N/2+1 bins carry unique information; the exact format of the output (interleaved complex, split real/imag arrays, packed, etc.) varies by library. Compute the magnitude of each bin (sqrt of real^2 + imag^2, or an approximation) to get the amplitude spectrum.
What is spectral leakage and how do I reduce it?
Leakage occurs when a signal's frequency does not fall exactly on a DFT bin. The DFT implicitly assumes the captured block repeats periodically; a tone that is not a whole number of cycles within the block creates discontinuities at the block edges, spreading energy into neighboring bins. Applying a window function (Hann, Hamming, Blackman, flat-top, etc.) to the time-domain samples before the FFT tapers the edges toward zero and significantly reduces leakage, at the cost of a slightly wider main lobe.
What is frequency resolution and how do I improve it?
Frequency resolution is Fs/N, where Fs is the sample rate and N is the number of points in the DFT. To improve resolution (get smaller Fs/N), you can increase N (collect more samples), decrease Fs (sample more slowly, though this also reduces the maximum detectable frequency), or use zero-padding -- appending zeros to the buffer before the FFT -- which interpolates the spectrum but does not add new information about signal content.
Why does my FFT output appear mirrored around the midpoint?
For a real-valued input signal, the DFT output is conjugate-symmetric: the second half of the N output bins mirrors the first half. This is mathematically expected and not an error. In practice, only the first N/2+1 bins (from DC up to Fs/2, the Nyquist frequency) carry unique information. Many FFT libraries provide a 'real FFT' variant that computes and returns only these unique bins, saving roughly half the computation and memory.
How does the frequency domain relate to filtering in embedded systems?
Filtering can be understood as shaping the frequency-domain representation of a signal: a low-pass filter attenuates high-frequency bins, a band-pass filter retains only a specific range, and so on. In practice, embedded filters are usually implemented in the time domain using FIR or IIR difference equations (which are computationally cheaper for short filters), but block-based frequency-domain convolution using the overlap-add or overlap-save method can be more efficient when filter kernels are long (typically hundreds of taps or more).

Differentiators vs similar concepts

The frequency domain is often contrasted with the time domain, where a signal is represented as amplitude versus time. Neither is inherently more "correct"; they contain the same information, just arranged differently. The frequency domain is also distinct from the Laplace domain (s-domain) and Z-domain used in control theory and discrete filter design: those representations generalize frequency response to complex exponentials across the full s-plane or z-plane, and the familiar frequency response is obtained as a special case by evaluating them on the jω axis or unit circle, respectively. In a practical embedded workflow, however, the frequency domain is accessed directly through sampled data and the DFT/FFT rather than through those analytical tools.