Design Feature: April 27, 1995
The classical way to obtain a system's frequency response is to apply sine waves at many frequencies and, at each frequency, to measure the gain and phase shift from input to output. Even when performed with automated test equipment, this procedure takes a long time; impulse-response testing is faster and more convenient. A single long-record-length acquisition and a fast Fourier transform (FFT) calculation can provide data equivalent to that from sine-wave tests at thousands of frequencies. Although most digital storage oscilloscopes (DSOs) that calculate FFTs can perform impulse tests in real time, off-line analysis, using software such as MathCad, can overcome several disadvantages of nearly all DSOs' FFT capabilities.
The Fourier transform of the impulse response of a linear time-invariant system yields the system's magnitude and phase response vs frequency. To measure the phase and magnitude at all frequencies, you must apply all frequencies to the system. This is what you do when you apply an impulse to the system's input. An impulse's Fourier transform equals 1. Therefore, an ideal impulse contains all frequencies at equal amplitude and at a phase of zero with respect to a zero-phase reference point coincident with the impulse. In other words, each harmonic in the impulse starts a cycle at the time of the impulse. Fig 1 shows the phase relationship of three harmonics contained in an impulse. If you consider the harmonics to be cosine waves, the phase of each harmonic with respect to the zero-phase reference is 0°. All of the harmonics in the impulse have the same phase relationship.
If you compute an FFT of the system output and set the zero-phase reference correctly, you measure the magnitude and phase of the output at each FFT frequency.
The discrete Fourier transform (DFT) is a mathematical operation that transforms an array of data points representing amplitude vs time into an array of data representing magnitude and phase vs frequency. The FFT, which is simply a factored version of the DFT, produces identical results. Therefore, if you understand the DFT, you have a conceptual view of how the FFT provides a system's phase and magnitude response.
The equation for the DFT is
where:
x(n) = a point in the input time domain data array
X(k) = a point in the output frequency domain data array
N = length of the FFT input data block
k = index to the current output data point: k = 0 to N-1
n = index to the input data array
j = square root of -1
Twiddle factor:
Wnk = e<+z10>-j2(PI)nk/N
Wnk = cos (2(PI)nk/N) - jsin(2(PI)nk/N).
The twiddle array, a set of values corresponding to the twiddle vector, Wnk, contains k cycles. Each value in the array is a complex number with a magnitude that equals the square root of the sum of the squares of the value's real and imaginary parts. The magnitude of all points in the array is 1. Fig 2 shows the twiddle vector for k=5.
Fig 3 shows an example of an impulse-response vector, x(n), and the twiddle vector's real and imaginary parts for k=5. To compute an output point of the DFT according to Eq 1, multiply the x(n) vector by the complex twiddle vector point-by-point, add up all the points, and multiply the result by 1/N. The resulting complex point represents the magnitude and phase of the impulse response at the twiddle frequency. Place this point at position X(5) in the FFT-output array. Refer this value's phase to the twiddle vector's real part. If the zero-phase reference point coincides with the impulse you apply to the system, the impulse component at any particular frequency is in phase with the real part of the same-frequency twiddle vector. Thus, you should refer the phase of each FFT output point to the real part of the same-frequency harmonic.
For each value of k, the twiddle vector's real part starts at a positive peak at the beginning of the record. Therefore, the FFT's zero-phase reference point is at the beginning of the record. (Note that you can modify the twiddle phase so that the zero-phase reference point is at any desired position in the record. Later in the article, Eqs 4, 5, and 6 describe this phase shift.)
Now that you understand how the FFT converts a system's measured impulse response into a frequency response, you have the background for examining a measurement setup. Fig 4 shows one possible setup.
A signal generator produces a pulse that approximates an impulse-within the limits of the acquisition system's sample rate and the impulse response's frequency content. This pulse goes into channel 1 of a DSO and into the input of the system under test. To avoid reflections at higher frequencies, you must use a power splitter and proper cable terminations. Also, be sure that the cable length (B+C) from the power splitter to the system and DSO is the same as A, which connects the power splitter to the scope.
The output of the system under test feeds channel 2 of the DSO. The scope collects a long record of the impulse response and stores it on disk in a MathCad-compatible format. The PC reads this file into a MathCad document and processes the data to produce a number of displays. The displays include magnitude and phase vs frequency, 2- and 3-D Nyquist plots, and a wavelet transform. Although DSOs from the major manufacturers calculate FFTs, all of them have disadvantages for this application, which off-line analysis seeks to overcome. For example, one manufacturer does not allow a phase display of the FFT result. Another allows long record lengths only at certain time/div settings. A third manufacturer does not allow FFTs longer than 10k points.
Here is how to tune the test setup: At higher system frequencies and sample rates, you can have trouble finding a signal generator that produces a good impulse. Because good step generators are easier to come by, you can use a step as the input to the system under test. The derivative of a step function is an impulse. If the system under test is linear and time-invariant, you can determine the frequency response by calculating the FFT of the derivative of the system's response to an input step.
Set the scope to trigger on channel 1-the channel that the impulse generator drives. The impulse response from the system under test goes into channel 2. Adjust channels 2's vertical sensitivity to cause the impulse response to cover as many divisions as possible without clipping. This adjustment maximizes the ability of the scope's ADC to resolve the signal. The following equation describes how the FFT's resolution relates to the acquisition's sample rate and the record length. Here, the FFT is applied to the full acquisition record:

