Practical application of the Fourier transform for signal analysis. Introduction for beginners

I believe that everything in general terms know about the existence of such a wonderful mathematical tool as the Fourier transform. However, in universities, for some reason, it is taught so badly that relatively few people understand how this transformation works and how it should be used correctly. Meanwhile, the mathematics of this transformation is surprisingly beautiful, simple and elegant. I invite everyone to learn a little more about the Fourier transform and the related topic of how analog signals can be effectively converted into digital ones for computational processing.

Without using complex formulas and matlab, I will try to answer the following questions:

  • FT, DTF, DTFT - what are the differences and how do seemingly completely different formulas give such conceptually similar results?
  • How to correctly interpret Fast Fourier Transform (FFT) results
  • What to do if a signal of 179 samples is given and the FFT requires a sequence of length equal to the power of two as input
  • Why, when trying to get the spectrum of a sinusoid using Fourier, instead of the expected single “stick”, a strange squiggle comes out on the graph and what can be done about it
  • Why analog filters are placed before the ADC and after the DAC
  • Is it possible to digitize an ADC signal with a frequency higher than half the sampling rate (the school answer is incorrect, the correct answer is possible)
  • How the digital sequence restores the original signal

I will proceed from the assumption that the reader understands what an integral is, a complex number (as well as its modulus and argument), convolution of functions, plus at least “on the fingers” imagines what the Dirac delta function is. Do not know - it does not matter, read the above links. By “product of functions” in this text, I will always mean “pointwise multiplication”

We should probably start with the fact that the usual Fourier transform is some kind of thing that, as you might guess from the name, transforms one function into another, that is, assigns to each function of a real variable x (t) its spectrum or Fourier image y (w):

If we give analogies, then an example of a transformation similar in meaning can be, for example, differentiation, which turns a function into its derivative. That is, the Fourier transform is, in fact, the same operation as taking the derivative, and it is often denoted in a similar way, drawing a triangular “cap” over the function. Only unlike differentiation, which can also be defined for real numbers, the Fourier transform always “works” with more general complex numbers. Because of this, problems constantly arise with the display of the results of this transformation, since complex numbers are determined not by one, but by two coordinates on a graph operating with real numbers. The most convenient way, as a rule, is to represent complex numbers as a module and an argument and draw them separately as two separate graphs:

The graph of the argument of a complex value is often referred to in this case as the “phase spectrum”, and the graph of the modulus is often called the “amplitude spectrum”. The amplitude spectrum, as a rule, is of much greater interest, and therefore the “phase” part of the spectrum is often skipped. In this article, we will also focus on “amplitude” things, but we should not forget about the existence of the missing phase part of the graph. In addition, instead of the usual modulus of a complex value, its logarithm multiplied by 10 is often drawn. The result is a logarithmic plot, the values ​​​​on which are displayed in decibels (dB).

Please note that not very much negative numbers logarithmic graph (-20 dB or less) at the same time correspond to almost zero numbers on a regular chart. Therefore, long and wide “tails” of various spectra on such graphs, when displayed in “ordinary” coordinates, as a rule, practically disappear. The convenience of such a seemingly strange representation arises from the fact that the Fourier transforms of various functions often need to be multiplied with each other. With such a pointwise multiplication of complex-valued Fourier images, their phase spectra are added, and their amplitude spectra are multiplied. The first is easy to do, while the second is relatively difficult. However, the logarithms of the amplitude are added when multiplying the amplitudes, so the logarithmic amplitude graphs can, like the phase graphs, simply be added point by point. In addition, in practical problems it is often more convenient to operate not with the "amplitude" of the signal, but with its "power" (the square of the amplitude). On the logarithmic scale, both graphs (both amplitude and power) look identical and differ only in the coefficient - all values ​​on the power graph are exactly twice as large as on the amplitude scale. Accordingly, to plot the frequency distribution of power (in decibels), you can not square anything, but calculate the decimal logarithm and multiply it by 20.

