Amplitude vector. Graphic representation of harmonic vibrations

The addition of several oscillations of the same direction (or, what is the same, the addition of several harmonic functions) is greatly facilitated and becomes clear if the oscillations are depicted graphically in the form of vectors on a plane.

Let's take an axis, which we will denote as “x”. From point O, taken on the axis, at an angle a equal to the initial phase of oscillations, we plot a vector of length A (Fig. 8.3). Let's project vector A onto the x axis, we get x 0 =A cos a is the initial displacement of the oscillating point from the equilibrium position. Let's rotate this vector counterclockwise with angular velocity w 0 . The position of this vector at any time will be characterized by angles equal to:

w 0 t 1 +a; w 0 t 2 +a; w 0 t 3 +a; etc.

And the projection of this vector will move along the “x” axis in the range from –A to +A. Moreover, the coordinate of this projection will change over time according to the law:

.

Consequently, the projection of the end of the vector onto some arbitrary axis will perform a harmonic oscillation with an amplitude equal to length vector, circular frequency equal to the angular velocity of rotation of the vector and initial phase equal to the angle, formed by a vector with axis in starting moment time.

So, a harmonic oscillation can be specified using a vector, the length of which is equal to the amplitude of the oscillation, and the direction of the vector forms an angle with the “x” axis equal to the initial phase of the oscillation.

Let's consider the addition of two harmonic oscillations of the same direction and the same frequency. The displacement of the oscillating body “x” will be the sum of the displacements x 1 and x 2, which will be written as follows:

Let's represent both oscillations using vectors and (Fig. 8.4) Using the rules for adding vectors, we construct the resulting vector. The projection of this vector onto the X axis will be equal to the sum of the projections of the summand vectors: x=x 1 +x 2. Therefore, the vector represents the resulting vibration. This vector rotates with the same angular velocity w 0 as the vectors and , so the resulting motion will be a harmonic oscillation c with frequency w 0 , amplitude “a” and initial phase a. From the construction it follows that

So, the representation of harmonic oscillations by means of vectors makes it possible to reduce the addition of several oscillations to the operation of adding vectors. This method is more simple and clear than using trigonometric transformations.

Let's analyze the expression for amplitude. If the phase difference of both oscillations a 2 - a 1 = 0, then the amplitude of the resulting oscillation is equal to the sum ( A 2 + A 1). If the phase difference a 2 - a 1 = +p or -p, i.e. the oscillations are in antiphase, then the amplitude of the resulting oscillation is equal to .

If the oscillation frequencies x 1 and x 2 are not the same, the vectors and will rotate with at different speeds. In this case, the resulting vector pulsates in magnitude and rotates at a variable speed. Therefore, the resulting motion will be in this case Not Just harmonic vibration, but some complex oscillatory process.


Harmonic vibrations

Those. in fact, the sine graph is obtained from the rotation of the vector, which is described by the formula:

F(x) = A sin (ωt + φ),

Where A is the length of the vector (oscillation amplitude), φ is the initial angle (phase) of the vector at zero time, ω - angular velocity rotation, which is equal to:

ω=2 πf, where f is the frequency in Hertz.

As we see, knowing the signal frequency, amplitude and angle, we can construct a harmonic signal.

The magic begins when it turns out that the representation of absolutely any signal can be represented as a sum (often infinite) of different sinusoids. In other words, in the form of a Fourier series.
I will give an example from the English Wikipedia. Let's take a sawtooth signal as an example.


Ramp signal

Its amount will be represented by the following formula:

If we add up one by one, take first n=1, then n=2, etc., we will see how our harmonic sinusoidal signal gradually turns into a saw:

This is probably most beautifully illustrated by one program I found on the Internet. It was already said above that the sine graph is a projection of a rotating vector, but what about more complex signals? This, oddly enough, is a projection of many rotating vectors, or rather their sum, and it all looks like this:


Vector drawing saw.

