Mike Martin
Product Manager
#SquareWaves #AudioAnalyzer #FFTAnalyzer

# It’s Hip to be Square

The Utility of Square Wave Signals
Square waves are useful because they can reveal many things about the frequency and phase response of a system with just quick visual analysis. This can be valuable when doing a system check, checking DSP routines, or when doing an A/B comparison while changing settings or components.

Generation
During your technical education, you likely were introduced to Fourier Transforms, learning that any repeating waveforms could be produced by a fundamental sine wave and a collection of sinusoids that represented odd or even harmonics, and varying amplitudes. Theoretically, what is a perfect square wave made of? It contains a sine wave fundamental and all its odd harmonics. The amplitude of each harmonic is 1/n, so the amplitude of the fifth harmonic, for example, would be 1/5 the amplitude of the fundamental. But making a perfect square wave isn’t easy.

Let’s look at a frequency domain view of a square wave produced by a high quality 15 MHz function generator. This function generator is a good choice for many applications, but not for audio, where the extremely high dynamic range (about 144 dB for 24-bit) requires the purest signal possible.

Most engineers are used to looking at square waves only in the time domain, but the frequency domain view provides additional diagnostic ability regarding the quality of a square wave, both before and after it has passed through a DUT (device under test).

Square wave created by a 15 MHz function generator, frequency domain view.

Notice how smoothly the odd harmonics diminish. That’s good. But also notice how high the even harmonics are—only about 60 dB below the fundamental. A perfect square wave would have no even harmonics. At 1 MHz, the even harmonics are only about 12 dB below the desirable odd harmonics, which means that real information about the DUT may be easily obscured by distortion in the square wave test signal. Notice that there are also intermodulation products 90 dB or so below the fundamental, again potentially hiding problems in the DUT.

In comparison, here is a square wave generated by Audio Precision’s (AP’s) AG52 option:

Square wave created by an APx525 audio analyzer with the AG52 option, frequency domain.

This is the best square wave produced by any audio analyzer in the world. What you see here is a fundamental frequency of 1 kHz at 0 dBV and every odd harmonic up to roughly 1.2 MHz. You can see that the noise floor is at approximately -120 dBV, with a reference of 0 dBV, but it is difficult to see the exact spacing of the odd harmonics, so below is a zoomed view that provides more detail.

We see in this zoomed-in view that the odd harmonics are evenly spaced and that the even harmonics are below -110 dBV for the second harmonic and down to -120 dBV at the 6th harmonic.

The shape of the square wave depends on the number of odd harmonics that are generated and how accurately they are produced in both frequency and amplitude. The “squareness” of the signal is improved with the addition of more odd harmonics. We can easily see the effects of more odd harmonics on this 1 kHz square wave simply by varying the bandwidth of the analyzer acquisition channel. Here is an example:

Note that the tops and bottoms of the waveform become flatter as the number of odd harmonics increase (by increasing the bandwidth). In addition, the edges become more vertical. The ringing that can be easily seen in the first three plots is an artifact of the number of harmonics available to create the signal. The ringing you see on the horizontal portions of the waveform is called “Gibbs Effect.” A quick internet search of “Gibbs Effect” will provide lots of additional details on this topic.

Analysis
The BW52 option complements the high performance of the AG52 square wave. Its 1 MHz bandwidth keeps the square wave perfectly square, so that we can be sure any defects seen are in the DUT, and aren’t artifacts of the audio analyzer itself. The 1 million point FFT and 24-bit A/D conversion allow extremely detailed analysis unobscured by noise.

Now, let’s use the AG52/BW52 combination to look at the time and frequency domain displays of a signal passing through a stereo receiver. Each example below represents the same conditions of the DUT, with the square wave response (time domain) on the left side, and the frequency sweep response (frequency domain) on the right side.

As I commented in my blog on Slew Rate & Rise Time Measurements, with square waves the edges are where the higher frequencies exist and the flat portions of the top and bottom are where the low frequencies exist (DC if the top and bottom are completely flat). This is why the high frequency roll-off and high frequency boost show their effects primarily at the edges (shown below), while the low frequency roll-off and low frequency boost show their effects primarily on the tops and bottoms of the cycles, leaving the edges mostly undisturbed (also shown below).

The Active All-Pass filter (below) is a case where the frequency domain looks reasonable and doesn’t indicate that anything unusual is happening with the response. However, looking at this in the time domain shows that the phase is shifting 180 degrees through each cycle.

It is worth mentioning one other audio test where a high purity square wave is required for accurate results. DIM (Dynamic Intermodulation Distortion) uses a combined square wave / sine wave stimulus to reveal slew-induced distortion—distortion caused when an amplifier cannot increase or decrease its output voltage fast enough to follow its input. This is generally not a problem in modern op amps, but DIM can still be an issue in the design of high wattage power amplifiers due to the large voltage swings they must produce.

DIM Level Sweep measurement (ratio vs. measured level).

Conclusion
While many audio analyzers can generate a square wave signal, it is often with inadequate bandwidth and visible ringing. These analyzers, coupled with an FFT analyzer limited in bandwidth and resolution, can only perform the most rudimentary square wave analysis. In this discussion, we’ve looked at the powerful analysis capability made possible using a high-quality square wave generator with wide bandwidth, high resolution, and long sample length FFT – all of which are available in APx Series audio analyzers.