Fast Fourier Transform in SPICE - diyAudio
Go Back   Home > Forums > Amplifiers > Solid State

Solid State Talk all about solid state amplification.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 3rd February 2007, 05:03 PM   #1
ptah is offline ptah  United States
diyAudio Member
 
Join Date: Aug 2006
Default Fast Fourier Transform in SPICE

I know most of you guys know SPICE inside and out. I am learning it with Linear Technologies version and have gotten all the basics down.

What am I looking at when I run fast Fourier transform? It gives a plot of dB vs frequency for a specific voltage or current through a component. What does it mean?
  Reply With Quote
Old 3rd February 2007, 07:45 PM   #2
diyAudio Member
 
myhrrhleine's Avatar
 
Join Date: Jan 2006
Location: Avalon Island
Default Re: Fast Fourier Transform in SPICE

You'll get the best answers from the email group LTspice@yahoogroups.com

They discuss all aspects of LTSpice.
__________________
Just because you can't hear it doesn't mean no one can.
  Reply With Quote
Old 3rd February 2007, 09:08 PM   #3
jcx is offline jcx  United States
diyAudio Member
 
Join Date: Feb 2003
Location: ..
the "trick" is that 0 dB = 1 Vrms or 1 Arms

so a 1.414 V Sine gives a 0 dB output point on the fft plot

and a 1 V sine would be -3 dB

and since dB is suposed to be power ratio, other V or A rms amplitudes are displayed as 20*Log(x/1 Vrms), or 20*Log(x/1 Arms)

another trick is that LtSpice is optimized for very long runs of their switching regulators, to keep file size down the default setting is to use compression on the data - which adds distortion in simulated waveforms
for most audio circuits you will want to add a spice directive to the sheet:
.option plotwinsize=0

to turn off the data file compression
  Reply With Quote
Old 3rd February 2007, 09:44 PM   #4
jcx is offline jcx  United States
diyAudio Member
 
Join Date: Feb 2003
Location: ..
I have posted a few sims and discussed other LtSpice issues in audio simulations here so searching for posts by user "jcx" containing words: "LtSpice" or "photobucket" (where I host my images, ~ 80% will be LtSpice circuit drawing/wave/fft plots) might help you see what can be done with LtSpice sims, often the .asc files are attached as well (my older posts might be better for learning LtSpice sim tricks)
  Reply With Quote
Old 4th February 2007, 04:17 AM   #5
thanh is offline thanh  Viet Nam
diyAudio Member
 
thanh's Avatar
 
Join Date: Jan 2004
Location: ho chi minh city
Send a message via Yahoo to thanh
I want to view FFT of V=Va-Vb. So how can I do ?
Thanks!
__________________
Justice for Victims of Agent Orange
http://www.petitiononline.com/AOVN/Thank all of you!
  Reply With Quote
Old 4th February 2007, 04:29 AM   #6
teemuk is offline teemuk  Finland
diyAudio Member
 
Join Date: Nov 2004
Location: Suomi, Finland
Two methods (for LTspice):
1. Use arbitrary behavioral voltage sources and plot them. They support waveform arithmetics.
2. In FFT window right click the plot title. This should open an "expression editor" window. Write expression, press enter.

Another useful command (besides turning compression off) is .fft
The results of using this command can be seen by viewing the spice error log.
  Reply With Quote
Old 4th February 2007, 04:56 AM   #7
andy_c is offline andy_c  United States
Banned
 
Join Date: Apr 2003
Quote:
Originally posted by thanh
I want to view FFT of V=Va-Vb. So how can I do ?
Thanks!
When you run your transient analysis, a dialog box will come up. Click once on any voltage listed (or better yet, one that's part of the expression you want to use). Then press Alt and double-click (per the text you see on the dialog). This will bring up the expression editor dialog. If you have previously used F4 to name some nodes, say, a and b, enter the expression V(a)-V(b). If you haven't named the nodes this way, you can escape out and name them now, or you can escape out and hover the mouse over the nodes you want to measure. The status bar will say something like "this is node N025". Then you could memorize those names and use them in the expression. Another way is to start out plotting any old voltage. Then once you get the plot, switch back to schematic view. Click on one of the nodes you want to measure to get a probe. Then drag the probe to the other node. This will plot the difference. To eliminate an unused plot, just right-click on the expression at the top of the plot and choose "delete this trace". This is all in the help files under Waveform viewer, trace selection. To plot the FFT of the waveform, just right-click on the plot and choose "FFT".

If all you care about is a sine wave and its harmonics, just put a ".FOUR" SPICE directive on the schematic directly using the "S" key. It might look something like this:

.four 20kHz 19 v(out)

The frequency in the .FOUR directive must match the frequency of the source. The expression above says to use 19 harmonics to calculate THD. To see the results, run transient and do a "View, SPICE error log". The signal, its harmonics and the THD will be shown in text form in this file. See the help files under "LTSpice, Dot commands" for details of .FOUR.
  Reply With Quote
Old 7th February 2007, 11:26 AM   #8
thanh is offline thanh  Viet Nam
diyAudio Member
 
thanh's Avatar
 
Join Date: Jan 2004
Location: ho chi minh city
Send a message via Yahoo to thanh
In "...raw" window, I click menu View/ FFT, a panel appears--> I have no allowance to edit expression

I tried
.FOUR 20khz 19 (v(a)-v(b))
but LTspice says "..error"
__________________
Justice for Victims of Agent Orange
http://www.petitiononline.com/AOVN/Thank all of you!
  Reply With Quote
Old 7th February 2007, 12:01 PM   #9
teemuk is offline teemuk  Finland
diyAudio Member
 
Join Date: Nov 2004
Location: Suomi, Finland
In FFT window right click the plot title. This should open an "expression editor" window. Write expression, press enter.

The right syntax for the other command is .four frequency v(a)-v(b).
  Reply With Quote
Old 7th February 2007, 12:30 PM   #10
Dag is offline Dag  Sweden
diyAudio Member
 
Dag's Avatar
 
Join Date: Feb 2005
Location: Goteborg
You guys probably know all about this but to get the most out of the FFT you shoul think about this:

1. You have to wait for a steadystate situation in the transient run before you do the fft. (That is, don't do the fft on the data from the start (0s), wait a few periods)

2. Use EXACT numbers of periods of the fundamental frequency for THD sims. Two is enough.

3. For intermodulation sims you have to use the lowest periodic frequency. f2=f1*1.1 => lowest periodic frequency =0.1*f1 (10 times longer sim time!!!!!!!)

4. Use fixed timesteps in the trans sims. Timestep= [2^-n / (lowest periodic frequency)] is a good choise.

5. To improve accuracy change "rel tol", "V tol" and "I tol" in the control panel. Smaller numbers = better accuracy. Too small nubers will only make the sims very slow or you might get DC convergence problems.
(In LTS: Maybe you can switch off the compression here also as jcx suggested??? Or use .option plotwinsize=0 in the schematic)

What is wrong or what did I miss??

  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Spice Or Cheap Spice Simulator-Where To Start? kelticwizard Everything Else 29 15th February 2007 02:38 AM
How fast are 'Fast Fuse' and how to identify? bigpanda Solid State 7 22nd March 2005 10:00 PM
Linkwitz Transform ding Multi-Way 10 11th July 2004 10:55 PM
Fourier transforms (split from 25W class A into 1 ohm resistive load) Steve Eddy Everything Else 20 20th April 2004 04:12 PM
What Can I do to transform... Thicorrêa The Lounge 3 13th August 2003 02:51 AM


New To Site? Need Help?

All times are GMT. The time now is 12:06 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright ©1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2