In general, I recommend going to the link yourself and trying to play with the parameters yourself and see how the signal changes. IMHO I have never seen a more visual toy for understanding.

It should also be noted that there is an inverse procedure that allows you to obtain frequency, amplitude and initial phase (angle) from a given signal, which is called the Fourier Transform.


Fourier series expansion of some well-known periodic functions(from here)

I won’t dwell on it in detail, but I will show how it can be applied in life. In the bibliography I will recommend where you can read more about the materiel.

Let's move on to practical exercises!

It seems to me that every student asks a question while sitting at a lecture, for example on mathematics: why do I need all this nonsense? And as a rule, having not found an answer in the foreseeable future, unfortunately, he loses interest in the subject. So I'll show you right away practical application this knowledge, and you will master this knowledge yourself :).

I will implement everything further on my own. I did everything, of course, under Linux, but did not use any specifics; in theory, the program will compile and run under other platforms.

First, let's write a program to generate an audio file. The wav file was taken as the simplest one. You can read about its structure.
In short, the structure of a wav file is described as follows: a header that describes the file format, and then there is (in our case) an array of 16-bit data (spike) with a length of: sampling_frequency*t seconds or 44100*t pieces.

An example was taken to generate a sound file. I modified it a little, corrected errors, and the final version with my edits is now on Github here

Let's generate a two-second sound file with a pure sine wave with a frequency of 100 Hz. To do this, modify the program as follows:

#define S_RATE (44100) //sampling frequency #define BUF_SIZE (S_RATE*10) /* 2 second buffer */ …. int main(int argc, char * argv) ( ... float amplitude = 32000; //take the maximum possible amplitude float freq_Hz = 100; //signal frequency /* fill buffer with a sine wave */ for (i=0; i

Please note that the formula for pure sine corresponds to the one we discussed above. The amplitude of 32000 (32767 could have been taken) corresponds to the value that a 16-bit number can take (from minus 32767 to plus 32767).

As a result, we get the following file (you can even listen to it with any sound-reproducing program). Let's open this audacity file and see that the signal graph actually corresponds to a pure sine wave:


Pure tube sine

Let's look at the spectrum of this sine (Analysis->Plot spectrum)


Spectrum graph

A clear peak is visible at 100 Hz ( logarithmic scale). What is spectrum? This is the amplitude-frequency characteristic. There is also a phase-frequency characteristic. If you remember, I said above that to build a signal you need to know its frequency, amplitude and phase? So, you can get these parameters from the signal. IN in this case We have a graph of frequencies corresponding to amplitude, and the amplitude is not in real units, but in Decibels.

I understand that in order to explain how the program works, it is necessary to explain what the fast Fourier transform is, and this is at least one more article.

First, let's allocate the arrays:

C = calloc(size_array*2, sizeof(float)); // array of rotation factors in = calloc(size_array*2, sizeof(float)); //input array out = calloc(size_array*2, sizeof(float)); //output array

Let me just say that in the program we read data into an array of length size_array (which we take from the header of the wav file).

While(fread(&value,sizeof(value),1,wav)) ( in[j]=(float)value; j+=2; if (j > 2*size_array) break; )

Array for fast conversion The Fourier must be a sequence (re, im, re, im,… re, im), where fft_size=1<< p - число точек БПФ. Объясняю нормальным языком:
is an array of complex numbers. I’m even afraid to imagine where the complex Fourier transform is used, but in our case, our imaginary part is equal to zero, and the real part is equal to the value of each point of the array.
Another feature of the fast Fourier transform is that it calculates arrays that are multiples only of powers of two. As a result, we must calculate the minimum power of two:

Int p2=(int)(log2(header.bytes_in_data/header.bytes_by_capture));

The logarithm of the number of bytes in the data divided by the number of bytes at one point.

After this, we calculate the rotation factors:

Fft_make(p2,c); // function for calculating rotation factors for FFT (the first parameter is a power of two, the second is an allocated array of rotation factors).

