Continue to Site

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.

  • 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.
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: https://www.diyaudio.com/forums/solid-state/177820-thd-ltspice.html
 

Attachments

  • FFT.png
    FFT.png
    114.1 KB · Views: 836
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:
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.
 
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
 
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

  • list.png
    list.png
    70.4 KB · Views: 744
  • SPICE.png
    SPICE.png
    15.5 KB · Views: 791
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:
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

  • BOOST ACDC_PFC_LT1248 OK.asc
    6 KB · Views: 370
Last edited:
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:
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:
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

  • AnAutomotiveOn-Board3.3kWBatteryChargerforPHEVApplication_ NEW.pdf
    1.7 MB · Views: 478
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...
 
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.
 
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.
 
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 :).
 
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

  • current seleciton?.png
    current seleciton?.png
    106.2 KB · Views: 396
  • analysze Input.png
    analysze Input.png
    20.3 KB · Views: 424
  • BOOST ACDC_PFC_LT1248 OK.asc
    6 KB · Views: 338
Last edited:
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

  • THD.png
    THD.png
    48.6 KB · Views: 400
  • THDwindow.png
    THDwindow.png
    42.5 KB · Views: 392
  • graph.png
    graph.png
    97.2 KB · Views: 446
  • Freq4A.png
    Freq4A.png
    34.6 KB · Views: 398
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top