Next, choose the appropriate sample rate. According to the sampling theorem, the sample rate must be at least twice the highest frequency that the system under test can pass. If the sample rate is too low, the higher frequencies in the impulse responses cause the captured data to contain low-frequency alias responses. These spurious responses cause errors in the measurement. If the sample rate is too high, the length of the record needed to capture the entire impulse response may exceed the scope's memory depth.
Another aspect of choosing the sample rate relates to the one-sample-period jitter associated with many acquisition systems. Computing the FFT of the acquired signal produces output points covering a frequency range from dc to the Nyquist frequency (one-half of the sample rate). An input at the Nyquist frequency is sampled only twice per cycle. With such an input, jitter of one sample period corresponds to an uncertainty of 180° in the sample point's phase. Therefore, you should set the sample rate to at least four times the highest sample frequency. Higher sample rates are required to the point where the phase error is acceptable.
After you choose the sample rate, select the record length, which must be at least as long as the entire impulse response. Longer records increase the FFT's frequency resolution. However, in most cases, you accomplish nothing by increasing the record length beyond where the impulse response goes to and remains at zero; you can increase the frequency resolution off-line by padding the end of the record with zeros.
Many DSOs offer multiple signal-acquisition modes. Standard sample mode is a good choice for impulse-response testing applications where the noise is sufficiently low and the vertical resolution of the scope is acceptable. Don't use peak-detect or envelope modes because they store minimum and maximum values of samples over multiple sample intervals. In the frequency domain, these modifications of the original data result in undesirable artifacts. High-resolution or signal-averaging modes are probably the best choice because they increase the vertical resolution and remove noise. However, you must be aware of these modes' effects on the acquired signal's frequency response. For example, if the jitter in the sample time is one sample period (a typical fivalue) and you use averaging, the frequency response rolls off from a magnitude of 1 at dc to approximately 0.64 at half the sample rate. However, if you set the sample rate high enough, this roll-off won't matter.
An impulse applied to channel 1 triggers an acquisition. Because the impulse position is the zero-phase reference, you can use the trigger-position control to set this point to a position within the record. Usually, the impulse should fall at the beginning of the record because the system produces no output until the impulse occurs. This setting allows full use of the waveform memory for capturing the impulse response. Fig 5 shows alternative impulse locations within a record.
Be careful if you use the scope's built-in FFT to display the phase and magnitude response. Some scopes place the FFT's zero-phase reference at the beginning of the record. This reference position requires you to use a rectangular window function. Other symmetrical windows grossly distort the impulse response because they taper the data to zero at the ends of the record. On scopes that place the zero-phase reference at the record's midpoint, you can use any window function, but, to obtain the correct phase response, you must make sure that the impulse also occurs at the record's midpoint.
You should understand some of the issues involved in setting up a pulse generator to produce a pulse train that approximates a series of impulses. Although you may save only one record of the system response, you probably want to stimulate the system repeatedly so that you can tune the setup for the optimal acquisition.
An ideal impulse has infinite amplitude, zero width, and an area of 1. Obviously, no pulse generator can create such a pulse. The generator must provide an approximation that appears reasonable to the system under test. A pulse with an amplitude that is not large enough or with a width that is too narrow does not contain sufficient energy. Often, the result is a system response buried in noise. If the pulse amplitude is too large, the system under test clips. If the pulse is too wide, the impulse response is distorted because harmonics in the pulse roll off in amplitude. The pulse generator should produce pulses with as much amplitude as possible without causing the system under test to clip. The width of the pulse should be much less than the period of the highest frequency the system can pass.
The magnitude of the FFT of a one-sample-period-wide impulse is flat from dc to the Nyquist frequency. This is the desired result. However, as the pulse becomes wider than one sample period, the higher frequency harmonics roll off in amplitude. Therefore, ideally, the sample period should slightly exceed the pulse width. However, if the sample rate is high enough, you may be able to tolerate a pulse several sample periods wide because the roll-off occurs primarily at frequencies above those of interest.
If you need real-time information-say, on how adjustments affect the gain and phase response of the system under test-the generator must produce pulses at a fairly rapid rate, so that the scope can update its display. But the pulse rate must not be so high that multiple pulses occur during a single record or before the system response decays to zero and remains there.
Windowing functions are generally used in FFT analysis when a time-domain acquisition has been truncated at each end. The resulting discontinuity causes "leakage" in the FFT output-part of the energy at one FFT frequency shows up at adjacent frequencies. Multiplying the record by the windowing function tapers the ends of the record to zero. This tapering reduces the amount of energy that spills over to adjacent frequencies. For impulse testing, the signal is normally zero at both ends of the record. Therefore, a rectangular window is sufficient; other windowing functions provide little benefit.
If the impulse response begins at the start of the record, the only symmetrical window you can use is rectangular. Other windows taper the response to zero and grossly distort the FFT results.
If the record isn't long enough for the impulse response to decay completely to zero, you may be able to use a window function. If you use a standard bell-shaped window, such as the Hanning or Blackman/Harris functions, the zero-phase reference point must be at the midpoint of the record supplied to the FFT; otherwise, the phase response is incorrect.
By modifying the record off-line in the MathCad document, you can use the scope's full acquisition memory. The modification consists of rotating the twiddle phase (by multiplying every other point in the FFT's complex output array by -1) before computing the phase values. This approach moves the FFT phase reference to the 50% position. Another alternative is the author's asymmetrical window function. This window requires the zero-phase reference point to be at the 20% position in the time record.
The record of a system's impulse response usually begins with a high amplitude that decays exponentially. The asymmetrical window developed below allows the impulse to occur at the record's 20% position. Placing the impulse at this point necessitates correcting the FFT results: Like the impulse, the zero-phase reference point must move to the record's 20% position. You make the correction by operating on the FFT output data with the equations for rotating X-Y coordinates. The asymmetrical window introduces a small error (<2 dB) into the measurement. So, before you use it, you must determine the trade-offs.
Eqs 2 and 3 describe the asymmetrical window mathematically. The derivation begins with a base set of equations from Ref 1. Fig 6 shows the shape of the asymmetrical window in the time domain. Fig 7 shows the corresponding shape in the frequency domain.
| w[n] = the time domain window array | a1 = (N - 1)/5 | scallop loss = 0.154 dB |
| N = length of the window | a2 = (N - 1)/3 | CG = 0.232082 |
| a0 gain (Normalize peak to 1) | a3 = 0.03125 N | 3-dB bandwidth = 2.35 bins |
| n = 0, ... N - 1 | a4 = 0.5 N exp = 12 | 6-dB bandwidth = 3.67 bins |
Eqs 4, 5, and 6 describe moving the zero-phase reference point in mathematical terms. By applying these three equations to the complex output points of the FFT, you can move the zero-phase reference point to any desired position in the record:
N = length of the FFT
P = position of the zero-phase reference point as a percentage of N
C = 2[PI] P/100
k = 0 ... N - 1
X is the array of complex FFT points
Re(Xk) is the real part of X at the kth position in the array
Im(Xk) is the imaginary part of X at the kth position in the array
newlk = Im(Xk) cos( C k) + Re(Xk) sin( C k ) (5)
Xk = newRk + j newlk, (6)
where X is the new phase adjusted array, and j is the square root of -1.
Data gathered on an audio-frequency parametric equalizer demonstrate how to set up a test. An example of a scope display appears in Fig 8. The impulse width is about 20 µsec; the amplitude is about 10V. The record length is 50k points. These settings permit oversampling of the response at 2.5M samples/sec while allowing the response to decay to zero before the scope's memory fills up. Because the sampling system's 1.25-MHz Nyquist frequency is much higher than the equalizer's 20-kHz bandwidth, the roll-off introduced by the scope's averaging mode occurs well above any frequencies of interest. Using averaging removes a large amount of undesirable noise from the acquired signal and increases the vertical resolution from 8 bits to approximately 12 bits.
Saving the impulse-response (Fig 8) to a disk on the DSO in a MathCad-compatible format allows loading the response into a MathCad document on a PC (see box, " Using MathCad for off-line FFT analysis"). If the DSO can't produce MathCad-compatible output files on disk, you must dump the data in some other format or send it to the PC via the IEEE-488 bus and convert it to MathCad format. The format consists of numerical values represented as ASCII characters delimited by spaces, commas, or carriage returns. This example used a Tektronix TDS 784A, which can produce files that are directly compatible with MathCad.

John J Pickerd is a software engineer at Tektronix Inc in Beaverton, OR, where he has worked for five years. His job entails developing DSP software for the TDS family of oscilloscopes. Pickerd earned an associate's degree in electronic engineering technology from Blue Mountain Community College, Pendleton, OR, in 1972 and received his BSEE from Oregon State University, Corvallis, OR, in 1988. In his spare time, he plays guitar and bass in a Christian rock 'n' roll band.
References
Brown, Ron,"The search for a universal peak-fitting tool yields two general-purpose functions," Personal Engineering and Instrumentation News, December 1992, pg 48.
MathCad is a registered trademark of Mathsoft Inc.