And we feed our just array into the Fourier transformer:

Fft_calc(p2, c, in, out, 1); //(one means we are getting a normalized array).

At the output we get complex numbers of the form (re, im, re, im,… re, im). For those who don’t know what a complex number is, I’ll explain. It’s not for nothing that I started this article with a bunch of rotating vectors and a bunch of GIFs. So, a vector on the complex plane is determined by the real coordinate a1 and the imaginary coordinate a2. Or length (this is amplitude Am for us) and angle Psi (phase).


Vector on the complex plane

Please note that size_array=2^p2. The first point of the array corresponds to a frequency of 0 Hz (constant), the last point corresponds to the sampling frequency, namely 44100 Hz. As a result, we must calculate the frequency corresponding to each point, which will differ by the delta frequency:

Double delta=((float)header.frequency)/(float)size_array; //sampling frequency per array size.

Allocation of the amplitude array:

Double * ampl; ampl = calloc(size_array*2, sizeof(double));

And look at the picture: amplitude is the length of the vector. And we have its projections onto the real and imaginary axis. As a result, we will have a right triangle, and here we remember the Pythagorean theorem, and count the length of each vector, and immediately write it into a text file:

For(i=0;i<(size_array);i+=2) { fprintf(logfile,"%.6f %f\n",cur_freq, (sqrt(out[i]*out[i]+out*out))); cur_freq+=delta; }
As a result, we get a file something like this:

… 11.439514 10.943008 11.607742 56.649738 11.775970 15.652428 11.944199 21.872342 12.112427 30.635371 12.280655 30.329171 12.448883 11.932371 12.617111 20.777617 ...

Let's try!

Now we feed the resulting program that sine sound file

./fft_an ../generate_wav/sin\ 100\ Hz.wav format: 16 bits, PCM uncompressed, channel 1, freq 44100, 88200 bytes per sec, 2 bytes by capture, 2 bits per sample, 882000 bytes in data chunk= 441000 log2=18 size array=262144 wav format Max Freq = 99.928 , amp =7216.136

And we get a text file of the frequency response. We build its graph using a gnuplot

Script for construction:

#! /usr/bin/gnuplot -persist set terminal postscript eps enhanced color solid set output "result.ps" #set terminal png size 800, 600 #set output "result.png" set grid xtics ytics set log xy set xlabel "Freq, Hz" set ylabel "Amp, dB" set xrange #set yrange plot "test.txt" using 1:2 title "AFC" with lines linestyle 1 !}

Please note the limitation in the script on the number of points along X: set xrange . Our sampling frequency is 44100, and if we recall Kotelnikov’s theorem, then the signal frequency cannot be higher than half the sampling frequency, therefore we are not interested in a signal above 22050 Hz. Why this is so, I advise you to read in specialized literature.
So (drum roll), we run the script and see:


Spectrum of our signal

Note the sharp peak at 100 Hz. Don't forget that the axes are on a logarithmic scale! The wool on the right is what I think are Fourier transform errors (windows come to mind here).

Let's indulge?

Come on! Let's look at the spectra of other signals!

There is noise around...
First, let's plot the noise spectrum. The topic is about noise, random signals, etc. worthy of a separate course. But we will touch on it lightly. Let's modify our wav file generation program and add one procedure:

Double d_random(double min, double max) ( return min + (max - min) / RAND_MAX * rand(); )

It will generate a random number within the given range. As a result, main will look like this:

