When you are debugging an EMI issue on a buck converter, sizing an LC filter, or trying to figure out why your true-RMS multimeter reads a bizarre voltage on an ESP32 PWM pin, you need the exact math. The formula for a square wave depends entirely on whether you are synthesizing it in the frequency domain or measuring its power in the time domain.
In the frequency domain, the Fourier series formula for an ideal bipolar square wave is V(t) = (4Vp / π) × ∑ [sin(2πnft) / n] for odd harmonics. For practical DC and RMS bench measurements of a unipolar pulse wave, the time-domain formula is VRMS = Vp × √D. Below, we break down every symbol, map out real-world harmonic magnitudes, and walk through bench-ready calculations with strict unit tracking.
The Core Formulas and Symbol Definitions
A square wave is not a single frequency; it is an infinite sum of sine waves. The Fourier series formula reconstructs the time-domain voltage V(t) by summing the fundamental frequency and its odd harmonics. Conversely, when you are measuring power delivery (like a PWM signal driving a heater or motor), you use the RMS formula based on the duty cycle.
| Symbol | Definition | Standard Unit | Notes & Bench Context |
|---|---|---|---|
| V(t) | Instantaneous voltage at time t | Volts (V) | The reconstructed waveform value at a specific microsecond. |
| Vp | Peak voltage amplitude | Volts (V) | Maximum deviation from zero. Not peak-to-peak (Vpp). |
| n | Harmonic number | Unitless (Integer) | Only odd integers (1, 3, 5, 7...) exist in an ideal symmetrical square wave. |
| f | Fundamental frequency | Hertz (Hz) | The base switching frequency or clock rate. |
| t | Time | Seconds (s) | Often measured in μs or ns on the bench. |
| π | Pi (mathematical constant) | Unitless | Approx 3.14159. Critical for the amplitude scaling factor (4/π ≈ 1.273). |
| VRMS | Root Mean Square voltage | Volts (V) | The equivalent DC heating value of the waveform. |
| D | Duty cycle | Unitless (Decimal) | Expressed as 0.0 to 1.0 (e.g., 50% = 0.5). Do not use 0-100 in the formula. |
Real-World Harmonic Magnitudes (Data Table)
The Fourier formula tells us that the amplitude of each harmonic drops off at a rate of 1/n. This is why square waves are notorious for causing Electromagnetic Interference (EMI); the high-frequency harmonics extend far beyond the fundamental clock speed. According to Wolfram MathWorld's Fourier derivations, the amplitude of the nth harmonic is exactly (4Vp) / (nπ).
Below is a data-dense breakdown for a standard 5V peak (10Vpp), 10 kHz square wave, typical of a microcontroller clock or a low-frequency SMPS switching node.
| Harmonic (n) | Frequency (Hz) | Multiplier (4 / nπ) | Peak Voltage (V) | Attenuation vs Fundamental |
|---|---|---|---|---|
| 1 (Fundamental) | 10,000 | 1.2732 | 6.366 V | 0 dB (Reference) |
| 3 | 30,000 | 0.4244 | 2.122 V | -9.54 dB |
| 5 | 50,000 | 0.2546 | 1.273 V | -13.98 dB |
| 7 | 70,000 | 0.1819 | 0.909 V | -16.90 dB |
| 9 | 90,000 | 0.1415 | 0.707 V | -19.08 dB |
| 11 | 110,000 | 0.1157 | 0.579 V | -20.83 dB |
Bench Insight: Notice that the fundamental frequency (10 kHz) actually has a peak voltage of 6.366 V, which is higher than the 5V peak of the square wave itself. This is a quirk of Fourier synthesis; the sine waves must overshoot to create the flat top and sharp corners of the square wave, a mathematical artifact known as the Gibbs phenomenon.
Rearranged Forms for the Bench
On the workbench, you rarely need to calculate V(t) from scratch. Instead, you are usually reverse-engineering a parameter from a multimeter reading or an FFT scope capture. Here are the rearranged forms of the core formulas:
RMS and Duty Cycle Rearrangements (Unipolar Waves)
- Solve for Peak Voltage:
Vp = VRMS / √D
Use when: You measure the RMS voltage with a Fluke 87V and know the PWM duty cycle, but need to verify the logic-high voltage level. - Solve for Duty Cycle:
D = (VRMS / Vp)2
Use when: You know the supply voltage and the measured RMS voltage, and need to determine the actual duty cycle hitting the load.
Fourier Series Rearrangements (Frequency Domain)
- Solve for Fundamental Frequency:
f = fn / n
Use when: Your spectrum analyzer shows a massive EMI spike at 150 MHz, and you suspect it is the 3rd harmonic of a 50 MHz clock. - Solve for Peak Voltage from Harmonic:
Vp = (Vn × n × π) / 4
Use when: You can only cleanly measure the fundamental sine component on a scope and need to deduce the original square wave amplitude.
Worked Problems with Unit Tracking
Let’s apply these formulas to two common scenarios. We will track units at every step to prevent the scaling errors that routinely ruin prototype designs.
Problem 1: Sizing a Heater Load via PWM RMS
Scenario: You are using an ESP32 to drive a 12V DC heating element via a logic-level MOSFET. The ESP32 outputs a 3.3V PWM signal to the MOSFET gate. You set the duty cycle to 40% (0.40) to limit power. What is the effective RMS voltage applied to the gate, and does it exceed the MOSFET’s VGS(th) threshold of 2.5V?
- Identify the formula:
VRMS = Vp × √D - Substitute values:
Vp = 3.3 V,D = 0.40(unitless decimal) - Calculate the root:
√0.40 ≈ 0.6324(unitless) - Multiply and track units:
3.3 [V] × 0.6324 [unitless] = 2.087 [V]
Result: The RMS voltage is 2.087 V. Because this is below the 2.5V threshold, the MOSFET will barely turn on, leading to high RDS(on) and thermal failure. Fix: Increase duty cycle or use a gate driver to boost Vp to 10V.
Problem 2: EMI Filter Sizing for a Buck Converter
Scenario: A 48V DC-DC buck converter switches at a fundamental frequency of 100 kHz. You are designing an input LC filter and need to know the exact peak voltage amplitude of the 5th harmonic to ensure your capacitor’s ripple current rating isn’t exceeded.
- Identify the formula: The amplitude of the nth harmonic is
Vn = (4 × Vp) / (n × π) - Substitute values:
Vp = 48 V,n = 5(unitless),π ≈ 3.14159(unitless) - Calculate numerator:
4 × 48 [V] = 192 [V] - Calculate denominator:
5 × 3.14159 = 15.70795(unitless) - Divide and track units:
192 [V] / 15.70795 [unitless] = 12.223 [V]
Result: The 5th harmonic (at 500 kHz) has a peak voltage of 12.22 V. When selecting your input bypass capacitor, ensure its AC ripple current rating can handle a 12.22V peak sine wave at 500 kHz, not just the DC bus voltage.
Assumptions, Unit Traps, and Realistic Magnitudes
The formulas above are mathematically perfect, but the bench is not a math textbook. Understanding where the formulas break down is what separates a textbook student from a competent engineer.
When the Formula Applies (and When It Doesn’t)
The Fourier series formula assumes an ideal square wave with instantaneous rise and fall times (infinite dv/dt) and perfectly symmetrical 50% duty cycles. In reality, every physical square wave has a finite rise time dictated by parasitic capacitance and driver impedance. According to Analog Devices Tutorial MT-015, as the rise time slows down, the high-frequency harmonics roll off much faster than the 1/n rate predicted by the ideal formula. If your scope shows a trapezoidal wave rather than a square one, the Fourier formula will overestimate your high-frequency EMI.
The RMS formula (VRMS = Vp × √D) applies strictly to unipolar waves (swinging from 0V to +V). If you are measuring a bipolar square wave (swinging from -V to +V, like an audio amplifier output or an H-bridge motor drive), the duty cycle doesn’t matter for RMS; the RMS voltage is simply equal to the peak voltage (VRMS = Vp).
Unit Mistakes That Will Break Your Math
⚠ Radians vs. Degrees: The term
2πnft in the sine function is calculated in radians. If your calculator or math software is set to degrees, the sine wave will be completely distorted, and your time-domain reconstruction will fail.
⚠ Duty Cycle Percentage: In the RMS formula, D must be a decimal (0.0 to 1.0). Plugging in "50" instead of "0.5" will result in an RMS voltage 7 times higher than reality, leading to catastrophic load overvoltage if used for power supply design.
What a Realistic Answer Magnitude Looks Like
If you measure a standard 5V logic square wave (0V to 5V, 50% duty cycle) with a true-RMS multimeter, you should expect to read exactly 3.53 V (since 5 × √0.5 = 3.535). If your meter reads 2.5V, you are likely using an average-responding meter that is incorrectly scaling the waveform, or the signal has significant ringing that is confusing the meter’s ADC. If you are looking at the FFT on a scope, the fundamental sine component of that same 5V wave should peak at 6.36 V. If your scope FFT shows the fundamental at 5V, the scope is likely displaying RMS values in the frequency domain rather than peak values.






