Jump to content

Square wave

From Wikipedia, the free encyclopedia

Square wave
Sine, square, triangle, and sawtooth waveforms
Sine,square,triangle,andsawtoothwaveforms
General information
General definition
Fields of applicationElectronics, synthesizers
Domain, codomain and image
Domain
Codomain
Basic features
ParityOdd
Period1
AntiderivativeTriangle wave
Fourier series

Asquare waveis anon-sinusoidal periodic waveformin which the amplitude alternates at a steadyfrequencybetween 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 apulse wavewhich allows arbitrary durations at minimum and maximum amplitudes. The ratio of the high period to the total period of a pulse wave is called theduty cycle.A true square wave has a 50% duty cycle (equal high and low periods).

Square waves are often encountered inelectronicsandsignal processing,particularlydigital electronicsanddigital signal processing.Itsstochasticcounterpart is atwo-state trajectory.

Origin and uses

[edit]

Square waves are universally encountered in digital switching circuits and are naturally generated by binary (two-level) logic devices. They are used as timing references or "clock signals",because their fast transitions are suitable for triggeringsynchronous logiccircuits at precisely determined intervals. However, as the frequency-domain graph shows, square waves contain a wide range of harmonics; these can generateelectromagnetic radiationor pulses of current that interfere with other nearby circuits, causingnoiseor errors. To avoid this problem in very sensitive circuits such as precisionanalog-to-digital converters,sine wavesare 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 forwind instrumentsounds created usingsubtractive synthesis.They also make up the "beeping" alerts used in many household, commercial, and industrial contexts. Additionally, the distortion effect used onelectric guitarsclips the outermost regions of the waveform, causing it to increasingly resemble a square wave as more distortion is applied.

Simple two-levelRademacher functionsare square waves.

Definitions

[edit]

The square wave in mathematics has many definitions, which are equivalent except at the discontinuities:

It can be defined as simply thesign functionof a sinusoid: which will be 1 when the sinusoid is positive, −1 when the sinusoid is negative, and 0 at the discontinuities. Here,Tis theperiodof the square wave andfis its frequency, which are related by the equationf= 1/T.

A square wave can also be defined with respect to theHeaviside step functionu(t) or therectangular functionΠ(t):

A square wave can also be generated using thefloor functiondirectly: and indirectly:

Using the fourier series (below) one can show that the floor function may be written in trigonometric form[1]

Fourier analysis

[edit]
The six arrows represent the first six terms of the Fourier series of a square wave. The two circles at the bottom represent the exact square wave (blue) and its Fourier-series approximation (purple).
(Odd) harmonics of a 1000 Hz square wave
Graph showing the first 3 terms of the Fourier series of a square wave

UsingFourier expansionwith cycle frequencyfover timet,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-integerharmonicfrequencies (of the form2π(2k− 1)f).

A curiosity of the convergence of theFourier seriesrepresentation of the square wave is theGibbs phenomenon.Ringing artifactsin 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 theLanczos sigma factorsto 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 infinitebandwidth.

Animation of the additive synthesis of a square wave with an increasing number of harmonics

Square waves in physical systems have only finite bandwidth and often exhibitringingeffects 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

[edit]

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 therise timeand thefall timerespectively.

If the system isoverdamped,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%. Thebandwidthof 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

[edit]

References

[edit]
  1. ^"Partial sum formula".wolfram Alpha.Archivedfrom the original on 22 January 2023.Retrieved9 July2023.
[edit]