Int main(int argc, char * argv) ( int i; float amplitude = 32000; srand((unsigned int)time(0)); //initialize the random number generator for (i=0; i

Let's generate a file (I recommend listening to it). Let's look at it in audacity.


Signal in audacity

Let's look at the spectrum in the audacity program.


Spectrum

And let's look at the spectrum using our program:


Our spectrum

I would like to draw your attention to a very interesting fact and feature of noise - it contains the spectra of all harmonics. As can be seen from the graph, the spectrum is quite even. Typically, white noise is used for frequency analysis of bandwidth, such as audio equipment. There are other types of noise: pink, blue and others. Homework is to find out how they differ.

What about compote?

Now let's look at another interesting signal - a meander. I gave above a table of expansions of various signals in Fourier series, you look at how the meander is expanded, write it down on a piece of paper, and we will continue.

To generate a square wave with a frequency of 25 Hz, we once again modify our wav file generator:

Int main(int argc, char * argv) ( int i; short int meandr_value=32767; /* fill buffer with a sine wave */ for (i=0; i

As a result, we get an audio file (again, I advise you to listen), which you should immediately watch in audacity


His Majesty - the meander or meander of a healthy person

Let's not languish and take a look at its spectrum:


Meander spectrum

It’s not very clear yet what it is... Let’s take a look at the first few harmonics:


First harmonics

It's a completely different matter! Well, let's look at the sign. Look, we only have 1, 3, 5, etc., i.e. odd harmonics. We see that our first harmonic is 25 Hz, the next (third) is 75 Hz, then 125 Hz, etc., while our amplitude gradually decreases. Theory meets practice!
Now attention! In real life, a square wave signal has an infinite sum of harmonics of higher and higher frequencies, but as a rule, real electrical circuits cannot pass frequencies above a certain frequency (due to the inductance and capacitance of the tracks). As a result, you can often see the following signal on the oscilloscope screen:


Smoker's meander

This picture is just like the picture from Wikipedia, where for the example of a meander, not all frequencies are taken, but only the first few.


The sum of the first harmonics, and how the signal changes

The meander is also actively used in radio engineering (it must be said that this is the basis of all digital technology), and it is worth understanding that with long chains it can be filtered so that the mother does not recognize it. It is also used to check the frequency response of various devices. Another interesting fact is that TV jammers worked precisely on the principle of higher harmonics, when the microcircuit itself generated a meander of tens of MHz, and its higher harmonics could have frequencies of hundreds of MHz, exactly at the operating frequency of the TV, and the higher harmonics successfully jammed the TV broadcast signal.

In general, the topic of such experiments is endless, and you can now continue it yourself.


Book

For those who don’t understand what we’re doing here, or vice versa, for those who understand but want to understand it even better, as well as for students studying DSP, I highly recommend this book. This is a DSP for dummies, which is the author of this post. There, complex concepts are explained in a language accessible even to a child.

Conclusion

In conclusion, I would like to say that mathematics is the queen of sciences, but without real application, many people lose interest in it. I hope this post will encourage you to study such a wonderful subject as signal processing, and analog circuitry in general (plug your ears so your brains don’t leak out!). :)
Good luck!

Tags:

Add tags

Harmonic oscillation x = a Cos(w t+ a) geometrically can be represented by a projection onto an arbitrary direction x vector rotating around a fixed axis with angular velocity w. The length of this vector is equal to the amplitude of the oscillation, and its initial direction forms with the axis x angle equal to the initial phase of oscillation - a. Using this geometric interpretation, we will solve the problem of adding two harmonic oscillations of the same frequency and direction.

x = x 1 + x 2 = a 1 Cos(w t+ a 1) + a 2 Cos(w t+ a 2).

Let's construct a vector (at an angle a 1 to the axis x), representing the first vibration. Let us add to it the vector forming an angle a 2 with the axis x(Fig. 12.8). The sum of the projections of these vectors onto the axis x is equal to the projection onto this axis of the vector equal to the sum and .

x = x 1 + x 2 .

Rice. 12.8

Let us bring this vector diagram into rotation with angular velocity w around an axis passing through the origin of coordinates - point O. In this case, the equality x = x 1 + x 2 will remain unchanged over time, although the projections themselves x, x 1 and x 2 will now pulsate according to a harmonic law with the same frequency w and with initial phases a, a 1 and a 2 - respectively. As a result of the addition of two vibrations:

x 1 = a 1 Cos(w t+ a 1) and x 2 = a 2 Cos(w t+ a 2) a new oscillation occurs x = x 1 + x 2 =

= a Cos(w t+ a), the frequency of which - w – coincides with the frequency of the added oscillations. Its amplitude is equal to the absolute value of the vector, and the initial phase a, as follows from Fig. 12.8, is equal to:

.

To calculate the amplitude " A» total oscillation, we use the cosine theorem:

The amplitude of the resulting oscillation depends not only on the amplitudes of the added oscillations A 1 and A 2, but also on the difference in their initial phases. Oscillation with maximum amplitude, A = a max = a 1 + a 2 occurs when adding in-phase oscillations, that is, when their initial phases coincide: a 1 = a 2.

If the phase difference (a 2 – a 1) = p, then the amplitude of the total oscillation will be minimal a = a min = | a 1 – a 2 |. If the amplitudes of such oscillations occurring in antiphase are equal to ( a 1 = a 2), then the amplitude of the total oscillation will be equal to zero.

We will often use this method of vector diagrams in the future when adding not only oscillations, but also waves.

Lecture 13 “Mechanical vibrations”

Lecture outline

1. Energy of a harmonic oscillator.

2. Natural damped oscillations.

3. Forced vibrations. Resonance. Amplitude and phase of forced oscillations.

The solution to a number of issues, in particular the addition of several oscillations of the same direction (or, what is the same, the addition of several harmonic functions), is greatly facilitated and becomes clear if the oscillations are depicted graphically as vectors on a plane. The diagram obtained in this way is called a vector diagram.

Let's take the axis, which we denote by the letter x (Fig. 55.1). From point O, taken on the axis, we plot a vector of length a, forming an angle a with the axis.

If we bring this vector into rotation with angular velocity , then the projection of the end of the vector will move along the x axis in the range from -a to +a, and the coordinate of this projection will change over time according to the law

Consequently, the projection of the end of the vector onto the axis will perform a harmonic oscillation with an amplitude equal to the length of the vector, with a circular frequency equal to the angular velocity of rotation of the vector, and with an initial phase equal to the angle formed by the vector with the axis at the initial moment of time.

From the above it follows that a harmonic oscillation can be specified using a vector, the length of which is equal to the amplitude of the oscillation, and the direction of the vector forms an angle with the x-axis equal to the initial phase of the oscillation.

Let's consider the addition of two harmonic oscillations of the same direction and the same frequency. The displacement x of the oscillating body will be the sum of the displacements, which will be written as follows:

Let's represent both oscillations using vectors (Fig. 55.2). Let us construct the resulting vector a according to the rules of vector addition.

It is easy to see that the projection of this vector onto the x-axis is equal to the sum of the projections of the summand vectors:

Therefore, vector a represents the resulting oscillation. This vector rotates with the same angular velocity as the vectors so that the resulting motion will be a harmonic oscillation with frequency amplitude a and initial phase a. From the construction it is clear that

So, the representation of harmonic oscillations by means of vectors makes it possible to reduce the addition of several oscillations to the operation of adding vectors. This technique is especially useful, for example, in optics, where light oscillations at a certain point are determined as the result of the superposition of many oscillations arriving at a given point from different parts of the wave front.

Formulas (55.2) and (55.3) can, of course, be obtained by adding expressions (55.1) and making the corresponding trigonometric transformations. But the method we used to obtain these formulas is more simple and clear.

Let's analyze expression (55.2) for amplitude. If the phase difference between both oscillations is zero, the amplitude of the resulting oscillation is equal to the sum of a and a. If the phase difference is equal to or , i.e. both oscillations are in antiphase, then the amplitude of the resulting oscillation is equal to

If the oscillation frequencies are not the same, the vectors a and will rotate at different speeds. In this case, the resulting vector a pulsates in magnitude and rotates at a variable speed. Consequently, the resulting motion in this case will not be a harmonic oscillation, but some complex oscillatory process.



Did you like the article? Share with your friends!