Fourier series

One type of spectral analysis is called Fourier or harmonic decomposition. It’s based on the theory, that any periodic function can be expressed as the sum, or series of sinusoidal functions. If a periodic function is expressed this way, each component in the series must be periodic over the same interval as the original function. The components are integer multiples or harmonics of the original function’s fundamental (base) frequency. This decomposition is described by the following formulas:

Fourier00000000.gif, or in complex form Fourier00000001.gif, where Fourier00000002.gif, and Fourier00000003.gif are the Fourier coefficients.

Let us see this decomposition in case of some practical waveforms:

Triangle wave

Fourier00000004.gif

Square wave

Fourier00000005.gif

Let us demonstrate the above theorem with Tina in case of a square wave of f=1kHz frequency and 1V amplitude up to three sine waves. The easiest way is to put together a simple circuit (fourex1.sch). The circuit consists of three sine wave generators connected in series and the reference square wave generator. The frequencies of the sine wave generators are Fourier00000006.gif, Fourier00000007.gif and Fourier00000008.gif, however the amplitudes are Fourier00000009.gif Fourier00000010.gifand Fourier00000011.gif according to the above formula.

Fourier00000012.gif

The result of the transient analysis can be seen on the following figure.

Fourier00000013.gif

Note that the above figure was entirely made by Tina using its Equation Editor in the Diagram Window. For example the Fourier00000014.gifis described in the following way in the Equation Editor’s text mode: \i(f,1)=\f(4,\s(p))sin(\s(w)t) as it can be seen on the next figure.

Fourier00000015.gif

If you press the View button Fourier00000016.gif you can preview the formula in the Equation Editor. Press the Edit button Fourier00000017.gif to return into the text mode if you want to make further changes. Finally press the Copy button Fourier00000018.gif to place the formula in the Diagram Window.

Fourier00000019.gif

Obviously if you connected more than 3 generators in series, you would have achieved a better match. There is an easy way to demonstrate this statement. Using Tina’s Interpreter you can easily write a function that calculates the sum of any number of sine waves (fourex1.ipr).

Function Square(t, n);
{Sum of n sine waves, n: number of sine waves, t: time}
Begin
  f := 1k;
  w := 2 * pi * f;
  x := 0;
  For i := 0 To n - 1 Do
  x := x + 1 / (2 * i + 1) * sin((2 * i + 1) * w * t);
  Square := 4 / pi * x;
End;
{Sum of 20 sine waves}
Draw(Square(Time, 20), Square);

To run the above example invoke the Interpreter from the Tools menu, type in the above text or read in fourex1.ipr by selecting the Open command from the File menu. If you press the Run Fourier00000020.gif button after a short calculation the following function appears:

Fourier00000021.gif

The more sine waves you would sum up the better match you would get. Note however the small peaks at the edges of the square wave. This is called Gibbs phenomenon. According to the mathematical theory the Fourier series can not approximate properly non-continuous functions in the point of discontinuity. In case of a square wave there will always be 18% overrun at the edges at any number of approximating sine waves. Let us demonstrate this with 100 harmonics; simple change 20 to 100 in the Draw command of the above example (fourex1.ipr)

Fourier00000022.gif

However there are methods which improve the convergence of the Fourier series near the discontinuity. The essence of these techniques is to modify the Fourier coefficients by multiplying each coefficient by a weight factor. This method is also called window function technique. Two Hungarian mathematicians - Fejér, and Lánczos - invented such window functions that are commonly used in practice.

In practice however there are no discontinuous waveforms though to the rise/fall time could be very short in comparison to the period time. This means, that the Fourier series will always converge. Let us demonstrate this with the approximation of the triangular waveform with just 3 harmonics using the above circuit. Change the amplitude of the sinusoidal generators to Fourier00000023.gif, Fourier00000024.gif and Fourier00000025.gif. Change the waveform of the reference generator to triangle wave (fourex12.sch).

Fourier00000026.gif

In practice of course you use the Fourier series option of TINA in opposite direction. You have a periodic function and you want to know the Fourier components. To get them in Tina first you have to run a transient analysis and then in the appearing Diagram window select a curve. Then in the diagram window you have to select Fourier series from the Process menu. After selecting this menu item Tina performs a harmonic decomposition, calculating the Fourier coefficients for the sinusoidal components of any voltage or current. After you select Fourier series a dialog box appears, where you have to set the sampling start time, the base frequency, the number of samples, the number of harmonics, and the format.

Example: Let us determine the Fourier decomposition of the previous square wave (f=1kHz, A=1V). We will compare the theoretical decomposition with the result calculated by TINA.

The Fourier series of a square wave function is Fourier00000027.gif.

Because square wave function is an odd function Fourier00000028.gif, all the coefficients Fourier00000029.gif, and Fourier00000030.gif, too. Comparing the above function with the definition of the Fourier series it’s quite clear that: Fourier00000031.gif, Fourier00000032.gif, Fourier00000033.gif, Fourier00000034.gif, Fourier00000035.gif. In Tina we get approximately the same result. However due to numerical inaccuracy we don’t get exactly 0 for the theoretically 0 coefficients. If you examine these values more carefully you’ll see, that they are not significant because they are Fourier00000036.gif times less than the fundamental value.

Load this example (fourex2.sch). Run transient analysis then select the appearing square wave and choose Fourier series from the Process menu. In the dialog box change the default format from complex representation / Fourier00000037.gif/ to real representation /Fourier00000038.gif/.

Fourier00000039.gif

If you have set all the parameters, press Calculate. At the bottom of the dialog box the Fourier coefficients appear. Tina allows you to use these values in other programs. Every time you press Calculate the coefficients are placed not only at the bottom of the dialog box but on the clipboard, as well. You can import this table of Fourier components in other programs, for example Word or Excel to process.

Harmonics

Amplitude (A)

Amplitude (B)

0.

0

0

1.

976.56u

1.27

2.

-1.15n

-749.01n

3.

976.56u

424.41m

4.

-4.6n

-1.5u

5.

976.56u

254.64m

It’s also possible to evaluate the above result graphically. You only need to press Draw, then Tina generates you a diagram with the Fourier coefficients.

Fourier00000040.gif

You can also get complex Fourier components with Tina. To do this select the complex representation in the Fourier series dialog box and press Calculate again. On the following three figures you’ll see the harmonic decomposition of the same sine wave (f=1kHz, A=1V) but this time using the complex representation. On the first figure the dialog box can be seen, on the next the Fourier coefficients as they are placed on the clipboard, and on the last the graphical representation of the result.

Fourier00000041.gif

Harmonics

Amplitude (A)

Phase (ø)

0.

0

0

1.

636.62m

-89.96

2.

374.51n

90.09

3.

212.21m

-89.87

4.

749.01n

90.18

5.

127.32m

-89.78

Fourier00000042.gif

To compare this result with the previous one we have to perform a simple mathematical transformation. Using the Euler-formula: Fourier00000043.gif or vice versa Fourier00000044.gif. From this we get, that Fourier00000045.gif, Fourier00000046.gif, Fourier00000047.gif, Fourier00000048.gif, Fourier00000049.gif. Again it is important to mention, that due to numerical inaccuracy we don’t get exactly 0 for the theoretically 0 coefficients. It’s especially true in case of the phase values. As harmonic magnitudes become small it becomes difficult to determine phase. Again, this is a numerical problem only.