# LTSpice Fourier Series

**Fourier Series**

If the input of your linear circuit is a non-sinusoidal periodic function (e.g.: triangular, rectangular, sawtooth waveform), you will need to apply Fourier Series analysis to your circuit in order to study it.

Briefly, any practical periodic function can be represented as a sum of sinusoids. Such representation, along with the superposition theorem, allows us to find the response of circuits to arbitrary periodic inputs using phasor techniques.

Let's analyze the circuit below that has a sawtooth wave as input and we want to know as an output the current that flows though the circuit. Have in mind that we are interested in study this circuit in steady state and not the transient of the circuit (similarly to phasors analysis).

**LTSpice Circuit**

To create this sawtooth waveform, add a generic voltage source and select the pulse function and enter the desired values for the amplitude and period.

**Transient Analysis**

The transient analysis is straight forward. Include the "** .tran**" spice directive with the desired time parameters and plot the desired output.

**Fourier Coefficients**

To get the Fourier coefficients from the Fourier Analysis, add the "** .four**" spice directive and include the frequency of your input waveform, plus how many Fourier coefficients you are interested in getting, and from which part of the circuit you want those Fourier coefficients from.

The results will not show up automatically. To visualize that information, press "ctrl + L" or go to "view -> SPICE Error Log".

The output results include information about the DC component, the harmonic number, magnitude and respective phase, and the total harmonic distortion.

Note:In this particular case, we are interested in all (odd and even) harmonics from your output answer. This because the sawtooth waveform has both odd and even harmonics. But if your input has only odd or even, you will need to look at the harmonics of interest and ignore the rest. The "" spice directive will always print all harmonic even if they are not relevant for your answer..four

**Other Examples**

**Example 1**

**LTSpice Circuit**

**Transient Analysis**

**Fourier Coefficients**

The triangular waveform is composed only by odd harmonics. The "** .four**" spice directive prints out all harmonics. We are only interested on the odd harmonics. On the picture below I erased the even harmonics so it is easier to follow the desired answer.

**Example 2**

**LTSpice Circuit**

**Transient Analysis**

**Fourier Coefficients**

**LTSpice Simulation Files**

**Spice Components**

**Directions:** Download the spice model and place it in the same project folder that you are working.

**References**

**[Ref 1]***“LTspice tutorial – Ep6 Basics of FFT Analysis and .four Statement“*, FesZ Electronics YouTube Channel [Video]