Keyboard Shortcuts
Likes
Search
FFT Resolution
Hi If you upload the your schematics, some will give you a comment, I think. ? Shiggy ? On Tue, Dec 10, 2013 at 1:56 PM, <ronw6wo@...> wrote:
|
ronw6wo?wrote:
I don't use FFTs regularly, but some things you should be doing include: Disable waveform compression (.option plotwinsize=0). The simulation must run for an exact integer multiple of cycles, and turn off Windowing in the FFT. ?Either of those can make the components wider.
More data points at finer time increments is usually better. ?Specify a Maximum Timestep in the .TRAN command.
Many circuits start with a burp, which you might not always notice. ?Remember, a transient simulation begins with the variable sources turned off, and then suddenly they are turned on. ?That can cause a bias shift if signals are AC-coupled anywhere ... which translates into a widening of the FFT components. ?To avoid that when it happens, don't start saving data until after the bias has settled or the transient has died out ("Time to Start Saving Data" in the .TRAN command). ?Remember to adjust the stop time accordingly so you still have an integral number of cycles saved.
Also, don't forget, you can't make perfect "square" waves. ?The Pulse waveform rise and fall times should not be zero.
Andy |
Given (in this case) a square wave of fixed frequency, fast but non-zero rising & falling edges, 50% duty cycle, and an exact integer number of cycles (etc.), what's the narrowest possible harmonic bandwidth that ought to be expected? In other words, when is the simulation as optimized as it can be?
toggle quoted message
Show quoted text
On a more general note, assuming artifacts of a non-ideal simulation have been minimized, does the harmonic bandwidth provide useful information, or do only the peak values matter? Just curious, Steve K. --- In LTspice@..., Andy <Andrew.Ingraham@...> wrote:
|
John Woodgate
In message <l87u7c+ebvu@...>, dated Tue, 10 Dec 2013, "skleiser@..." <skleiser@...> writes:
Given (in this case) a square wave of fixed frequency, fast but non-zero rising & falling edges, 50% duty cycle, and an exact integer number of cycles (etc.), what's the narrowest possible harmonic bandwidth that ought to be expected? In other words, when is the simulation as optimized as it can be?harmonic bandwidth doesn't depend on those things. Embedded in the Help on the B source is: "In LTspice, the impulse response is found from the FFT of a discrete set points in frequency domain response. This process is prone to the usual artifacts of FFT's such as spectral leakage and picket fencing that is common to discrete FFT's. LTspice uses a proprietary algorithm that exploits that it has an exact analytical expression for the frequency domain response and chooses points and windows to cause such artifacts to diffract precisely to zero. However, LTspice must guess an appropriate frequency range and resolution. It is recommended that the LTspice first be allowed to make a guess at this. The length of the window and number of FFT data points used will be reported in the .log file. You can then adjust the algorithm's choices by explicitly setting nfft and window length. The reciprocal of the value of the window is the frequency resolution. The value of nfft times this resolution is the highest frequency considered." The significant words are: "The reciprocal of the value of the window is the frequency resolution." Frequency resolution is the same as the observed 'harmonic bandwidth'. The harmonic energy is averaged over the bandwidth, so widening the bandwidth tends to reduce the observed amplitude. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
Steve K. wrote: "
...? what's the narrowest possible harmonic bandwidth that ought to be expected? In other words, when is the simulation as optimized as it can be?"Good question. ?I don't know. Steve continued, "On a more general note, assuming artifacts of a non-ideal simulation have been minimized, does the harmonic bandwidth provide useful information, or do only the peak values matter?"
I think the widths could matter, depending. ?If anything non-ideal is going on that modulates the signal in some way, whether by varying its amplitude or its phase or frequency, that should translate into sidebands around each of the frequency components of the square wave signal. ?So if you are looking for that sort of thing, and assuming that the FFT is good enough to resolve those sidebands (and not just an artifact of doing the FFT), then it could be useful information. ?But to someone else, it might not matter.
When some sort of modulation is going on, energy gets transferred from the signal at the peak, into the sidebands around it. ?So as the amount of modulation gets worse, I think I would expect to see the peak shown by the FFT to decrease, while the width increases.
Andy |
The widths of the peaks depend highly on the number of samples per cycle. It also depends a lot on the windowing function that is used.My hunch is that, for an FFT, it is often an indicator of non-infinite sampling duration. If you sample with the same number of samples per cycle, the peaks are narrower as you include more cycles. To me, that says that much of the observed peak width is not "real".?
toggle quoted message
Show quoted text
Jim Wagner Oregon Research Electronics On Dec 10, 2013, at 3:11 PM, Andy wrote:
|
¿ªÔÆÌåÓýHi Steve and AndyYoull only be able to see the side bands if the sample is long enough to encompass an integral number of modulation periods. (and an integral number of carrier periods. The two should be integrally related to minimize artifacts.) The more info that gets sampled, the better the resolution. Hence is why the default FFT size is 262k, but of course you can set that to any thing needed. Al D. On 12/10/2013 06:11 PM, Andy wrote:
-- AC2CL I do not think there is any thrill that can go through the human heart like that felt by the inventor as he sees some creation of the brain unfolding to success... Such emotions make a man forget food, sleep, friends, love, everything. - Nikola Tesla |
In any event the resultant "spectral accuracy", even if optimized for some set of conditions, resolution, and bandwidth of spectrum, will be directly dependent on the accuracy of represented distortion (read non-linear) effects. ? - In general large scale spectra will tend to more accurate representation, whereas the smaller the spectral component the more the sensitivity, and deviation, from the actual results in a real world circuit. This effect is exploited in so-called "Harmonic balance" type solvers to great success. ? - Cordially - RC On Tuesday, December 10, 2013 2:58 PM, John Woodgate
?
In message , dated Tue, 10 Dec 2013,
"skleiser@..." writes: > Given (in this case) a square wave of fixed frequency, fast but >non-zero rising & falling edges, 50% duty cycle, and an exact integer >number of cycles (etc.), what's the narrowest possible harmonic >bandwidth that ought to be expected? In other words, when is the >simulation as optimized as it can be? harmonic bandwidth doesn't depend on those things. Embedded in the Help on the B source is: "In LTspice, the impulse response is found from the FFT of a discrete set points in frequency domain response. This process is prone to the usual artifacts of FFT's such as spectral leakage and picket fencing that is common to discrete FFT's. LTspice uses a proprietary algorithm that exploits that it has an exact analytical expression for the frequency domain response and chooses points and windows to cause such artifacts to diffract precisely to zero. However, LTspice must guess an appropriate frequency range and resolution. It is recommended that the LTspice first be allowed to make a guess at this. The length of the window and number of FFT data points used will be reported in the .log file. You can then adjust the algorithm's choices by explicitly setting nfft and window length. The reciprocal of the value of the window is the frequency resolution. The value of nfft times this resolution is the highest frequency considered." The significant words are: "The reciprocal of the value of the window is the frequency resolution." Frequency resolution is the same as the observed 'harmonic bandwidth'. > > On a more general note, assuming artifacts of a non-ideal simulation >have been minimized, does the harmonic bandwidth provide useful >information, or do only the peak values matter? The harmonic energy is averaged over the bandwidth, so widening the bandwidth tends to reduce the observed amplitude. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
? RC and John Thanks? for the response,but I am blinded by science now as this is my first attempt to model FT behaviour I would like to be clear on at least one matter? " 'the value of the window" Is this the same as the number of cycles AKA Span ? Is it possible to display the harmonics of say a 10MHz square wave to 100Hz resolution ? My 30 year-old HP spectrum analyzer can Can anyone illustrate? with the pulse and Tran statements using a square wave at any freqency ---In LTspice@..., <ron_liff@...> wrote: In any event the resultant "spectral accuracy", even if optimized for some set of conditions, resolution, and bandwidth of spectrum, will be directly dependent on the accuracy of represented distortion (read non-linear) effects. ? - In general large scale spectra will tend to more accurate representation, whereas the smaller the spectral component the more the sensitivity, and deviation, from the actual results in a real world circuit. This effect is exploited in so-called "Harmonic balance" type solvers to great success. ? - Cordially - RC On Tuesday, December 10, 2013 2:58 PM, John Woodgate <jmw@...> wrote:
?
In message <l87u7c+ebvu@...>, dated Tue, 10 Dec 2013,
"skleiser@..." <skleiser@...> writes: > Given (in this case) a square wave of fixed frequency, fast but harmonic bandwidth doesn't depend on those things. Embedded in the Help on the B source is: "In LTspice, the impulse response is found from the FFT of a discrete set points in frequency domain response. This process is prone to the usual artifacts of FFT's such as spectral leakage and picket fencing that is common to discrete FFT's. LTspice uses a proprietary algorithm that exploits that it has an exact analytical expression for the frequency domain response and chooses points and windows to cause such artifacts to diffract precisely to zero. However, LTspice must guess an appropriate frequency range and resolution. It is recommended that the LTspice first be allowed to make a guess at this. The length of the window and number of FFT data points used will be reported in the .log file. You can then adjust the algorithm's choices by explicitly setting nfft and window length. The reciprocal of the value of the window is the frequency resolution. The value of nfft times this resolution is the highest frequency considered." The significant words are: "The reciprocal of the value of the window is the frequency resolution." Frequency resolution is the same as the observed 'harmonic bandwidth'. > The harmonic energy is averaged over the bandwidth, so widening the bandwidth tends to reduce the observed amplitude. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
John Woodgate
In message <l8l5j2+4h2m77@...>, dated Sun, 15 Dec 2013,
ronw6wo@... writes: It isn't very clear. No. It's the 'width' in frequency of one window. Working backwards through that last bit in the Help, to get 100 Hz resolution, the window width is 1/100 s = 10 milliseconds. You need to consider at least harmonics up to the ninth, 90 MHz, so the number of samples has to be at least 90 MHz/100 Hz = 90000. LTspice supports much larger numbers. But the necessary simulation time may be archaeological. Your spectrum analyser works in the analogue domain, so the only time constraint is the settling time of the 100 Hz filter, which might be as long as 100 ms. So you do need to sweep the frequency slowly enough. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
Hello Ron,
If you want 100Hz resolution, you have to simulate at least 1/100s=10ms. I have uploaded an example "fft10meg.asc" to the Temp-folder folder. I simulated 20ms. http://groups.yahoo.com/neo/groups/LTspice/files/%20Temp/ Run the simulation. Then in the FFT dialog window choose 4194304 samples. Please be aware that the FFT/DFT only looks so perfect because my second source has 100Hz offset which exactly fits to the FFT's frequency resolution. If this is not the case, one would try with a window function to get a good resolution. Best regards, Helmut |
John Woodgate
In message <ENcQOfEjUjrSFwah@...>, dated Sun, 15 Dec 2013, John Woodgate <jmw@...> writes:
I'm sorry: I got a bit confused myself in trying to explain this and I inadvertently sent it before I'd fixed the text. Please disregard. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
ronw6wo?wrote, " Here are some tips. (1) ?To get finer frequency resolution in the FFT results, you need to use longer simulation times. ?The two are directly related. For 100 Hz frequency resolution, the total time interval of the waveform data that is sent to the FFT must be 1/100Hz = 0.01 seconds = 10 ms. ?But to examine discrete components that are 100 Hz apart, you might want the frequency resolution to be at least twice as good as that (if not more) ... so simulate for 20 ms if not 40 ms or more. ?Then you can see the dips between the components too. ?Otherwise it tends to look like a big blob and it's hard to tell one component from the next.
(2) ?The "Number of data point samples in time" and the total time interval determine the upper frequency limit of the FFT. ?If the FFT doesn't go up high enough in frequency to show the components you want to see, repeat the FFT with more data point samples in time. ?Hopefully you have simulated with fine enough time steps so that the FFT isn't using fake data (see later, about "Tstep" and "plotwinsize").
An FFT works best when the number of data point samples is a power of 2 (hence LTspice starts with a default of 262144 data points), but I believe LTspice's algorithm does not require a power of 2. ?Just the same, I'd go with the power of 2 in case it impairs accuracy not to use it.
When in doubt, click "Reset to Default Values" at the bottom of the FFT dialog window, then use the up/down arrows to try other powers-of-two.
(3) ?LTspice's FFT display has a truly annoying characteristic when you zoom in to see the individual components of the FFT: ?Each component looks like an arch. ?I think that happens because LTspice does a linear interpolation between the points, BEFORE it computes a logarithm to turn it into Decibels for display. ?Hence you end up with those deceptive arch-like bumps. ?(Note: LTspice's developer says this is actually intentional. ?Not a bug. ?Could've fooled me.)
The apparent "width" of those bumps means nothing and does not imply a width of the components present! ?The tip of each bump is the ONLY thing that matters. ?The sides of the bumps are meaningless.
You can highlight the individual FFT components (right-click in the FFT window, then "Mark Data Points"), and then LTspice draws little dots at the actual FFT components. ?The curves between the dots are interpolations, not real data, and should be ignored. ?Be aware that turning on the display of those data point dots can make LTspice VERY slow and unresponsive when there are a very large number of data points on your screen. ?But this is the only way to see what's really there when your FFT's resolution is 100 Hz and you need to see frequency components every 100 Hz.
(4) ?Many things affect the apparent accuracy of the FFT results, i.e., the "noise floor" of the FFT plot, the appearance of extraneous signal components, etc. Most important is to simulate (and send to the FFT) an integral number of cycles. ?If you have multiple known components present, use an integral number of cycles of ALL of them, if you can. ?In Helmut's example, the time interval (20 ms) is a multiple of both 10.0000 MHz and 10.0001 MHz.
Here's why. The time-domain simulation generates a bunch of data points running from t=0 to t=Tstop = Stop Time. ?Think of turning that into a continuous waveform, by repeating that interval indefinitely. ?This is effectively what the output of the FFT represents. ?When you "splice" the waveform at t=0 to the waveform at t=Tstop, is it continuous, or is there a "glitch" at the splice? ?If there's a glitch, the waveform effectively has a modulation applied to it, which shows up in the spectrum as unwanted sidebands around everything and an increased noise floor.
In the FFT dialog box, the "Time range to include" controls the amount of waveform sent to the FFT. ?Normally one would "Use Extent of Simulation Data". ?A case where you might not do that, is when the simulation includes a start-up transient, and you want to include only the steady-state waveform after that transient has died. ?Make sure the time range you include, has the integral number of cycles, even if the total simulation time does not.
Simulating over many cycles seems to work better than simulating fewer cycles. ?I think it allows mathematical errors to average out better, and this reduces the FFT's noise floor and spurious components in the display.
When it is impossible to simulate for an integral number of cycles of all components, that's when one of the Windowing functions is used. ?My understanding is that they force the pre-FFT, time-domain data to fall somewhat gracefully to zero at t=0 and at t=Tstop. ?Thus, a nasty glitch is avoided when you "splice" the ends together. ?Instead, a gentler modulation is applied to your signal, so it still causes sidebands to appear in the output spectrum.
(5) ?It helps to turn off waveform compression in the time-domain data:
.options plotwinsize=0
Also, make Tstep (Maximum Timestep) as small as practical. ?The less interpolation between data points that the FFT needs to do, the better. (6) ?Enabling double precision may also help: .options numdgt=15 Regards,
Andy |
ronw6wo?wrote:
I think "the value of the window" as used before, refers to the time interval that was simulated and sent to the FFT. ?Not the number of cycles, but the number of seconds of time.
You could take Helmut's example and change V2 from a Sine wave source to a Pulse source.
Andy |
John Woodgate
In message
<CALBs-TgcwTBCyW1+=wNz4R7Yk09QHzk1sbNYC1ii8HU7SecrFg@...>, dated Mon, 16 Dec 2013, Andy <Andrew.Ingraham@...> writes: Here are some tips.This is all good stuff, but could you please comment in the OP's question about analysing a 10 MHz square wave with a resolution of 100 Hz? Given that 20 ms is long enough to get 100 Hz resolution, how many data points are required to get up to, say, 90 MHz? -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
John Woodgate asked: This is all good stuff, but could you please comment in the OP's You need at least two time samples at the highest frequency of the FFT. 1/90MHz * 0.5 = 5.56 ns Helmut's example simulates for 20 ms, which actually gives you 50 Hz resolution, enough to see the "trough" between alternate components that are 100 Hz apart. ?Given that, you need at least 3600000 for the "Number of data point samples in time" to have time samples no greater than 5.56 ns apart. ?Using Helmut's recommended 4194304 (= 2^22) gives you that. ?That simulation's FFT goes up to (1/2) * 1/(20ms/4194304) = 104.858 MHz, which is what I see when I run it.
Using the bare minimum (3600000) probably stops exactly AT 90 MHz and isn't enough to show you the 90 MHz component. ?So always go higher if there is any doubt.
Andy |
John Woodgate
In message
<CALBs-TipQ2tWb71L_jO+d3CysuyxmNHd1cAx+162RVC-OCHd9g@...>, dated Mon, 16 Dec 2013, Andy <Andrew.Ingraham@...> writes: You need at least two time samples at the highest frequency of the FFT.Thanks. I hope that makes it all clear: To get x Hz resolution, you should, in practice, simulate for 2/x seconds. You can simulate for longer to get a clearer spectrum display, say N/x seconds. To get a spectrum up to X Hz, you then need more than 2*N*X/x samples, preferably the next higher power of 2. I do think that, if it's correct, is a bit more lucid than the Help text. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |
John Woodgate wrote: To get x Hz resolution, you should, in practice, simulate for 2/x Actually, x Hz resolution needs only 1/x seconds. Simulating for 2/x seconds gives you x/2 Hz resolution, which in practice might be useful if you know you have discrete frequency components at x Hz increments. ?Having those in-between components in the FFT plot both makes it easier to see the components, and can be used as a rough gauge of the FFT's accuracy. ?If components which should be very low, are not low, then something is wrong and you need to take a closer look.
The factor of 2 is needed only for the upper frequency limit.
Andy |
John Woodgate
In message
<CALBs-ThuY6qLHD4J3RdQsTdd9YP+1YphDpTzvxun4yTU9wM4DQ@...>, dated Mon, 16 Dec 2013, Andy <Andrew.Ingraham@...> writes: John Woodgate wrote:See 'in practice', words you use yourself in the critique below. I put the factor of 2 in and the words 'in practice' for precisely the reasons you have cited again, as you did in your previous message. We are in violent agreement but I fear that a thirst for rigor can result in added confusion. -- OOO - Own Opinions Only. With best wishes. See www.jmwa.demon.co.uk Nondum ex silvis sumus John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK |