FFT Tutorial NI
FFT Tutorial NI
Introduction
The Fast Fourier Transform (FFT) and the power spectrum are powerful tools for analyzing and measuring signals
from plug-in data acquisition (DAQ) devices. For example, you can effectively acquire time-domain signals, measure
the frequency content, and convert the results to real-world units and displays as shown on traditional benchtop
spectrum and network analyzers. By using plug-in DAQ devices, you can build a lower cost measurement system and
avoid the communication overhead of working with a stand-alone instrument. Plus, you have the flexibility of
configuring your measurement processing to meet your needs.
To perform FFT-based measurement, however, you must understand the fundamental issues and computations
involved. This application note serves the following purposes.
• Describes some of the basic signal analysis computations,
• Discusses antialiasing and acquisition front ends for FFT-based signal analysis,
• Explains how to use windows correctly,
• Explains some computations performed on the spectrum, and
• Shows you how to use FFT-based functions for network measurement.
The basic functions for FFT-based signal analysis are the FFT, the Power Spectrum, and the Cross Power Spectrum.
Using these functions as building blocks, you can create additional measurement functions such as frequency response,
impulse response, coherence, amplitude spectrum, and phase spectrum.
FFTs and the Power Spectrum are useful for measuring the frequency content of stationary or transient signals. FFTs
produce the average frequency content of a signal over the entire time that the signal was acquired. For this reason, you
should use FFTs for stationary signal analysis or in cases where you need only the average energy at each frequency
line. To measure frequency information that is changing over time, use joint time-frequency functions such as the
Gabor Spectrogram.
This application note also describes other issues critical to FFT-based measurement, such as the characteristics of the
signal acquisition front end, the necessity of using windows, the effect of using windows on the measurement, and
measuring noise versus discrete frequency components.
National Instruments™, ni.com™, and LabWindows/CVI™ are trademarks of National Instruments Corporation. Product and company names mentioned herein are
trademarks or trade names of their respective companies.
340555B-01 © Copyright 2000 National Instruments Corporation. All rights reserved. July 2000
Basic Signal Analysis Computations
The basic computations for analyzing signals include converting from a two-sided power spectrum to a single-sided
power spectrum, adjusting frequency resolution and graphing the spectrum, using the FFT, and converting power and
amplitude into logarithmic units.
The power spectrum returns an array that contains the two-sided power spectrum of a time-domain signal. The array
values are proportional to the amplitude squared of each frequency component making up the time-domain signal.
A plot of the two-sided power spectrum shows negative and positive frequency components at a height
2
Ak
------
4
where Ak is the peak amplitude of the sinusoidal component at frequency k. The DC component has a height of A02
where A0 is the amplitude of the DC component in the signal.
Figure 1 shows the power spectrum result from a time-domain signal that consists of a 3 Vrms sine wave at 128 Hz, a
3 Vrms sine wave at 256 Hz, and a DC component of 2 VDC. A 3 Vrms sine wave has a peak voltage of 3.0 • or
about 4.2426 V. The power spectrum is computed from the basic FFT function. Refer to the Computations Using the
FFT section later in this application note for an example this formula.
5.0
4.0
2
3.0
Vrms
2.0
1.0
0.0
0 200 400 600 800 1000 1200
Hz
In a two-sided spectrum, half the energy is displayed at the positive frequency, and half the energy is displayed at the
negative frequency. Therefore, to convert from a two-sided spectrum to a single-sided spectrum, discard the second
half of the array and multiply every point except for DC by two.
G AA ( i ) = S AA ( i ), i = 0 (DC)
N
G AA ( i ) = 2 • S AA ( i ) , i = 1 to ---- – 1
2
N
---- through N – 1
2
is discarded.
2
Ak
------
2
This is equivalent to
Ak 2
------
-
2
where
A
------k-
2
is the root mean square (rms) amplitude of the sinusoidal component at frequency k. Thus, the units of a power
spectrum are often referred to as quantity squared rms, where quantity is the unit of the time-domain signal. For
example, the single-sided power spectrum of a voltage waveform is in volts rms squared.
Figure 2 shows the single-sided spectrum of the signal whose two-sided spectrum Figure 1 shows.
10.0
8.0
2
6.0
Vrms
4.0
2.0
0.0
0 100 200 300 400 500 600
Hz
As you can see, the level of the non-DC frequency components are doubled compared to those in Figure 1. In addition,
the spectrum stops at half the frequency of that in Figure 1.
where N is the number of points in the acquired time-domain signal. The first frequency line is at 0 Hz, that is, DC.
The last frequency line is at
Fs Fs
----- – -----
2 N
where Fs is the frequency at which the acquired time-domain signal was sampled. The frequency lines occur at ∆f
intervals where
F
∆f = -----s
N
Frequency lines also can be referred to as frequency bins or FFT bins because you can think of an FFT as a set of
parallel filters of bandwidth ∆f centered at each frequency increment from
Fs F
DC to ----- – -----s
2 N
1
∆f = ---------------
N • ∆t
where ∆t is the sampling period. Thus N • ∆t is the length of the time record that contains the acquired time-domain
signal. The signal in Figures 1 and 2 contains 1,024 points sampled at 1.024 kHz to yield ∆f = 1 Hz and a frequency
range from DC to 511 Hz.
The computations for the frequency axis demonstrate that the sampling frequency determines the frequency range or
bandwidth of the spectrum and that for a given sampling frequency, the number of points acquired in the time-domain
signal record determine the resolution frequency. To increase the frequency resolution for a given frequency range,
increase the number of points acquired at the same sampling frequency. For example, acquiring 2,048 points at 1.024
kHz would have yielded ∆f = 0.5 Hz with frequency range 0 to 511.5 Hz. Alternatively, if the sampling rate had been
10.24 kHz with 1,024 points, ∆f would have been 10 Hz with frequency range from 0 to 5.11 kHz.
The phase information the FFT yields is the phase relative to the start of the time-domain signal. For this reason, you
must trigger from the same point in the signal to obtain consistent phase readings. A sine wave shows a phase of –90°
at the sine wave frequency. A cosine shows a 0° phase. In many cases, your concern is the relative phases between
components, or the phase difference between two signals acquired simultaneously. You can view the phase difference
between two signals by using some of the advanced FFT functions. Refer to the FFT-Based Network Measurement
section of this application note for descriptions of these functions.
2 2
Magnitude [FFT(A)] [ real [ FFT ( A ) ] ] + [ imag [ FFT ( A ) ] ]
Amplitude spectrum in quantity peak = -------------------------------------------------- = -------------------------------------------------------------------------------------------------
N N
imag [ FFT ( A ) ]
Phase spectrum in radians = Phase [FFT(A)] = arctangent -------------------------------------
real [ FFT ( A ) ]
where the arctangent function here returns values of phase between –π and +π, a full range of 2π radians.
Using the rectangular to polar conversion function to convert the complex array
FFT(A)
------------------
N
to its magnitude (r) and phase (ø) is equivalent to using the preceding formulas.
The two-sided amplitude spectrum actually shows half the peak amplitude at the positive and negative frequencies. To
convert to the single-sided form, multiply each frequency other than DC by two, and discard the second half of the
array. The units of the single-sided amplitude spectrum are then in quantity peak and give the peak amplitude of each
sinusoidal component making up the time-domain signal. For the single-sided phase spectrum, discard the second half
of the array.
To view the amplitude spectrum in volts (or another quantity) rms, divide the non-DC components by the square root
of two after converting the spectrum to the single-sided form. Because the non-DC components were multiplied by two
to convert from two-sided to single-sided form, you can calculate the rms amplitude spectrum directly from the
two-sided amplitude spectrum by multiplying the non-DC components by the square root of two and discarding the
second half of the array. The following equations show the entire computation from a two-sided FFT to a single-sided
amplitude spectrum.
Magnitude[FFT(A)] N
Amplitude spectrum in volts rms = 2 • ------------------------------------------------ for i = 1 to ---- – 1
N 2
Magnitude[FFT(A)]
= ------------------------------------------------ for i = 0 (DC)
N
The magnitude in volts rms gives the rms voltage of each sinusoidal component of the time-domain signal.
180
Phase spectrum in degrees = --------- • Phase FFT(A)
π
FFT(A) • FFT*(A)
Power spectrum S AA ( f ) = ----------------------------------------------
N
where FFT*(A) denotes the complex conjugate of FFT(A). To form the complex conjugate, the imaginary part of
FFT(A) is negated.
When using the FFT in LabVIEW, be aware that the speed of the power spectrum and the FFT computation depend on
the number of points acquired. If N is a power of two, LabVIEW uses the efficient FFT algorithm. Otherwise,
LabVIEW actually uses the discrete Fourier transform (DFT), which takes considerably longer. LabWindows/CVI
requires that N be a factor of two and thus always uses the FFT. Typical benchtop instruments use FFTs of 1,024 and
2,048 points.
So far, you have looked at display units of volts peak, volts rms, and volts rms squared, which is equivalent to
mean-square volts. In some spectrum displays, the rms qualifier is dropped for Vrms, in which case V implies Vrms,
and V2 implies Vrms2, or mean-square volts.
dB = 10log 10 P ⁄ P r
Use the following equation to compute the ratio in decibels from amplitude values.
dB = 20log 10 A ⁄ A r
When using amplitude or power as the amplitude-squared of the same signal, the resulting decibel level is exactly the
same. Multiplying the decibel ratio by two is equivalent to having a squared ratio. Therefore, you obtain the same
decibel level and display regardless of whether you use the amplitude or power spectrum.
As shown in the preceding equations for power and amplitude, you must supply a reference for a measure in decibels.
This reference then corresponds to the 0 dB level. Several conventions are used. A common convention is to use the
reference 1 Vrms for amplitude or 1 Vrms squared for power, yielding a unit in dBV or dBVrms. In this case, 1 Vrms
corresponds to 0 dB. Another common form of dB is dBm, which corresponds to a reference of 1 mW into a load of
50 Ω for radio frequencies where 0 dB is 0.22 Vrms, or 600 Ω for audio frequencies where 0 dB is 0.78 Vrms.
When the Nyquist criterion is violated, frequency components above half the sampling frequency appear as frequency
components below half the sampling frequency, resulting in an erroneous representation of the signal. For example, a
component at frequency
Fs
----- < f 0 < F s
2
Figure 4 shows the alias frequencies that appear when the signal with real components at 25, 70, 160, and 510 Hz is
sampled at 100 Hz. Alias frequencies appear at 10, 30, and 40 Hz.
Figure 4. Alias Frequencies Resulting from Sampling a Signal at 100 Hz That Contains
Frequency Components Greater than or Equal to 50 Hz
These higher frequency components, do not interfere with the measurement. If you know that the frequency bandwidth
of the signal being measured is lower than half the sampling frequency, you can choose not to use an antialiasing filter.
Figure 5 shows the input frequency response of the National Instruments PCI-4450 Family dynamic signal acquisition
boards, which have antialiasing filters. Note how an input signal at or above half the sampling frequency is severely
attenuated.
Amplitude (dB)
0.00
–20.00
–40.00
–60.00
–80.00
–100.00
–120.00
0.00 0.20 0.40 0.60 0.80 1.00
Frequency/Sample Rate (fs)
Figure 5. Bandwidth of PCI-4450 Family Input Versus Frequency, Normalized to Sampling Rate
For example, in the case of the PCI-4450 Family sample shown in Figure 5, amplitude flatness is maintained to within
±0.1 dB, at up to 0.464 of the sampling frequency to 20 kHz for all gain settings, +1 dB to 95 kHz, and then the input
gain starts to attenuate. The –3 dB point (or half-power bandwidth) of the input occurs at 0.493 of the input spectrum.
Therefore, instead of showing the input spectrum all the way out to half the sampling frequency, you may want to show
only 0.464 of the input spectrum. To do this, multiply the number of points acquired by 0.464, respectively, to compute
the number of frequency lines to display.
The characteristics of the signal acquisition front end affect the measurement. The National Instruments PCI-4450
Family dynamic signal acquisition boards and the NI 4551 and NI 4552 dynamic signal analyzers are excellent
acquisition front ends for performing FFT-based signal analysis measurements. These boards use delta-sigma
modulation technology, which yields excellent amplitude flatness, high-performance antialiasing filters, and wide
dynamic range as shown in Figure 5. The input channels are also simultaneously sampled for good multichannel
measurement performance.
To calculate the measurement bandwidth for a given sampling frequency, multiply the sampling frequency by 0.464
for the ±0.1 dB flatness. Also, the larger the FFT, the larger the number of frequency lines. A 2,048-point FFT yields
twice the number of lines listed above. Contrast this with typical benchtop instruments, which have 400 or 800 useful
lines for a 1,024- point or 2,048-point FFT, respectively.
2
Vs
SNR = 10log 10 -----2- dB
V n
where Vs and Vn are the rms amplitudes of the signal and noise, respectively. A bandwidth is usually given for SNR.
In this case, the bandwidth is the frequency range of the board input, which is related to the sampling rate as shown in
Figure 5. The 93 dB SNR means that you can detect the frequency components of a signal that is as small as 93 dB
below the full-scale range of the board. This is possible because the total input noise level caused by the acquisition
front end is 93 dB below the full-scale input range of the board.
If the signal you monitor is a narrowband signal (that is, the signal energy is concentrated in a narrow band of
frequencies), you are able to detect an even lower level signal than –93 dB. This is possible because the noise energy
of the board is spread out over the entire input frequency range. Refer to the Computing Noise Level and Power
Spectral Density section later in this application note for more information about narrowband versus broadband levels.
The spurious-free dynamic range of the dynamic signal acquisition boards is 95 dB. Besides input noise, the
acquisition front end may introduce spurious frequencies into a measured spectrum because of harmonic or
intermodulation distortion, among other things. This 95 dB level indicates that any such spurious frequencies are at
least 95 dB below the full-scale input range of the board.
The wide dynamic range specifications of these boards is largely due to the 16-bit resolution ADCs. Figure 6 shows a
typical spectrum plot of the PCI-4450 Family dynamic range with a full-scale 997 Hz signal applied. You can see that
the harmonics of the 997 Hz input signal, the noise floor, and any other spurious frequencies are below 95 dB. In
contrast, dynamic range specifications for benchtop instruments typically range from 70 dB to 80 dB using 12-bit and
13-bit ADC technology.
Spectral Leakage
For an accurate spectral measurement, it is not sufficient to use proper signal acquisition techniques to have a nicely
scaled, single-sided spectrum. You might encounter spectral leakage. Spectral leakage is the result of an assumption
in the FFT algorithm that the time record is exactly repeated throughout all time and that signals contained in a time
record are thus periodic at intervals that correspond to the length of the time record. If the time record has a nonintegral
number of cycles, this assumption is violated and spectral leakage occurs. Another way of looking at this case is that
the nonintegral cycle frequency component of the signal does not correspond exactly to one of the spectrum frequency
lines.
There are only two cases in which you can guarantee that an integral number of cycles are always acquired. One case
is if you are sampling synchronously with respect to the signal you measure and can therefore deliberately take an
integral number of cycles.
Another case is if you capture a transient signal that fits entirely into the time record. In most cases, however, you
measure an unknown signal that is stationary; that is, the signal is present before, during, and after the acquisition. In
this case, you cannot guarantee that you are sampling an integral number of cycles. Spectral leakage distorts the
measurement in such a way that energy from a given frequency component is spread over adjacent frequency lines or
bins. You can use windows to minimize the effects of performing an FFT over a nonintegral number of cycles.
Figure 7 shows the effects of three different windows — none (Uniform), Hanning (also commonly known as Hann),
and Flat Top — when an integral number of cycles have been acquired, in this figure, 256 cycles in a 1,024-point
record. Notice that the windows have a main lobe around the frequency of interest. This main lobe is a frequency
domain characteristic of windows. The Uniform window has the narrowest lobe, and the Hann and Flat Top windows
introduce some spreading. The Flat Top window has a broader main lobe than the others. For an integral number of
cycles, all windows yield the same peak amplitude reading and have excellent amplitude accuracy.
Figure 7 also shows the values at frequency lines of 254 Hz through 258 Hz for each window. The amplitude error at
256 Hz is 0 dB for each window. The graph shows the spectrum values between 240 and 272 Hz. The actual values in
the resulting spectrum array for each window at 254 through 258 Hz are shown below the graph. ∆f is 1 Hz.
Figure 8 shows the leakage effects when you acquire 256.5 cycles. Notice that at a nonintegral number of cycles, the
Hann and Flat Top windows introduce much less spectral leakage than the Uniform window. Also, the amplitude error
is better with the Hann and Flat Top windows. The Flat Top window demonstrates very good amplitude accuracy but
also has a wider spread and higher side lobes than the Hann window.
Figure 8. Power Spectrum of 1 Vrms Signal at 256.5 Hz with Uniform, Hann, and Flat Top Windows
20
0
–20
No Window
dBV
–40
–60
–80
Hann Window
–100
–120
100 150 200 250 300
Hz
Window Characteristics
To understand how a given window affects the frequency spectrum, you need to understand more about the frequency
characteristics of windows. The windowing of the input data is equivalent to convolving the spectrum of the original
signal with the spectrum of the window as shown in Figure 10. Even if you use no window, the signal is convolved
with a rectangular-shaped window of uniform height, by the nature of taking a snapshot in time of the input signal.
This convolution has a sine function characteristic spectrum. For this reason, no window is often called the Uniform
or Rectangular window because there is still a windowing effect.
An actual plot of a window shows that the frequency characteristic of a window is a continuous spectrum with a main
lobe and several side lobes. The main lobe is centered at each frequency component of the time-domain signal, and the
side lobes approach zero at
Fs
∆f = ----- i
N
*
Signal Spectrum Window Spectrum
If the frequency components of the original signal match a frequency line exactly, as is the case when you acquire an
integral number of cycles, you see only the main lobe of the spectrum. Side lobes do not appear because the spectrum
of the window approaches zero at ∆f intervals on either side of the main lobe. Figure 7 illustrates this case.
If a time record does not contain an integral number of cycles, the continuous spectrum of the window is shifted from
the main lobe center at a fraction of ∆f that corresponds to the difference between the frequency component and the
FFT line frequencies. This shift causes the side lobes to appear in the spectrum. In addition, there is some amplitude
error at the frequency peak, as shown in Figure 8, because the main lobe is sampled off center (the spectrum is
smeared).
Figure 11 shows the frequency spectrum characteristics of a window in more detail. The side lobe characteristics of
the window directly affect the extent to which adjacent frequency components bias (leak into) adjacent frequency bins.
The side lobe response of a strong sinusoidal signal can overpower the main lobe response of a nearby weak sinusoidal
signal.
–6 dB
Peak
Side Lobe
Level
Side Lobe
Roll-Off Rate
Another important characteristic of window spectra is main lobe width. The frequency resolution of the windowed
signal is limited by the width of the main lobe of the window spectrum. Therefore, the ability to distinguish two closely
spaced frequency components increases as the main lobe of the window narrows. As the main lobe narrows and
spectral resolution improves, the window energy spreads into its side lobes, and spectral leakage worsens. In general,
then, there is a trade off between leakage suppression and spectral resolution.
If the frequency of interest contains two or more signals very near to each other, spectral resolution is important. In
this case, it is best to choose a window with a very narrow main lobe. If the amplitude accuracy of a single frequency
component is more important than the exact location of the component in a given frequency bin, choose a window with
a wide main lobe. If the signal spectrum is rather flat or broadband in frequency content, use the Uniform window (no
window). In general, the Hann window is satisfactory in 95% of cases. It has good frequency resolution and reduced
spectral leakage.
The Flat Top window has good amplitude accuracy, but because it has a wide main lobe, it has poor frequency
resolution and more spectral leakage. The Flat Top window has a lower maximum side lobe level than the Hann
window, but the Hann window has a faster roll off-rate. If you do not know the nature of the signal but you want to
apply a window, start with the Hann window. Figures 7 and 8 contrast the characteristics of the Uniform, Hann, and
Flat Top Windows windows.
If you are analyzing transient signals such as impact and response signals, it is better not to use the spectral windows
because these windows attenuate important information at the beginning of the sample block. Instead, use the Force
and Exponential windows. A Force window is useful in analyzing shock stimuli because it removes stray signals at the
end of the signal. The Exponential window is useful for analyzing transient response signals because it damps the end
of the signal, ensuring that the signal fully decays by the end of the sample block.
Selecting a window function is not a simple task. In fact, there is no universal approach for doing so. However, Table 2
can help you in your initial choice. Always compare the performance of different window functions to find the best
one for the application. Refer to the references at the end of this application note for more information about windows.
Scaling Windows
Windows are useful in reducing spectral leakage when using the FFT for spectral analysis. However, because windows
are multiplied with the acquired time-domain signal, they introduce distortion effects of their own. The windows
change the overall amplitude of the signal. The windows used to produce the plots in Figures 7 and 8 were scaled by
dividing the windowed array by the coherent gain of the window. As a result, each window yields the same spectrum
amplitude result within its accuracy constraints.
You can think of an FFT as a set of parallel filters, each ∆f in bandwidth. Because of the spreading effect of a window,
each window increases the effective bandwidth of an FFT bin by an amount known as the equivalent noise-power
bandwidth of the window. The power of a given frequency peak is computed by adding the adjacent frequency bins
around a peak and is inflated by the bandwidth of the window. You must take this inflation into account when you
perform computations based on the spectrum. Refer to the Computations on the Spectrum section for sample
computations.
Table 3 lists the scaling factor (or coherent gain), the noise power bandwidth, and the worst-case peak amplitude
accuracy caused by off-center components for several popular windows.
You can estimate the actual frequency of a discrete frequency component to a greater resolution than the ∆f given by
the FFT by performing a weighted average of the frequencies around a detected peak in the power spectrum.
j+3
∑ ( Power ( i ) • i • ∆f )
i = j–3
Estimated Frequency = ------------------------------------------------------------
j+3
∑ Power ( i )
i = j–3
where j is the array index of the apparent peak of the frequency of interest and
F
∆f = -----s
N
The span j ±3 is reasonable because it represents a spread wider than the main lobes of the windows listed in Table 3.
Similarly, you can estimate the power in Vrms2 of a given peak discrete frequency component by summing the power
in the bins around the peak (computing the area under the peak)
j+3
∑ Power ( i )
i = j–3
Estimated Power = -----------------------------------------------------------------------------------
noise power bandwidth of window
Notice that this method is valid only for a spectrum made up of discrete frequency components. It is not valid for a
continuous spectrum. Also, if two or more frequency peaks are within six lines of each other, they contribute to
inflating the estimated powers and skewing the actual frequencies. You can reduce this effect by decreasing the number
of lines spanned by the preceding computations. If two peaks are that close, they are probably already interfering with
one another because of spectral leakage.
Similarly, if you want the total power in a given frequency range, sum the power in each bin included in the frequency
range and divide by the noise power bandwidth of the windows.
To compute the SNR, compare the peak power in the frequencies of interest to the broadband noise level. Compute the
broadband noise level in Vrms2 by summing all the power spectrum bins, excluding any peaks and the DC component,
and dividing the sum by the equivalent noise bandwidth of the window. For example, in Figure 6 the noise floor appears
to be more than 120 dB below full scale, even though the PCI-4450 Family dynamic range is only 93 dB. If you were
to sum all the bins, excluding DC, and any harmonic or other peak components and divide by the noise power
bandwidth of the window you used, the noise power level compared to full scale would be around –93 dB from full
scale.
Because of noise-level scaling with ∆f, spectra for noise measurement are often displayed in a normalized format
called power or amplitude spectral density. This normalizes the power or amplitude spectrum to the spectrum that
would be measured by a 1 Hz-wide square filter, a convention for noise-level measurements. The level at each
frequency line then reads as if it were measured through a 1 Hz filter centered at that frequency line.
2
Power Spectrum in V rms
Power spectral density = ----------------------------------------------------------------------------------------------------
-
∆f × Noise Power Bandwidth of Window
2 2
V rms V
The units are then in ---------------
- or -------
Hz Hz
FFT(B) × FFT*(A)
Cross Power Spectrum S AB ( f ) = ---------------------------------------------
2
-
N
The cross power spectrum is in two-sided complex form. To convert to magnitude and phase, use the
Rectangular-To-Polar conversion function. To convert to a single-sided form, use the same method described in the
Converting from a Two-Sided Power Spectrum to a Single-Sided Power Spectrum section of this application note. The
units of the single-sided form are in volts (or other quantity) rms squared.
The power spectrum is equivalent to the cross power spectrum when signals A and B are the same signal. Therefore,
the power spectrum is often referred to as the auto power spectrum or the auto spectrum. The single-sided cross power
spectrum yields the product of the rms amplitudes of the two signals, A and B, and the phase difference between the
two signals.
When you know how to use these basic blocks, you can compute other useful functions, such as the Frequency
Response function.
The frequency response of a network is measured by applying a stimulus to the network as shown in Figure 12 and
computing the transfer function from the stimulus and response signals.
Network
Applied Stimulus Under Measured Response (B)
Test
Transfer Function
The transfer function gives the gain and phase versus frequency of a network and is typically computed as
The transfer function is in two-sided complex form. To convert to the frequency response gain (magnitude) and the
frequency response phase, use the Rectangular-To-Polar conversion function. To convert to single-sided form, simply
discard the second half of the array.
You may want to take several transfer function readings and then average them. To do so, average the cross power
spectrum, SAB(f), by summing it in the complex form then dividing by the number of averages, before converting it to
magnitude and phase, and so forth. The power spectrum, SAA(f), is already in real form and is averaged normally.
To compute the impulse response of the network, take the inverse FFT of the two-sided complex transfer function as
described in the Transfer Function section of this application note.
S AB ( f )
Impulse Response (f) = Inverse FFT (Transfer Function H(f)) = Inverse FFT ----------------
S AA ( f )
The result is a time-domain function. To average multiple readings, take the inverse FFT of the averaged transfer
function.
Coherence Function
The coherence function is often used in conjunction with the transfer function as an indication of the quality of the
transfer function measurement and indicates how much of the response energy is correlated to the stimulus energy. If
there is another signal present in the response, either from excessive noise or from another signal, the quality of the
network response measurement is poor. You can use the coherence function to identify both excessive noise and
causality, that is, identify which of the multiple signal sources are contributing to the response signal. The coherence
function is computed as
2
[ Magnitude ( Averaged S AB ( f ) ) ]
Coherence Function (f) = ---------------------------------------------------------------------------------------
-
Averaged S AA ( f ) • Averaged S BB ( f )
The result is a value between zero and one versus frequency. A zero for a given frequency line indicates no correlation
between the response and the stimulus signal. A one for a given frequency line indicates that the response energy is
100 percent due to the stimulus signal; in other words, there is no interference at that frequency.
For a valid result, the coherence function requires an average of two or more readings of the stimulus and response
signals. For only one reading, it registers unity at all frequencies. To average the cross power spectrum, S AB(f), average
it in the complex form then convert to magnitude and phase as described in the Transfer Function section of this
application note. The auto power spectra, SAA(f) and SBB(f), are already in real form, and you average them normally.
It is best not to use windows when analyzing frequency response signals. If you generate a chirp stimulus signal at the
same rate you acquire the response, you can match the acquisition frame size to match the length of the chirp. No
window is generally the best choice for a broadband signal source. Because some stimulus signals are not constant in
frequency across the time record, applying a window may obscure important portions of the transient response.
References
Harris, Fredric J. “On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform” in
Proceedings of the IEEE Vol. 66, No. 1, January 1978.
Audio Frequency Fourier Analyzer (AFFA) User Guide, National Instruments, September 1991.
Horowitz, Paul, and Hill, Winfield, The Art of Electronics, 2nd Edition, Cambridge University Press, 1989.
Nuttall, Albert H. “Some Windows with Very Good Sidelobe Behavior,” IEEE Transactions on Acoustics, Speech, and
Signal Processing Vol. 29, No. 1, February 1981.
Randall, R.B., and Tech, B. Frequency Analysis, 3rd Edition, Bruël and Kjær, September 1979.