Introduction

Square waves have an interesting mix of practice and theory. In practice, they are extremely simple — an alternating sequence of high/low or 1's and 0's found in countless applications. In theory, however, they are somewhat difficult to analyze. This article derives the harmonic content rigorously using Laplace Transforms and explores practical applications including harmonic cancellation.

Square Wave Parameters

A general square wave is described by four parameters:

Parameterized square wave
v(t) t A τ φ T
A Amplitude  ·  φ Phase  ·  τ Pulse width  ·  T Period  ·  d = τ/T (duty cycle)

The first cycle expressed with unit step functions:

\[ v_0(t) = A\bigl[u(t-\phi) - u(t-\phi-\tau)\bigr], \quad 0 \le t < T \]

The full periodic wave: \(v(t) = \sum_{n=-\infty}^{\infty} v_0(t - nT)\)

Laplace Transform

The Laplace transform of a single cycle:

\[ \mathcal{L}[v_0(t)] = \frac{2A}{s}\,e^{-s(\phi+\tau/2)}\sinh\!\left(\frac{s\tau}{2}\right) \]

The full periodic square wave in the s-domain:

\[ V(s) = A\,e^{s(T/2-\phi-\tau/2)} \cdot \frac{\sinh(s\tau/2)}{s\sinh(sT/2)} \]

Fourier Series

The poles are at \(s = jn\frac{2\pi}{T}\) for \(n = 0, \pm1, \pm2, \ldots\) After applying L'Hôpital's rule, the residues (Fourier coefficients) are:

\[ R_n = \frac{\sin(n\pi d)}{n\pi}\,e^{-jn(2\pi/T)(\tau/2+\phi)}, \qquad R_0 = d \]

The final Fourier series expansion of the square wave:

\[ \boxed{v(t) = d + \sum_{n=1}^{\infty} \frac{\sin(n\pi d)}{n\pi} \cos\!\left[n\frac{2\pi}{T}\!\left(t - \frac{\tau}{2} - \phi\right)\right]} \]
Sanity check — 50% duty cycleFor d=1/2: sin(nπ/2)=0 for all even n → only odd harmonics are present, with amplitudes 1/(nπ). This matches the well-known result. ✓

Harmonic Spectrum

Harmonic spectrum — 50% duty cycle (d = 0.5)
|Rₙ| n 1 1/π 2 3 4 5 6 7 8 9 Even harmonics suppressed · Odd amplitudes ∝ 1/(nπ)

RC Filter Response

The transfer function of an RC low-pass filter is:

\[ H(s) = \frac{1/RC}{s + 1/RC} \]

The output in the time domain over one period:

\[ P_0(t) = A\cdot RC\left(1 - e^{-t/RC}\right)\bigl[u(t-\phi)-u(t-\phi-\tau)\bigr] - \left(K_1 + K_2 e^{-t/RC}\right)u(t) \]

where \(K_2 = d\) (DC level) and \(K_1\) captures the transient behavior.

Harmonic Cancellation

A single pulse per period suppresses the n-th harmonic when:

\[ \sin(n\pi d) = 0 \;\Rightarrow\; d = k/n, \quad k = 1,\ldots,n-1 \]

For multiple harmonic cancellation, use M equal slots per period. The m-th pulse has Fourier coefficient:

\[ R_{n,m} = \frac{\sin(n\pi/M)}{n\pi}\,e^{-jn\pi(1+2m)/M} \]

Two pulses at positions \(m_1\) and \(m_2\) cancel the n-th harmonic when:

\[ \boxed{(-m_1 + m_2 + M/2n) \equiv 0 \pmod{M/n}} \]

This requires M even and n dividing M/2. Minimum M values to cancel up to the n-th harmonic:

n (highest cancelled)23456789
Minimum M412241201208408402520

Phasor Diagram

Each pulse position m corresponds to a phasor \(e^{-jn\pi m/6}\). Two pulses cancel a harmonic when their phasors are exactly 180° apart:

Phasor diagram — M=12, n=1 (fundamental)
+j +1 0 1 2 3 4 5 6 7 8 9 10 11 cancel!
Positions 0 and 6 are 180° apart — their phasors cancel the fundamental.