Are you bored? Wait, just a little more, with the boring part of the article explaining how to interpret charts, we will soon finish :). But before that, one very important thing to understand is that although all the spectrum plots above were drawn for some limited ranges of values ​​(in particular, positive numbers), all of these plots actually continue into plus and minus infinity. Graphs simply depict some “most meaningful” part of the graph, which is usually mirrored for negative values parameter and is often periodically repeated with some step, if we consider it on a larger scale.

Having decided on what is drawn on the graphs, let's get back to the Fourier transform itself and its properties. There are several different ways how to define this transformation differing in small details (different normalizations). For example, in our universities, for some reason, they often use the normalization of the Fourier transform that determines the spectrum in terms of angular frequency (radians per second). I will use a more convenient western formulation that defines the spectrum in terms of the usual frequency (hertz). The direct and inverse Fourier transforms in this case are defined by the formulas on the left, and some of the properties of this transform that we need are a list of seven items on the right:

The first of these properties is linearity. If we take some linear combination of functions, then the Fourier transform of this combination will be the same linear combination of the Fourier images of these functions. This property allows you to reduce complex functions and their Fourier transforms to simpler ones. For example, the Fourier transform of a sinusoidal function with frequency f and amplitude a is a combination of two delta functions located at points f and -f and with coefficient a/2:

If we take a function consisting of the sum of a set of sinusoids with different frequencies, then, according to the linearity property, the Fourier transform of this function will consist of the corresponding set of delta functions. This allows us to give a naive, but visual interpretation of the spectrum according to the principle “if in the spectrum of a function frequency f corresponds to amplitude a, then the original function can be represented as a sum of sinusoids, one of which will be a sinusoid with frequency f and amplitude 2a”. Strictly speaking, this interpretation is incorrect, since the delta function and the point on the graph are completely different things, but as we will see further, for discrete Fourier transforms, it will not be so far from the truth.

The second property of the Fourier transform is the independence of the amplitude spectrum from the time shift of the signal. If we move the function to the left or right along the x-axis, then only its phase spectrum will change.

The third property - stretching (compression) of the original function along the time axis (x) proportionally compresses (stretches) its Fourier transform along the frequency scale (w). In particular, the spectrum of a signal of finite duration is always infinitely wide, and vice versa, the spectrum of finite width always corresponds to a signal of unlimited duration.

The fourth and fifth properties are perhaps the most useful of all. They make it possible to reduce the convolution of functions to the pointwise multiplication of their Fourier transforms, and vice versa - the pointwise multiplication of functions to the convolution of their Fourier transforms. A little further I will show how convenient it is.

The sixth property speaks about the symmetry of the Fourier images. In particular, it follows from this property that in the Fourier transform of a real-valued function (i.e., any “real” signal), the amplitude spectrum is always even function, and the phase spectrum (if it is reduced to the range -pi...pi) is odd. It is for this reason that the negative part of the spectrum is almost never drawn on the spectrum graphs - for real-valued signals, it does not provide any new information (but, I repeat, it is not zero either).

Finally, the last, seventh property, says that the Fourier transform preserves the “energy” of the signal. It makes sense only for signals of finite duration, whose energy is finite, and says that the spectrum of such signals at infinity is rapidly approaching zero. It is precisely because of this property that, as a rule, only the “main” part of the signal is depicted on the spectrum graphs, which carries the lion's share of energy - the rest of the graph simply tends to zero (but, again, it is not zero).

Armed with these 7 properties, let's take a look at the mathematics of "digitizing" a signal to translate a continuous signal into a sequence of digits. To do this, we need to take a function known as the “Dirac comb”:

A Dirac comb is simply a periodic sequence of unity delta functions, starting at zero and proceeding with step T. To digitize signals, T is chosen as small as possible, T<<1. Фурье-образ этой функции - тоже гребенка Дирака, только с гораздо большим шагом 1/T и несколько меньшим коэффициентом (1/T). С математической точки зрения, дискретизация сигнала по времени - это просто поточечное умножение исходного сигнала на гребенку Дирака. Значение 1/T при этом называют частотой дискретизации:

