Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Document Version 4
plot of the two-sided power spectrum shows negative and positive frequency components at a height
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.
www.ni.com
where SAA(i) is the two-sided power spectrum, GAA(i) is the single-sided power spectrum, and N is the length of the
two-sided power spectrum. The remainder of the two-sided power spectrum SAA
This is equivalent to
where
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.
www.ni.com
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
where Fs is the frequency at which the acquired time-domain signal was sampled. The frequency lines occur at
f intervals where
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
www.ni.com
where
t is the sampling period. Thus
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.
www.ni.com
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
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.
www.ni.com
The amplitude spectrum is closely related to the power spectrum. You can compute the single-sided power spectrum by
squaring the single-sided rms amplitude spectrum. Conversely, you can compute the amplitude spectrum by taking the
square root of the power spectrum. The two-sided power spectrum is actually computed from the FFT as follows.
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 and LabWindows/CVI, be aware that the speed of the power spectrum and the FFT
computation depend on the number of points acquired. If N can be factored into small prime numbers, LabVIEW and
LabWindows/CVI uses a highly efficient Cooley-Tukey mixed-radix FFT algorithm. Otherwise (for large prime sizes),
LabVIEW uses other algorithms to compute the discrete Fourier transform (DFT), and these methods often take
considerably longer. For example, the time required to compute a 1000-point and 1024-point FFT are nearly the same,
but a 1023-point FFT may take twice as long to compute. 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.
Refer to the
Computing the Amplitude and Phase Spectrums
topic in the
LabVIEW Help
(linked below) for the most updated information about using the FFT for computations.
www.ni.com
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.
Refer to the
Converting to Logarithmic Units
topic in the
LabVIEW Help
(linked below) for the most updated information about converting to logarithmic units.
www.ni.com
Figure 4. Alias Frequencies Resulting from Sampling a Signal at 100 Hz That Contains Frequency Components
Greater than or Equal to 50 Hz
Before a signal is digitized, you can prevent aliasing by using antialiasing filters to attenuate the frequency components
at and above half the sampling frequency to a level below the dynamic range of the analog-to-digital converter (ADC).
For example, if the digitizer has a full-scale range of 80 dB, frequency components at and above half the sampling
frequency must be attenuated to 80 dB below full scale.
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.
www.ni.com
Figure 5. Bandwidth of PCI-4450 Family Input Versus Frequency, Normalized to Sampling Rate
10
www.ni.com
At a sampling frequency of 51.2 kHz, these boards can perform frequency measurements in the range of DC to 23.75
kHz. Amplitude flatness is 0.1 dB maximum from DC to 23.75 kHz. Refer to the PCI-4451/4452/4453/4454 User
Manual for more information about these boards.
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 signal-to-total-harmonic-distortion (THD)-plus-noise ratio, which excludes intermodulation distortion, is 90 dB
from 0 to 20 kHz. THD is a measure of the amount of distortion introduced into a signal because of the nonlinear
behavior of the acquisition front end. This harmonic distortion shows up as harmonic energy added to the spectrum for
each of the discrete frequency components present in the input signal.
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
11
www.ni.com
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.
Figure 6. PCI-4450 Family Spectrum Plot with 997 Hz Input at Full Scale (Full Scale = 0 dB) < /div > < /DIV >
See Also:
PCI-4451/4452/4453/4454 User Manual
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.
12
www.ni.com
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 7. Power Spectrum of 1 Vrms Signal at 256 Hz with Uniform, Hann, and Flat Top Windows
13
www.ni.com
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
In addition to causing amplitude accuracy errors, spectral leakage can obscure adjacent frequency peaks. Figure 9
shows the spectrum for two close frequency components when no window is used and when a Hann window is used.
14
www.ni.com
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
15
www.ni.com
16
www.ni.com
Uniform (None)
Hanning (Hann)
Hamming
Blackman-Harris
Exact Blackman
Blackman
Flat Top
0.88
1.44
1.30
1.62
1.61
1.64
2.94
1.21
2.00
1.81
2.27
2.25
2.30
3.56
-13
-32
-43
-71
-67
-58
-44
20
60
20
20
20
60
20
Refer to the
Characteristics of Different Smoothing Windows
topic in the
LabVIEW Help
(linked below) for the most updated information about window characteristics.
Window
Hann
Flat Top
Hann
Uniform
Uniform, Hamming
Force
18
www.ni.com
Response signals
Unknown content
Exponential
Hann
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.
Table 3. Correction Factors and Worst-Case Amplitude Errors for Windows
Window
Scaling Factor
Noise Power
Worst-Case Amplitude
Uniform (none)
Hann
Hamming
Blackman-Harris
Exact Blackman
Blackman
Flat Top
(Coherent Gain)
1.00
0.50
0.54
0.42
0.43
0.42
0.22
Bandwidth
1.00
1.50
1.36
1.71
1.69
1.73
3.77
Error (dB)
3.92
1.42
1.75
1.13
1.15
1.10
< 0.01
Refer to the
Characteristics of Different Smoothing Windows
topic in the
LabVIEW Help
(linked below) for the most updated information about window characteristics.
www.ni.com
picket-fence effect explained in the Window Characteristics section of this application note.
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.
where j is the array index of the apparent peak of the frequency of interest and
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)
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.
Refer to the
Computations on the Spectrum
topic in the
LabVIEW Help
(linked below) for the most updated information about estimating power and frequency.
20
www.ni.com
The spectral density format is appropriate for random or noise signals but inappropriate for discrete frequency
components because the latter theoretically have zero bandwidth.
21
www.ni.com
Refer to the
Computations on the Spectrum
topic in the
LabVIEW Help
(linked below) for the most updated information about computing noise levels and the power spectral density.
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.
Refer to the
Cross Power Spectrum
conceptual topic in the
LabVIEW Help
(linked below) for the most updated information about the cross power spectrum.
22
www.ni.com
Three useful functions for characterizing the frequency response of a network are the frequency response, impulse
response, and coherence functions.
The frequency response of a network is measured by applying a stimulus to the network as shown in Figure 12 and
computing the frequency response from the stimulus and response signals.
www.ni.com
The result is a time-domain function. To average multiple readings, take the inverse FFT of the averaged frequency
response function.
Refer to the
Frequency Response and Network Analysis
topic in the
LabVIEW Help
(linked below) for the most updated information about the impulse response function.
Coherence Function
The coherence function is often used in conjunction with the frequency response function as an indication of the quality
of the frequency response 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
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, SAB(f), average
it in the complex form then convert to magnitude and phase as described in the Frequency Response 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.
Refer to the
Frequency Response and Network Analysis
topic in the
LabVIEW Help
24
www.ni.com
(linked below) for the most updated information about the coherence function.
Conclusion
There are many issues to consider when analyzing and measuring signals from plug-in DAQ devices. Unfortunately, it
is easy to make incorrect spectral measurements. Understanding the basic computations involved in FFT-based
measurement, knowing how to prevent antialiasing, properly scaling and converting to different units, choosing and
using windows correctly, and learning how to use FFT-based functions for network measurement are all critical to the
success of analysis and measurement tasks. Being equipped with this knowledge and using the tools discussed in this
application note can bring you more success with your individual application.
Related Links
LabVIEW Help: Power Spectrum
LabVIEW Help: Computing the Amplitude and Phase Spectrums
LabVIEW Help: Converting to Logarithmic Units
LabVIEW Help: Spectral Leakage
LabVIEW Help: Windowing Signals
LabVIEW Help: Characteristics of Different Smoothing Windows
LabVIEW Help: Computations on the Spectrum
LabVIEW Help: Cross Power Spectrum
LabVIEW Help: Frequency Response and Network Analysis
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.
Horowitz, Paul, and Hill, Winfield, The Art of Electronics, 2nd Edition, Cambridge University Press, 1989.
25
www.ni.com
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, Brul and Kjr, September 1979.
The Fundamentals of Signal Analysis, Application Note 243, Hewlett-Packard, 1985.
26
www.ni.com