Signal analysis in the frequency domain with LTspice – Part 2.

In the first part of this article, I showed the usage of the FFT (Fast Fourier Transform) in LTspice briefly, highlighted some details about the various settings affecting the quality of the FFT result and showed the effect of windowing functions, too. In this second part, I will introduce the Fourier series function in LTspice and show an interesting use case for analysis of power line harmonics based on measured current waveforms.

Fourier series

The Fourier series can be used to decompose and analyze periodic signals. It can be calculated in LTspice by adding the .four spice directive to the schematic before performing the transient simulation. The corresponding syntax (see LTspice Help):

.four <frequency> [Nharmonics] [Nperiods] <data trace1> [<data trace2> …]

The frequency parameter defines the fundamental frequency (the lowest frequency of interest). The optional parameter Nharmonics sets the number of harmonics being calculated (default: Nharmonics=9), while the Nperiods parameter determines the number of full signal periods used for the analysis from the end time of the simulation (default: Nperiods=1). The data trace names identify the signals to be transformed.

Figure 1 shows a simple test circuit with the necessary spice directives to perform the analysis. V1 provides a symmetrical triangle waveform to net SIG. The result can be read in the error log after running the simulation (use the CTRL+L hotkey to open it).

Figure 1. Fourier series test schematic

The waveform is plot in Figure 2, while Figure 3 shows the result of the Fourier series from the corresponding error log (use CTRL+L to invoke it).

Figure 2. Triangle wave test voltage
Figure 3. The Fourier series of the test voltage

The results are listed in a table with the parameters of the individual harmonics. The column Fourier Component shows the amplitude (peak!) of the particular sinusoid component with the given frequency, while the values normalized to the amplitude of the fundamental harmonic are also shown. Similarly, the absolute and relative phase values are also indicated. As we expect, the even harmonics are close to zero, while the amplitudes of the odd harmonics match well with the analytical values defined by the following expression:

Where A is the amplitude of the triangle wave. This results in A1=0.81057V, A3=0.09006, A5=0.0324V amplitudes for instance – just like what we got from the simulation above.

There are two different THD (Total Harmonic Distortion) values calculated and shown in the results above. Unfortunately, the LTspice Help does not provide any information about the two different THD values, but it is quite simple to figure it out based on the two known THD definitions:

1.

2.

Where Vn represents the RMS of the nth harmonic, and VRMS is the RMS of the waveform including all harmonics and noise.

The first definition considers the calculated harmonics only, and ignores the noise, resulting in a slightly lower THD, depending on the nature of the signal. The second definition however, considers all harmonics and noise in the calculation – therefore the name “THD+N”, indicating that the noise is included in this figure. Though the difference between the two THD values does not necessarily caused by the additive noise of the signal, but the lack of the higher order harmonics in the calculated Fourier series.

Analysis of power line harmonics in LTspice

We can use the Fourier series to analyze simulated signals as well as measured waveforms. An interesting use case is presented below.

When dealing with off-line PFC (Power Factor Correction AC/DC) and other power supplies, there are certain standards (the IEC 61000-3-2 for instance) calling for measurement and evaluation of the harmonics of the line current. A proper compliance test shall always be done with power line analyzers, providing very high dynamic range, high accuracy and correct integration time constants. In engineering practice however, it is quite useful to have a simple tool for power line harmonics analysis for pre-compliance testing during development.

For this purpose, it is possible to capture and save the current and voltage waveforms of the DUT with a digital oscilloscope and analyze them in LTspice. Figure 4 shows a measurement example of a PFC stage with load, where the AC input voltage and current waveforms were captured. The length of the captured data was 50ms. The line frequency was f=50Hz, thus the period time is T=20ms.

Figure 4. Measurement setup for AC line voltage and current waveform capture

The waveforms were saved in ASCII format in two separate text files and are imported in the simulation (Figure 5) by V1 and I1 PWL sources, respectively.

Figure 5. Test simulation for importing the measured waveforms

A simulation length of 40ms is set for the transient simulation (directive: .tran 40m) to ensure that there are exactly two line periods being simulated and plot. The Fourier series is calculated for both signals up to the 50th harmonic. We can run a simulation now to gather data from the Fourier series of the voltage waveform first. The imported waveforms appear in Figure 6. Now we can look up the phase angle of the fundamental component in the error log (Figure 7).

Figure 6. Measured AC line waveforms (red: line voltage, green: line current)
Figure 7. The Fourier series of the measured voltage waveform

As it can be seen from the table above, the phase of the fundamental harmonic is ϕ=-91.56°. Therefore, by applying a dt=91.56°/180°∙10ms=5.0867ms time delay in the transient simulation settings (Edit simulation command->”Time to start saving data” field), the voltage waveform can be adjusted to ensure its fundamental component has 0°phase angle – this will be the phase reference for the evaluation of the phase of the current harmonics. Thus, the modified simulation directive is: .tran 0 45.0867m 5.0867m. We can also add some measurement directives to calculate the RMS value of the measured waveforms as well as the apparent and real power levels (Figure 8). The time shifted waveforms are shown in Figure 9, while the final Fourier series and the results of the measurements statements are shown in Figure 10.

Figure 8. Test simulation with delay in the transient stimulus and additional measurement directives
Figure 9. Delayed transient waveforms
Figure 10. Final Fourier series and waveform measurement results

The DC component of the analyzed waveforms appear at the top of the Fourier component tables, indicating the offset of the respective measurements. It is possible to compensate the waveforms for these DC offsets before calculating the RMS values, but these offsets will hardly affect the accuracy if they are less than 1% with respect to the fundamental components. As it can be seen from the tables above, the line voltage is now aligned to the simulation timescale in such a way that the phase of its fundamental component is (almost) zero, allowing a direct and easy readout of the phase of the current components.

Comparison with the results of an AC power analyzer

A Voltech PM100 power analyzer was also used during the capture of the line voltage and current waveforms to provide a reference for comparison of the measurement results. Figure 11 shows the most important AC line parameters (RMS voltage, RMS current, apparent and real power, power factor, current and voltage THD) obtained directly from the power analyzer and from the LTspice analysis, respectively.

Figure 11. Comparison of the measured AC line parameters

The comparison of the measured current harmonics is shown in Figure 12. Note that the amplitude scale is logarithmic in order to enable a comparison over a high dynamic range.

Figure 12. Comparison of the measured current harmonics

The voltage and current THD values as well as the dominant current harmonic amplitudes are in excellent agreement, indicating the usefulness of the shown measurement and analysis method.

[1] Voltech PM100 User Manual