The algorithm used to transform samples of the data from the time domain into the frequency domain is the discrete Fourier transform (DFT). The DFT establishes the relationship between the samples of a signal in the time domain and their representation in the frequency domain. The DFT is widely used in the fields of spectral analysis, applied mechanics, acoustics, medical imaging, numerical analysis, instrumentation, and telecommunications. The following figure illustrates using the DFT to transform data from the time domain into the frequency domain.
Suppose you obtained N samples of a signal from a DAQ device. If you apply the DFT to N samples of this time-domain representation of the signal, the result also is of length N samples, but the information it contains is of the frequency-domain representation.
If a signal is sampled at a given sampling rate, Equation A defines the time interval between the samples, or the sampling interval.
Δt = 1/fs | (A) |
where Δt is the sampling interval and fs is the sampling rate in samples per second (S/s).
The sampling interval is the smallest frequency that the system can resolve through the DFT or related routines.
Equation B defines the DFT. The equation results in X[k], the frequency-domain representation of the sample signal.
![]() |
(B) |
where x[i] is the time-domain representation of the sample signal and N is the total number of samples. Both the time domain x and the frequency domain X have a total of N samples.
Similar to the time spacing of Δt between the samples of x in the time domain, you have a frequency spacing, or frequency resolution, between the components of X in the frequency domain, which Equation C defines.
Δf = fs/N = 1/NΔt | (C) |
where Δf is the frequency resolution, fs is the sampling rate, N is the number of samples, Δt is the sampling interval, and NΔt is the total acquisition time.
To improve the frequency resolution, that is, to decrease Δf, you must increase N and keep fs constant or decrease fs and keep N constant. Both approaches are equivalent to increasing NΔt, which is the time duration of the acquired samples.
The following example uses Equation B to calculate the DFT for a DC signal. This example uses the following assumptions:
x[0] = x[1] = x[3] = x[4] = 1 | (D) |
The DFT calculation makes use of Euler's identity, which is given by the following equation.
exp(–iθ) = cos(θ) – jsin(θ)
If you use Equation B to calculate the DFT of the sequence shown in the previous figure and use Euler's identity, you get the following equations.
where X[0] is the DC component and N is the number of samples.
Therefore, except for the DC component, all other values for the sequence shown in the previous figure are zero, which is as expected. However, the calculated value of X[0] depends on the value of N. Because in this example N = 4, X[0] = 4. If N = 10, the calculation results in X[0] = 10. This dependency of X[ ] on N also occurs for the other frequency components. Therefore, you usually divide the DFT output by N to obtain the correct magnitude of the frequency component.
N samples of the input signal result in N samples of the DFT. That is, the number of samples in both the time and frequency representations is the same. Equation B shows that regardless of whether the input signal x[i] is real or complex, X[k] is always complex, although the imaginary part may be zero. In other words, every frequency component has a magnitude and phase.
Normally the magnitude of the spectrum is displayed. The magnitude is the square root of the sum of the squares of the real and imaginary parts.
The phase is relative to the start of the time record or relative to a single-cycle cosine wave starting at the beginning of the time record. Single-channel phase measurements are stable only if the input signal is triggered. Dual-channel phase measurements compute phase differences between channels so if the channels are sampled simultaneously, triggering usually is not necessary.
The phase is the arctangent of the ratio of the imaginary and real parts and is usually between π and –π radians, or 180 and –180 degrees.
For real signals (x[i] real), such as those you obtain from the output of one channel of a DAQ device, the DFT is symmetric with properties given by the following equations.
|X[k]| = |X[N – k]|
phase(X[k]) = –phase(X[N – k])
The magnitude of X[k] is even symmetric, and phase(X[k]) is odd symmetric. An even symmetric signal is symmetric about the y-axis, and an odd symmetric signal is symmetric about the origin. The following figure illustrates even and odd symmetry.
Because of this symmetry, the N samples of the DFT contain repetition of information. Because of this repetition of information, only half of the samples of the DFT actually need to be computed or displayed because you can obtain the other half from this repetition. If the input signal is complex, the DFT is asymmetrical, and you cannot use only half of the samples to obtain the other half.