A square wave is a
non-sinusoidal periodic waveform in which the amplitude alternates at a steady
frequency
Frequency is the number of occurrences of a repeating event per unit of time. It is also occasionally referred to as ''temporal frequency'' for clarity, and is distinct from ''angular frequency''. Frequency is measured in hertz (Hz) which is eq ...
between fixed minimum and maximum values, with the same duration at minimum and maximum. In an ideal square wave, the transitions between minimum and maximum are instantaneous.
The square wave is a special case of a
pulse wave
A pulse wave or pulse train is a type of non-sinusoidal waveform that includes square waves (duty cycle of 50%) and similarly periodic but asymmetrical waves (duty cycles other than 50%). It is a term used in synthesizer programming, and is ...
which allows arbitrary durations at minimum and maximum amplitudes. The ratio of the high period to the total period of a pulse wave is called the
duty cycle. A true square wave has a 50% duty cycle (equal high and low periods).
Square waves are often encountered in
electronics
The field of electronics is a branch of physics and electrical engineering that deals with the emission, behaviour and effects of electrons using electronic devices. Electronics uses active devices to control electron flow by amplification ...
and
signal processing
Signal processing is an electrical engineering subfield that focuses on analyzing, modifying and synthesizing ''signals'', such as sound, images, and scientific measurements. Signal processing techniques are used to optimize transmissions, ...
, particularly
digital electronics
Digital electronics is a field of electronics involving the study of digital signals and the engineering of devices that use or produce them. This is in contrast to analog electronics and analog signals.
Digital electronic circuits are usual ...
and
digital signal processing. Its
stochastic counterpart is a
two-state trajectory.
Origin and uses
Square waves are universally encountered in
digital switching circuits and are naturally generated by binary (two-level) logic devices. Square waves are typically generated by
metal–oxide–semiconductor field-effect transistor
The metal–oxide–semiconductor field-effect transistor (MOSFET, MOS-FET, or MOS FET) is a type of field-effect transistor (FET), most commonly fabricated by the controlled oxidation of silicon. It has an insulated gate, the voltage of which d ...
(MOSFET) devices due to their rapid on–off
electronic switch
In electronics, an electronic switch is an electronic component or device that can switch an electrical circuit, interrupting the current or diverting it from one conductor to another. Electronic switches are considered binary devices because the ...
ing behavior, in contrast to
bipolar junction transistor
A bipolar junction transistor (BJT) is a type of transistor that uses both electrons and electron holes as charge carriers. In contrast, a unipolar transistor, such as a field-effect transistor, uses only one kind of charge carrier. A bipola ...
s (BJTs) which slowly generate signals more closely resembling
sine waves
A sine wave, sinusoidal wave, or just sinusoid is a mathematical curve defined in terms of the ''sine'' trigonometric function, of which it is the graph. It is a type of continuous wave and also a smooth periodic function. It occurs often in ...
rather than square waves.
Square waves are used as timing references or "
clock signals", because their fast transitions are suitable for triggering
synchronous logic circuits at precisely determined intervals. However, as the frequency-domain graph shows, square waves contain a wide range of harmonics; these can generate
electromagnetic radiation
In physics, electromagnetic radiation (EMR) consists of waves of the electromagnetic (EM) field, which propagate through space and carry momentum and electromagnetic radiant energy. It includes radio waves, microwaves, infrared, (visible) li ...
or pulses of current that interfere with other nearby circuits, causing
noise
Noise is unwanted sound considered unpleasant, loud or disruptive to hearing. From a physics standpoint, there is no distinction between noise and desired sound, as both are vibrations through a medium, such as air or water. The difference aris ...
or errors. To avoid this problem in very sensitive circuits such as precision
analog-to-digital converter
In electronics, an analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a digital signal. An ADC may also provide ...
s,
sine waves are used instead of square waves as timing references.
In musical terms, they are often described as sounding hollow, and are therefore used as the basis for
wind instrument
A wind instrument is a musical instrument that contains some type of resonator (usually a tube) in which a column of air is set into vibration by the player blowing into (or over) a mouthpiece set at or near the end of the resonator. The pitc ...
sounds created using
subtractive synthesis
Subtractive synthesis is a method of sound synthesis in which partials of an audio signal (often one rich in harmonics) are attenuated by a filter to alter the timbre of the sound. While subtractive synthesis can be applied to any source audio ...
. Additionally, the distortion effect used on
electric guitar
An electric guitar is a guitar that requires external amplification in order to be heard at typical performance volumes, unlike a standard acoustic guitar (however combinations of the two - a semi-acoustic guitar and an electric acoustic gu ...
s clips the outermost regions of the waveform, causing it to increasingly resemble a square wave as more distortion is applied.
Simple two-level
Rademacher function
In mathematics, the Haar wavelet is a sequence of rescaled "square-shaped" functions which together form a wavelet family or basis. Wavelet analysis is similar to Fourier analysis in that it allows a target function over an interval to be repres ...
s are square waves.
Definitions
The square wave in mathematics has many definitions, which are equivalent except at the discontinuities:
It can be defined as simply the
sign function of a sinusoid:
which will be 1 when the sinusoid is positive, −1 when the sinusoid is negative, and 0 at the discontinuities. Here, ''T'' is the
period
Period may refer to:
Common uses
* Era, a length or span of time
* Full stop (or period), a punctuation mark
Arts, entertainment, and media
* Period (music), a concept in musical composition
* Periodic sentence (or rhetorical period), a concept ...
of the square wave and ''f'' is its frequency, which are related by the equation ''f'' = 1/''T''.
A square wave can also be defined with respect to the
Heaviside step function
The Heaviside step function, or the unit step function, usually denoted by or (but sometimes , or ), is a step function, named after Oliver Heaviside (1850–1925), the value of which is zero for negative arguments and one for positive argum ...
''u''(''t'') or the
rectangular function
The rectangular function (also known as the rectangle function, rect function, Pi function, Heaviside Pi function, gate function, unit pulse, or the normalized boxcar function) is defined as
\operatorname(t) = \Pi(t) =
\left\{\begin{array}{rl ...
Π(''t''):
A square wave can also be generated using the
floor function
In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
directly:
and indirectly:
Fourier analysis
![Fourier Series-Square wave 3 H](https://upload.wikimedia.org/wikipedia/commons/7/79/Fourier_Series-Square_wave_3_H.png)
Using
Fourier expansion
A Fourier series () is a summation of harmonically related sinusoidal functions, also known as components or harmonics. The result of the summation is a periodic function whose functional form is determined by the choices of cycle length (or '' ...
with cycle frequency over time , an ideal square wave with an amplitude of 1 can be represented as an infinite sum of sinusoidal waves:
The ideal square wave contains only components of odd-integer
harmonic frequencies (of the form ).
Sawtooth wave
The sawtooth wave (or saw wave) is a kind of non-sinusoidal waveform. It is so named based on its resemblance to the teeth of a plain-toothed saw with a zero rake angle. A single sawtooth, or an intermittently triggered sawtooth, is called ...
s and real-world signals contain all integer harmonics.
A curiosity of the convergence of the
Fourier series representation of the square wave is the
Gibbs phenomenon
In mathematics, the Gibbs phenomenon, discovered by Available on-line at:National Chiao Tung University: Open Course Ware: Hewitt & Hewitt, 1979. and rediscovered by , is the oscillatory behavior of the Fourier series of a piecewise continuousl ...
.
Ringing artifacts in non-ideal square waves can be shown to be related to this phenomenon. The Gibbs phenomenon can be prevented by the use of
σ-approximation, which uses the
Lanczos sigma factor
In mathematics, σ-approximation adjusts a Fourier summation to greatly reduce the Gibbs phenomenon, which would otherwise occur at discontinuities.
A σ-approximated summation for a series of period ''T'' can be written as follows:
s(\theta) = ...
s to help the sequence converge more smoothly.
An ideal mathematical square wave changes between the high and the low state instantaneously, and without under- or over-shooting. This is impossible to achieve in physical systems, as it would require infinite
bandwidth
Bandwidth commonly refers to:
* Bandwidth (signal processing) or ''analog bandwidth'', ''frequency bandwidth'', or ''radio bandwidth'', a measure of the width of a frequency range
* Bandwidth (computing), the rate of data transfer, bit rate or thr ...
.
![Fourier_series_for_square_wave](https://upload.wikimedia.org/wikipedia/commons/b/bc/Fourier_series_for_square_wave.gif)
Square waves in physical systems have only finite bandwidth and often exhibit
ringing effects similar to those of the Gibbs phenomenon or ripple effects similar to those of the σ-approximation.
For a reasonable approximation to the square-wave shape, at least the fundamental and third harmonic need to be present, with the fifth harmonic being desirable. These bandwidth requirements are important in digital electronics, where finite-bandwidth analog approximations to square-wave-like waveforms are used. (The ringing transients are an important electronic consideration here, as they may go beyond the electrical rating limits of a circuit or cause a badly positioned threshold to be crossed multiple times.)
Characteristics of imperfect square waves
As already mentioned, an ideal square wave has instantaneous transitions between the high and low levels. In practice, this is never achieved because of physical limitations of the system that generates the waveform. The times taken for the signal to rise from the low level to the high level and back again are called the ''
rise time In electronics, when describing a voltage or current step function, rise time is the time taken by a signal to change from a specified low value to a specified high value. These values may be expressed as ratiosSee for example , and . or, equivale ...
'' and the ''
fall time
In electronics, fall time (pulse decay time) t_f is the time taken for the amplitude of a pulse to decrease (fall) from a specified value (usually 90% of the peak value exclusive of overshoot or undershoot) to another specified value (usually 10 ...
'' respectively.
If the system is
overdamped
Damping is an influence within or upon an oscillatory system that has the effect of reducing or preventing its oscillation. In physical systems, damping is produced by processes that dissipate the energy stored in the oscillation. Examples in ...
, then the waveform may never actually reach the theoretical high and low levels, and if the system is underdamped, it will oscillate about the high and low levels before settling down. In these cases, the rise and fall times are measured between specified intermediate levels, such as 5% and 95%, or 10% and 90%. The
bandwidth
Bandwidth commonly refers to:
* Bandwidth (signal processing) or ''analog bandwidth'', ''frequency bandwidth'', or ''radio bandwidth'', a measure of the width of a frequency range
* Bandwidth (computing), the rate of data transfer, bit rate or thr ...
of a system is related to the transition times of the waveform; there are formulas allowing one to be determined approximately from the other.
See also
*
List of periodic functions
This is a list of some well-known periodic functions. The constant function , where is independent of , is periodic with any period, but lacks a ''fundamental period''. A definition is given for some of the following functions, though each funct ...
*
Rectangular function
The rectangular function (also known as the rectangle function, rect function, Pi function, Heaviside Pi function, gate function, unit pulse, or the normalized boxcar function) is defined as
\operatorname(t) = \Pi(t) =
\left\{\begin{array}{rl ...
*
Pulse wave
A pulse wave or pulse train is a type of non-sinusoidal waveform that includes square waves (duty cycle of 50%) and similarly periodic but asymmetrical waves (duty cycles other than 50%). It is a term used in synthesizer programming, and is ...
*
Sine wave
*
Triangle wave
A triangular wave or triangle wave is a non-sinusoidal waveform named for its triangular shape. It is a periodic, piecewise linear, continuous real function.
Like a square wave, the triangle wave contains only odd harmonics. However, ...
*
Sawtooth wave
The sawtooth wave (or saw wave) is a kind of non-sinusoidal waveform. It is so named based on its resemblance to the teeth of a plain-toothed saw with a zero rake angle. A single sawtooth, or an intermittently triggered sawtooth, is called ...
*
Waveform
In electronics, acoustics, and related fields, the waveform of a signal is the shape of its graph as a function of time, independent of its time and magnitude scales and of any displacement in time.David Crecraft, David Gorham, ''Electro ...
*
Sound
In physics, sound is a vibration that propagates as an acoustic wave, through a transmission medium such as a gas, liquid or solid.
In human physiology and psychology, sound is the ''reception'' of such waves and their ''perception'' b ...
*
Multivibrator
A multivibrator is an electronic circuit used to implement a variety of simple two-state devices such as relaxation oscillators, timers, and flip-flops. The first multivibrator circuit, the astable multivibrator oscillator, was invented by Henri ...
*
Ronchi ruling
A Ronchi ruling, Ronchi grating, or Ronchi mask, named after the Italian physicist Vasco Ronchi, is a constant-interval bar and space square-wave optical target or mask. The design produces a precisely patterned light source by reflection or ill ...
, a square-wave stripe target used in imaging.
*
Cross sea
A cross sea (also referred to as a squared sea or square waves) is a sea state of wind-generated ocean waves that form nonparallel wave systems. Cross seas have a large amount of directional spreading. This may occur when water waves from one w ...
*
Clarinet, a musical instrument that produces odd overtones approximating a square wave.
References
External links
Fourier decomposition of a square waveInteractive demo of square wave synthesis using sine waves, from GeoGebra site.
Square Wave Approximated by SinesInteractive demo of square wave synthesis using sine waves.
Square wave.
{{Waveforms
Waveforms
Fourier series