• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

THD in LTspice?

Status
Not open for further replies.

mading2018

Member
Do anyone know how to check the THD (fft) in a easy way in LTspice?
When I press the FFT-button, I got this window popping up. What should I select there?

Maybe an alternative is to do this instead:
I found somewhere that you need to write a SPICE directive like this:
".fourier {Freq} V(output)"
and then open and check "the spice error log."
according to this source: http://www.diyaudio.com/forums/solid-state/177820-thd-ltspice.html
 

Attachments

MikeMl

Well-Known Member
Most Helpful Member
fft1.png
Read the "Waveform Arithmetic" topic in the help file. Note the discussion about .OPTIONS plotwinsize=0 numdgt=15. Add that to the schematic. Plot about five cycles of the waveform.

In the upper plot window, VIEW/FFT generates the FFT plot, which shows that the third harmonic is down 20db from the fundamental, which is what the two sources add to...

How to convert that to THD.
 
Last edited:

alec_t

Well-Known Member
Most Helpful Member
I found somewhere that you need to write a SPICE directive like this:
".fourier {Freq} V(output)"
and then open and check "the spice error log."
That works, and is easy to do.
 

unclejed613

Well-Known Member
Most Helpful Member
the spice directive should be put on the schematic. if you are using a 1khz tone to test your device, and your output node is marked "out", the correct way to type the spice directive is:
.fourier 1000 V(out)

after running the sim, open the spice error log, and you will get the overall thd, plus a list of the magnitudes of the harmonics
 

mading2018

Member
the spice directive should be put on the schematic. if you are using a 1khz tone to test your device, and your output node is marked "out", the correct way to type the spice directive is:
.fourier 1000 V(out)

after running the sim, open the spice error log, and you will get the overall thd, plus a list of the magnitudes of the harmonics
Hmm, I may do something wrong, I don't find that list. I found this instead.

First I run the simulation by plotted Vout, then I took FFT of Vout, then I open the spice error log.
 

Attachments

MikeMl

Well-Known Member
Most Helpful Member
Without the .options statement. The .fourier statement has to refer to a node that actually exists in your schematic.

click:fn.png

This is with the .options statement. Notice how much cleaner the FFT is, and that is reflected in the error Log.

click:fy.png
 
Last edited:

unclejed613

Well-Known Member
Most Helpful Member

mading2018

Member
Without the .options statement. The .fourier statement has to refer to a node that actually exists in your schematic.

click:View attachment 112779

This is with the .options statement. Notice how much cleaner the FFT is, and that is reflected in the error Log.

click:View attachment 112780
I still don't get it. I have added all the SPICE directives, and I can not see the anything in the error log :( it is just empty.

you missed that part... put a flag on your output called "out"
It is already named 'OUT'.

Can you please show me how you obtain the list from my file?
 

Attachments

Last edited:

MikeMl

Well-Known Member
Most Helpful Member
THD is meaningless in the context of the circuit you posted. Doing an FFT on the output ripple shows that it has horrible ripple fed through from the full-wave rectified AC. You dont even need to do the FFT, you can see it...
 
Last edited:

alec_t

Well-Known Member
Most Helpful Member
I can not see the anything in the error log :( it is just empty
Did you wait for the sim to finish running before looking in the log?

Edit: To speed up the sim, edit the simulation command by ticking the 'Skip initial operating point solution' box.

Edit 2: Ignore that, since for some reason the 1248 doesn't oscillate if Skip is enabled.
 
Last edited:

mading2018

Member
THD is meaningless in the context of the circuit you posted. Doing an FFT on the output ripple shows that it has horrible ripple fed through from the full-wave rectified AC
Ah, I see. Yeah you right. So it would be more appropriate to do a THD on the current input instead, just to see how good quality the input current is? Like they did here in the document.
 

Attachments

mading2018

Member
THD is meaningless in the context of the circuit you posted. Doing an FFT on the output ripple shows that it has horrible ripple fed through from the full-wave rectified AC. You dont even need to do the FFT, you can see it...
Is it common to do a THD on AC current input instead? At the output, I think THD was very high...
 

MikeMl

Well-Known Member
Most Helpful Member
Is it common to do a THD on AC current input instead? At the output, I think THD was very high...
THD is something that is measured in a hifi audio amplifier. You put in a perfect sine wave, at say, 1000Hz. You analyze the output waveform to see if the non-linearity in the amplifier has contaminated the output signal with harmonics of 1000Hz. This has nothing to do with what you are doing; namely evaluating how well filtered (compared to DC) the output of a switching regulator is.
 

unclejed613

Well-Known Member
Most Helpful Member
THD measurements are usually done on audio systems, not power supplies. what you want to look at on a power supply output is the percentage of ripple, and that's a different measurement. if you have a 5V supply, and the ripple is 100mV, that's 2% ripple, which for most purposes is fine.
 

alec_t

Well-Known Member
Most Helpful Member
In that's what you're after, you could plot the supply input current and check for harmonics of the input frequency. Ideally, the input current will be perfectly in phase with the input voltage so, if the output load is a constant resistance and the PFC is 100% efficient, there would be no harmonics. In the real world that wouldn't happen :).
 

mading2018

Member
In that's what you're after, you could plot the supply input current and check for harmonics of the input frequency. Ideally, the input current will be perfectly in phase with the input voltage so, if the output load is a constant resistance and the PFC is 100% efficient, there would be no harmonics. In the real world that wouldn't happen :).
Yes :) I expect some THD cause the PF can't be perfect as you say in the real world. So my input frequency is 50 Hz from the grid, but how do I select the input current in the FFT window?

--edit--
Oh, wait, is that "I(V4)" at the voltage source that I should use to get the input current? And how long should the running time be?
 

Attachments

Last edited:

mading2018

Member
Now I tested for 100 ms, but is it strange that I only got 9 harmonic numbers, tough I have 15?

--edit2--
Is it possible to obtain see the image "graph.png"? Is that possible in Spice ? If not, do anyone how I create a graph like that?
Or could I used "freq4A.png" or "THD.png" like a clear result. What do you suggest? Sorry that I have so many questions :happy:
 

Attachments

Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top