Instead of a continuous function, after such multiplication, a sequence of delta pulses of a certain height is obtained. In this case, according to property 5 of the Fourier transform, the spectrum of the resulting discrete signal is the convolution of the original spectrum with the corresponding Dirac comb. It is easy to understand that, based on the properties of convolution, the spectrum of the original signal is, as it were, “copied” an infinite number of times along the frequency axis with a step of 1/T, and then summed up.

Note that if the original spectrum had a finite width and we used a sufficiently high sampling rate, then the copies of the original spectrum will not overlap and, therefore, will not be added to each other. It is easy to understand that it will be easy to restore the original spectrum from such a “folded” spectrum - it will be enough just to take the component of the spectrum in the region of zero, “cutting off” the extra copies that go to infinity. The simplest way to do this is to multiply the spectrum by a rectangular function equal to T in the range -1/2T...1/2T and zero outside this range. A similar Fourier transform corresponds to the function sinc (Tx) and according to property 4, such a multiplication is equivalent to convolution of the original sequence of delta functions with the function sinc(Tx)



That is, using the Fourier transform, we got a way to easily restore the original signal from a time-sampled one, which works provided that we use a sampling frequency that is at least twice (due to the presence of negative frequencies in the spectrum) the maximum frequency present in the original signal. This result is widely known and is called the Kotelnikov / Shannon-Nyquist theorem. However, as it is easy to see now (understanding the proof), this result, contrary to a widespread misconception, determines sufficient, but not necessary condition for restoring the original signal. All we need is to ensure that the part of the spectrum of interest to us after sampling the signal does not overlap each other, and if the signal is sufficiently narrow-band (has a small “width” of the non-zero part of the spectrum), then this result can often be achieved even at a sampling rate much lower than twice the maximum signal frequency. This technique is called “undersampling” (subsampling, bandpass sampling) and is quite widely used in the processing of all kinds of radio signals. For example, if we take an FM radio operating in the frequency band from 88 to 108 MHz, then an ADC with a frequency of only 43.5 MHz can be used to digitize it instead of the 216 MHz assumed by the Kotelnikov theorem. In this case, however, you need a high-quality ADC and a good filter.

I note that “duplication” of high frequencies by frequencies of lower orders (aliasing) is a direct property of signal sampling, irreversibly “spoiling” the result. Therefore, if high-order frequencies can in principle be present in the signal (that is, almost always), an analog filter is placed in front of the ADC, which “cuts off” everything superfluous directly in the original signal (since it will be too late to do this after sampling). The characteristics of these filters, as analog devices, are not ideal, so some signal “damage” still occurs, and in practice it follows that the highest frequencies in the spectrum are usually unreliable. To mitigate this problem, it is not uncommon to sample the signal at an oversampled rate, while setting the analog input filter to a lower bandwidth and using only the lower part of the ADC's theoretically available frequency range.

Another common misconception, by the way, is when the signal at the output of the DAC is drawn in “steps”. “Steps” correspond to the convolution of the sampled sequence of signals with a rectangular function of width T and height 1:

With such a transformation, the signal spectrum is multiplied by the Fourier transform of this rectangular function, and for a similar rectangular function it is again sinc(w), “stretched” the stronger, the smaller the width of the corresponding rectangle. The spectrum of the sampled signal with a similar "DAC" is pointwise multiplied by this spectrum. In this case, unnecessary high frequencies with “extra copies” of the spectrum are not completely cut off, and the upper part of the “useful” part of the spectrum, on the contrary, is weakened.

In practice, of course, no one does this. There are many different approaches to building a DAC, but even in the most similar weighting type DACs, on the contrary, rectangular pulses in the DAC are chosen as short as possible (approaching a real sequence of delta functions) in order to avoid unnecessary suppression of the useful part of the spectrum. “Extra” frequencies in the resulting broadband signal are almost always damped by passing the signal through an analog low-pass filter, so that there are no “digital steps” either “inside” the converter, or, moreover, at its output.

However, let's go back to the Fourier transform. The Fourier transform described above applied to a pre-sampled sequence of signals is called the Discrete Time Fourier Transform (DTFT). The spectrum obtained by such a transformation is always 1/T-periodic, so the DTFT spectrum is completely determined by its values ​​on the segment )