Square Wave
The complete guide to the square wave — the two-level ON/OFF waveform at the heart of digital electronics and switching power. From its duty cycle and odd-harmonic Fourier series to its RMS value and how it differs from a sine wave.
Complete Learning Path — Square Wave
From the anatomy of a square wave and its duty cycle, through its odd harmonics and spectrum, to its values, sine comparison and real applications
What is a Square Wave?
A square wave is a two-level, ON/OFF waveform that jumps almost instantly between a high value and a low value, staying flat at each. It is the most important non-sinusoidal waveform in electronics — the shape of clocks, digital signals and switching circuits.
Unlike a smooth sine wave, the square wave has sharp vertical edges and flat tops. It is still periodic, so it has the same basic parts: an amplitude Vm, a period T, and a frequency f = 1/T — plus one new property all its own: the duty cycle.
Symmetric, unipolar & bipolar
A symmetric square wave is high and low for equal times (50% duty). A bipolar square swings between +Vm and −Vm; a unipolar (digital) one switches between 0 and Vm.
Duty Cycle: D = ton / T
The duty cycle is the fraction of each period the wave spends high. It is the square wave’s signature property and the key to pulse-width modulation.
D = ton / T × 100%
Duty cycle — the percentage of each period the signal is high (also called the mark-space ratio)
Worked example
A signal is high for 2 ms and low for 6 ms, so T = 8 ms:
D = 2/8 × 100% = 25%, and the frequency is f = 1/8ms = 125 Hz.
Duty cycle carries information — PWM
By varying only the duty cycle at a fixed frequency, pulse-width modulation (PWM) controls average voltage — used to dim LEDs, drive motors and run switching power supplies. Try the SPWM Duty-Cycle Calculator.
A Square Wave = Sum of Odd Harmonics
Here is the deep truth: a square wave is really many sine waves added together — a fundamental plus its odd harmonics. This is Fourier synthesis.
v(t) = (4Vm/π) [ sinωt + ⅓ sin3ωt + ⅕ sin5ωt + … ]
Fourier series of a symmetric square wave — odd harmonics only, amplitudes falling as 1/n
The Gibbs overshoot
Notice the little ripples near each edge. Adding finite harmonics always leaves a small overshoot at the jumps — the Gibbs phenomenon. It shrinks in width but never fully vanishes.
The Harmonic Spectrum
Plot those harmonics by frequency and you get the square wave’s spectrum — a comb of odd harmonics that fade as 1/n.
| Harmonic | Frequency | Relative amplitude |
|---|---|---|
| Fundamental (1st) | f | 1 |
| 3rd | 3f | 1/3 (≈ 0.33) |
| 5th | 5f | 1/5 (0.20) |
| 7th | 7f | 1/7 (≈ 0.14) |
| Even (2f, 4f…) | — | 0 (absent) |
Because the energy reaches to very high harmonics, keeping a square wave’s shape needs a wide bandwidth — the reason fast digital edges demand fast circuits.
RMS, Average, Form & Crest Factor
The square wave’s flat tops make its RMS maths beautifully simple — and strikingly different from a sine.
Symmetric: Vrms = Vm · Unipolar (duty D): Vrms = Vm√D, Vavg = D·Vm
RMS and average of square waves — symmetric bipolar vs unipolar (0 to Vm)
| Quantity | Square (symmetric) | Sine (for comparison) |
|---|---|---|
| RMS | Vm | 0.707 Vm |
| Form factor (RMS/avg) | 1.00 | 1.11 |
| Crest factor (peak/RMS) | 1.00 | 1.414 |
| Harmonics | Odd only | None (pure) |
Worked example — digital signal
A 0–5 V digital clock at 50% duty:
Vavg = 0.5 × 5 = 2.5 V and Vrms = 5√0.5 ≈ 3.54 V.
Square Wave vs Sine Wave
Same amplitude, same frequency — completely different signals. The contrast explains a lot of electronics.
Why inverters quote “pure sine”
A cheap inverter outputs a square or “modified sine” wave, full of harmonics that heat motors and disturb electronics. A pure sine inverter filters those harmonics away — which is why it costs more and runs sensitive loads better.
How Square Waves Are Generated & Used
Square waves are everywhere a circuit switches between two states.
Digital clocks & logic
Every processor and logic circuit is timed by a square clock signal switching between 0 and VCC.
PWM control
Varying duty cycle controls LED brightness, motor speed and supply voltage. See the SPWM Calculator.
555 timers & oscillators
Astable multivibrators and 555 timers generate square waves at a chosen frequency and duty.
Inverters & converters
Switching devices chop DC into square or modified-sine AC in inverters and converters.
Test signals
A square wave’s rich harmonics test an amplifier’s bandwidth, rise time and ringing at a glance.
Sound & synthesis
The hollow, buzzy tone of a square wave is a staple of synthesizers and buzzers.
Key Terms at a Glance
The essential square-wave vocabulary students and engineers search for.
Square wave
Two-level ON/OFF periodic waveform.
Duty cycle
D = ton/T; % of period high.
Mark-space ratio
High time : low time.
Odd harmonics
f, 3f, 5f, 7f… only.
Fourier series
(4Vm/π)Σ(1/n)sin(nωt).
Gibbs phenomenon
Overshoot ripple at the edges.
RMS (symmetric)
Vrms = Vm.
PWM
Control by varying duty cycle.
Frequently Asked Questions
Quick, expert answers to the questions people ask most about square waves.
What is a square wave in simple words?
It is a signal that flips back and forth between two levels — high and low — staying flat at each and switching almost instantly. It looks like a row of rectangles and is the basic shape of digital and switching signals.
What is the duty cycle of a square wave?
It is the share of each period that the wave is high: D = ton/T, given as a percent. A 50% duty cycle means equal high and low times (a true symmetric square). Varying it is how PWM works.
What harmonics does a square wave have?
Only odd harmonics: the fundamental, 3rd, 5th, 7th… with amplitude falling as 1/n. There are no even harmonics. That mix of odd harmonics is what gives the square its shape.
What is the Fourier series of a square wave?
v(t) = (4Vm/π)[sinωt + ⅓sin3ωt + ⅕sin5ωt + …] — the fundamental plus odd harmonics, each scaled by 1/n.
What is the RMS value of a square wave?
For a symmetric ±Vm square wave, Vrms = Vm (equal to the peak), so the form factor and crest factor are both 1. For a unipolar 0–Vm wave of duty D, Vrms = Vm√D.
How is a square wave different from a sine wave?
A sine wave is smooth and has one frequency. A square wave has sharp edges and is a fundamental plus many odd harmonics, so it needs a wide bandwidth to keep its shape.
How do you generate a square wave?
By switching a voltage between two levels — with a 555 timer, an astable multivibrator, a comparator with feedback, a microcontroller pin, or the switches in an inverter. The switching rate sets the frequency.
Why do square waves matter for digital and power electronics?
They represent the two logic states (0 and 1), clock every digital chip, and — via duty-cycle control (PWM) — let switching converters and inverters set average voltage efficiently.
Conclusion & Key Takeaways
The square wave is the ON/OFF workhorse of electronics — simple in shape, rich in harmonics, and central to digital and switching circuits.
Two-level waveform
Switches high/low.
Duty cycle D = ton/T
Basis of PWM.
Odd harmonics
f, 3f, 5f… as 1/n.
Vrms = Vm
Symmetric square.
Wide bandwidth
Sharp edges need it.
Digital & power
Clocks, PWM, inverters.