# FFT of square wave - what does output represent?

I am really new to FFT and signal processing. I am doing an analysis of square waves with FFT and I am trying to understand why the FFT output on the frequency domain has a downward slope for square waves. Specifically:

1. Why in FFT output for a square wave, bin 0 has the highest amplitude and bin 1 has the second highest amplitudes no matter what the original frequency of the input signal in the time series domain representation is.
2. I read that bin 0 has to do with the ADC and that is the sum of the whole signal and that is why it is 0Hz. What does that mean?
3. What does amplitude represent in FFT output like below?

• Related Apr 26, 2021 at 19:47

Simply put, a square wave can be decomposed into a weighted summation of series of sine waves, which is exactly what the Fourier transform does. Here are two animations that describe the synthesis of a square wave by accumulating sine waves.

The amplitude of FFT results are the weights of each sine waves. As seen in Fig.1, the first order harmonic has the largest weights, that's why the first bin has the highest amplitude, and the following bins have decreasing amplitudes.

An ideal square wave with an amplitude of 1 can be represented as Fourier expansion:

$$x(t) = \mathrm{sgn}(\sin\omega t) = \frac{4}{\pi} \Big( \sin\omega t + \frac{1}{3} \sin 3\omega t + \frac{1}{5} \sin 5\omega t + \ldots \Big)$$

The above equation shows that the ideal square wave contains only components of odd harmonics and their amplitudes are decreasing. However, in real world square waves contain all integer harmonics.

Bin 0 represents DC (direct current, i.e., 0 Hz). Since your square wave has a zero mean, the DC components is zero as well. Try to add a constant value to the original square wave, then take FFT and see what happens.

• For amplitude, does the first order harmonic always have the largest weight or does it depend on the input signal? All of the examples of FFT of square waves show that the first order harmonic has the most weight and I wanted to know why
– Sam
Apr 26, 2021 at 13:20
• @Sam please see edit. Apr 27, 2021 at 1:24

From the title of the graph, it is seen that it is a 1Hz square wave and hence so your DFFT has a high magnitude in the initial bin (bin holding your 1Hz frequency component). Also, to be sure, perform FFT on another signal generated at a different frequency to check if that's the case.

In analog signals, it is not always mandatory that the first harmonic has high power. Several other factors contribute too.