Square, Triangle & Other Waveforms
Also known as: duty cycle, sawtooth
13 min read
Quick Answer
Common waveforms are the repeating shapes an AC signal takes: sine, square, triangle, sawtooth and rectangular pulse. They can share a peak value and still differ in RMS value, harmonic content and average, so the shape has to be stated alongside the amplitude before any of those numbers mean anything.
Intuition
Same peak, different signal
A repeating electrical signal does not have to be a sine wave. Four or five shapes cover almost everything that turns up on a bench, and each comes from a different kind of source.
A sine rises and falls smoothly, with no corners anywhere. Rotating machinery produces it, and so does a well-behaved oscillator.
A square wave sits at one of two levels and flips between them as fast as the circuit can manage. Anything that switches makes one, from a clock line to a logic output toggling.
A triangle climbs at a steady rate, turns around at the top, and falls at the same steady rate. Feed a capacitor a constant current and this is what its voltage does, so triangles come out of ramp generators and out of the inductor current in a switching converter.
A sawtooth ramps up steadily and then drops back almost instantly, over and over. It swept the beam across an old television screen and it sweeps the frequency axis of a swept measurement.
A pulse train is a rectangular wave that spends unequal times high and low, so a short burst of voltage is followed by a long rest.
Set all of these to the same height on a scope and they are still not equivalent. A square wave sits at its full height for nearly all of the cycle; a narrow pulse sits at zero for nearly all of it. Connect each in turn to a small heater and the square wave will deliver several times as much warmth, even though both traces reach the same mark on the screen. The share of each cycle a waveform spends away from zero is what separates them.
Practitioner
Getting from peak to RMS
All of these shapes repeat, so each has a frequency and a period, and those two are reciprocals regardless of what the waveform looks like:
Amplitude is where the shape starts to matter. Peak and peak-to-peak are read straight off a scope and mean the same thing for any waveform. The RMS value does not. It is the steady DC voltage that would heat a resistor at the same rate, and the fraction of each cycle the waveform spends away from zero decides it.
A symmetrical square wave never leaves the peak except during its transitions, so its RMS value is its peak, with nothing to divide by. A sine is the familiar case of peak divided by the square root of two. A triangle, and equally a symmetrical sawtooth, spends most of the cycle well below the peak:
A pulse train switching between zero and a peak depends on nothing but the fraction of the cycle it spends high, its duty:
Worked example — Five shapes, one peak, one frequency
A generator is set to 5.0 V peak at 2.0 kHz, so one cycle lasts 500 µs whichever shape is selected.
The square wave's RMS value is the same 5.0 V. The sine comes out at 3.54 V, and the triangle and the sawtooth at 2.89 V.
Switch to a pulse train at a duty of 0.20 and the RMS value drops to 2.24 V, well under half the square wave's figure, from a trace that still touches the same peak line on the screen.
Which convention an instrument or a datasheet means is worth confirming every time. A scope reads peak and peak-to-peak directly and reports RMS only if asked, and only over the window it happens to be showing. A multimeter reports RMS, although what an inexpensive one measures is something else, covered further on. A function generator usually specifies its output in peak-to-peak, and often into a stated load, so the number on the front panel and the number on the screen can disagree honestly.
Picking a shape is as much a design decision as picking an amplitude. A sine tests linearity, since a linear circuit can change a sine's size and its timing but never its shape. A square tests speed: its edges carry the fast content, and whatever the circuit does to them shows up immediately. Ramps earn their place differently again, because any bend in a transfer characteristic appears as a visible kink in what should be a straight line.
Engineer
The mean of the square, shape by shape
RMS is defined by an operation, not by a shape: square the waveform at every instant, average those squares over a complete cycle, then take the square root of the average. RMS value develops the definition properly, and applying it to each shape is where the different divisors come from.
Because height counts quadratically, time spent near the extremes weighs far more than time spent near zero, and a waveform that loiters at zero is penalised twice over.
A square wave's squared value is one constant, the peak squared, at every instant apart from the transitions. Its average is that same constant, and the root of it is the peak. A squared sine averages to half the peak squared over a full cycle, leaving the root-two divisor. A triangle and a sawtooth both sweep linearly across the same range, and the average of the square of a linear sweep is one third of the peak squared, so root three follows for each of them. Their equality is not a coincidence: the order in which a ramp visits its values cannot change the average of their squares. A pulse train's squared value is the peak squared for a fraction D of the cycle and zero for the rest, which makes the average D times the peak squared, and the square root of D the entire correction.
Crest factor, the peak divided by the RMS value, condenses all of that into one number for how spiky a waveform is:
| Shape | Crest factor |
|---|---|
| Square | 1.0 |
| Sine | 1.41 |
| Triangle or sawtooth | 1.73 |
| Pulse train at duty 0.20 | 2.24 |
It is worth carrying around because amplifiers and converters are limited by the peak while their ratings are quoted in RMS. A signal with a high crest factor clips long before its RMS value looks alarming.
The word square covers two different waveforms, and the difference between them accounts for a good deal of confusion.
Worked example — Two waveforms both called square
A bipolar square wave swings symmetrically about zero, so its RMS value is its peak, 5.0 V.
A logic output does something else. It rests at zero and rises to the peak, spending a fraction 0.50 of each cycle high. Read as a pulse train, its RMS value is 3.54 V, and it also carries a steady component that the bipolar waveform does not have at all.
Shape decides the spectrum as well as the RMS value. A symmetrical square wave contains the fundamental and the odd harmonics only, with amplitudes falling in proportion to one over the harmonic number. A triangle also carries odd harmonics only, but they fall as one over that number squared, so it looks and sounds much softer. A sawtooth breaks the symmetry that suppresses even harmonics, so it carries every harmonic, falling as one over the number. Harmonics and the Fourier series take that apart.
Everything above describes waveforms that do not exist. The transitions are treated as instantaneous, the flat parts as perfectly flat and the ramps as perfectly straight, and no generator or circuit delivers any of that. A square wave with a finite rise time is really a trapezoid, and its RMS value falls a little below its peak by an amount set by how much of the cycle the edges occupy. A ramp built from an RC network is an exponential impersonating a line, straight only while the capacitor has barely begun to charge, which is the compromise passive RC integrators are built on. The idealised figures hold whenever the transitions are a small fraction of the period, and they stop holding as the repetition rate climbs toward the circuit's own speed limit.
Professional
Real edges and what meters make of them
An inexpensive multimeter does not compute an RMS value at all. It rectifies the input, averages what comes out, and multiplies by a single fixed constant known as the sine's form factor. The constant is chosen to make a sine read correctly, and the meter applies it to whatever it is shown.
Worked example — An averaging meter shown a square and a triangle
The scaling constant built into the meter is 1.11, correct for a sine and for nothing else.
Given the square wave, the meter averages a rectified signal that never leaves the peak, so it scales 5.0 V and displays 5.55 V, high by 11.1 %.
Given the triangle, it averages 2.5 V and displays 2.78 V, low by 3.8 % against the true 2.89 V.
A true-RMS instrument does the arithmetic instead of assuming the shape, and gets both of those right. It has limits of its own: a bandwidth above which fast content simply is not counted, and a maximum crest factor it can handle, often stated together with the portion of the range over which that limit applies. Show a true-RMS meter a very narrow pulse train and it will run out of one or the other. A multimeter datasheet states both.
Nothing generates a true square wave either. What leaves a real driver has a finite rise time, usually some overshoot, and often ringing behind the edge while the load's stray inductance and capacitance trade energy back and forth. Those edges, not the flat parts, are what a neighbouring circuit hears, because coupling depends on how fast a voltage or current changes, not on how far it swings. EMI and EMC covers the mechanisms; the practical consequence is that slowing an edge to the slowest the timing tolerates costs nothing and removes most of the problem.
Measuring a square wave takes bandwidth far above its repetition rate, since the corners are assembled from harmonics well up the spectrum. Displayed on an oscilloscope with too little bandwidth, a square arrives rounded and a fast edge arrives slower than it really was, and the trace gives no hint that the instrument, and not the circuit, produced the result.
Shapes come from identifiable places, and knowing the source tells you what its imperfections will be. A 555 astable charges and discharges a capacitor between two thresholds, so its timing node carries exponential segments while its output pin carries a rectangular pulse train whose duty follows from the resistor values. Replace the charging resistor with a constant-current source and the exponential straightens into a triangle. A traditional analog function generator starts from that triangle and works outwards: a diode shaping network rounds it into a sine, and a comparator squares it off. A modern instrument is more likely to synthesise samples digitally and reconstruct them, which changes the imperfections rather than removing them.
Duty becomes a control variable in its own right once the shape is rectangular, and duty cycle and PWM turns that into a method for delivering a chosen fraction of the available power. In the other direction, an op-amp asked to reproduce a square wave beyond its slew rate returns a trapezoid, and beyond that a triangle, since the output can only travel at one speed. When the output shape stops resembling the input shape, that limit is usually the reason.
Common mistakes
- Dividing every peak by 1.414 — the root-two factor belongs to the sine alone. A square wave's RMS value equals its peak, and a triangle's is its peak divided by the square root of three.
- Reading a non-sine waveform on an averaging multimeter — the calibration constant assumes a sine. Square waves read high, triangles read low, and on a chopped or heavily pulsed waveform the error has no simple bound.
- Quoting an amplitude without the shape — peak, peak-to-peak and RMS differ by factors that depend on the waveform, so a bare voltage figure for a non-sine signal is incomplete information.
- Treating a logic output as a bipolar square wave — it swings between zero and a rail instead of symmetrically about zero, which gives it a DC component and a lower RMS value than a bipolar wave of the same peak.
- Assuming a sawtooth and a triangle differ in RMS value — they sweep the same range linearly, so the average of their squares is identical. Their spectra differ; their RMS values do not.
- Sending a square wave down a bandwidth-limited path — the corners are built from high harmonics, and a cable or amplifier that cannot pass them hands back something rounded that is easily mistaken for a circuit fault.
Frequently asked questions
What is the RMS value of a square wave?
Its peak. The magnitude sits at the peak throughout the cycle apart from the transitions, so the mean of the square is the peak squared and its root is the peak itself. This applies to the symmetrical version that swings equally either side of zero.
Why do a triangle and a sawtooth have the same RMS value?
Both sweep linearly across the same range, and averaging the squared values does not depend on the order in which those values are visited. Their spectra are quite different, since the sawtooth lacks the symmetry that suppresses even harmonics.
Does frequency change a waveform's RMS value?
No. RMS is an average taken over one complete cycle, so it follows from the shape and the amplitude and not from how many cycles occur each second. Frequency decides what the circuit downstream does with the signal, not what the number is.
Which waveform has the highest crest factor?
Of the shapes here, the narrow pulse train. Crest factor is peak divided by RMS value, and a pulse that rests at zero for most of the cycle pairs a large peak with a small RMS value. The square wave sits at the other extreme, with a crest factor of one.
Why does a square wave cause more interference than a sine of the same size?
The edges. A square wave's corners are assembled from harmonics reaching far above its repetition rate, and coupling into a neighbouring circuit grows with how fast a voltage or current changes. Slowing the edges as far as the timing allows reduces the problem directly.