LTSpice pulse options - Page 1
Forum section: electronics / projects

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 01:06:06 pm
content: I am trying to experiment with analysing square waveforms with FFT in LTSpice by analysing the pulse waveforms with various rise and fall times. But there seems to be a minimum rise time of 50µs. Even if I set rise and fall times to "0" I get a slope of about 50µs. Is this how it works?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 05, 2019, 03:00:45 pm
content: A zero, null or absent parameter, that must be nonzero, is simply given its default value.Tim

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 03:05:02 pm
content: Well in theoretical land a 0 rise/fall time can be done. So are you saying that 50µs is the fastest transition I am allowed or that it is the default because 0 is not acceptable?

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 03:06:00 pm
content: hm, setting 1ns I get practically straight edges.

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 03:08:34 pm
content: 1ps produces a giberish waveform

author: StillTrying
author_rank: Super Contributor
timestamp: May 05, 2019, 03:47:54 pm
content: Quote from: Simon on May 05, 2019, 03:06:00 pmYou might have to set Edit Simulation Command > Transient > Maximum Timestep to less than that, about 0.3nsshouldwork, but slows it down.

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 03:53:54 pm
content: Quote from: StillTrying on May 05, 2019, 03:47:54 pmRight, so i tried 1ps, how do I stop a simulation?, I am set to run for 1s, it's now taking 1s/µs to simulate - opps....

author: StillTrying
author_rank: Super Contributor
timestamp: May 05, 2019, 04:25:33 pm
content: I tried 1.5ps, I always use near prime or odd numbers, don't know if it makes any difference.Setting Maximum Timestep to 0.3ns is small enough to see 0.15ns edges for me.If you right-click over the plot and Mark Data Points, you can check there's enough sample calculation points on the fast edges, it only needs a few on the edge, unless you've got even faster edges somewhere else.

author: mikerj
author_rank: Super Contributor
timestamp: May 05, 2019, 04:27:36 pm
content: Quote from: Simon on May 05, 2019, 03:53:54 pmClick the "Hand" button, next to the "running man" button.

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 04:32:51 pm
content: Quote from: mikerj on May 05, 2019, 04:27:36 pmYea found it, i was running more like 0.1µs/s

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 04:34:15 pm
content: Quote from: StillTrying on May 05, 2019, 04:25:33 pmYou sure? don't you mean it the other way around?I am just experimenting with my PC, I can reduce my core count in the bios and get a speed boost.

author: pwlps
author_rank: Frequent Contributor
timestamp: May 05, 2019, 04:36:33 pm
content: Quote from: Simon on May 05, 2019, 03:53:54 pmYes, have gone through this too: LTSpice will happily fill up your hard drive if you don't pay attentionActually I would be interested too if someone knows how to limit the output file size.

author: Simon
author_rank: Unknown
timestamp: May 05, 2019, 04:41:46 pm
content: Quote from: pwlps on May 05, 2019, 04:36:33 pmSo where does it put the data? does it try to keep it after the program is closed?

author: pwlps
author_rank: Frequent Contributor
timestamp: May 05, 2019, 04:50:00 pm
content: Quote from: Simon on May 05, 2019, 04:41:46 pmIf I remember it was in the same directory as the project files, but I don't have LTSpice installed on my home computer, I can check tomorrow when I'm back in the lab. And yes, the simulation files are not deleted when you close it - unless there is an option I don't know.

author: iMo
author_rank: Super Contributor
timestamp: May 05, 2019, 08:31:15 pm
content: LTSpice creates .raw files with data at each node and component with stepping xxsec in your directory from which you started your .asc source.It could be GBytes of data. For example the multislope ADC simulation I did here saved 6.5GB of data after a simulation of a 20ms run.You may limit the data written with .save directive (ie. ".save V(base) I(R4)").Also you may delete the .raw data after closing the .asc sim source file (it could be set somewhere).It also does a compression of the data, and does use a limited precision to save the space (you may switch it off).You may set the time when it starts to save data, and also you may set maximum step size (the smaller the slower), ie "".tran 0 1s 0.5 10ns does 1sec long transient sim, starts to save data at 0.5sec and max step is 10ns.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 05, 2019, 11:20:03 pm
content: If all you're doing is looking at waveforms, you'll save a lot of time and precision doing it analytically rather than numerically.SPICE only knows what it knows, on a moment-to-moment basis. If you tell it that it needs those moments to be 1ps or something ridiculous, it's going to dutifully follow your command, and simulate with very small timesteps. Maybe the steps are too small and it doesn't ever recover (timestep too small). Finally, the FT it calculates from that run time, is limited by that run time: frequencies can only be so precisely calculated, based on the data recorded. The true frequency and harmonics might be perfectly spaced, but you get sloppy binned results because it's not an analytical method.But if all you're looking at is a PULSE source, that's a four step piecewise linear function, a trapezoid wave, with an easily solved integral in its Fourier series. To wit:- The harmonics go as 1/N from fundamental until the cutoff frequency- The cutoff is determined by the ramp (edge) rate- Above cutoff, harmonics go as 1/N^2- If the duty cycle isn't 50%, even harmonics are present. Specifically, harmonics go as, um, sin(D * (1-D) * N * 2*pi) or something like that. Basically at 50%, they alternate (even harmonics = 0), while at very low or very high D, the waveform is very spiky and harmonics are flat (just as an ideal impulse train has all equal harmonics) until a break frequency F / (D*(1-D)) or thereabouts.- I'm not sure offhand what happens with dissimilar rising and falling edges, but it must have some intermediate cutoff point. Note that asymmetry in any parameter (rise/fall, on/off) introduces even harmonics.Tim

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 09:03:11 am
content: Took a half of a second..

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 09:21:21 am
content: Sub-ps edges.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 06, 2019, 10:33:23 am
content: Regarding the 0/default value for rise/fall times:http://ltwiki.org/index.php?title=Most_frequently_asked_questions_for_beginners#I_have_a_pulse_source_in_my_schematic_with_zero_transition_times._LTspice_only_shows_slow_transition_times_of_2ns._What.27s_going_on_here.3FJust tested a pulse voltage source in LTSpice with rise and fall times of 10ns, 100µs Ton, 200µs Toff, 1ms stop time without specifying a maximum timestep for the transient simulation, and I get 10ns rise and fall times.

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 12:52:05 pm
content: Quote from: SiliconWizard on May 06, 2019, 10:33:23 amYes if you specify it it will go to what you want. If you don't it seems to assume 50µsI am looking at the FFT of RC filtered steps, i would think that 10 points of those curves is a good idea? Questin is to do a proper FFT how many cycles do i need? I am pretty sure that the resulting graph from 2 and 14 cycle was different.

author: aandrew
author_rank: Frequent Contributor
timestamp: May 06, 2019, 06:39:09 pm
content: Quote from: StillTrying on May 05, 2019, 04:25:33 pmWhy do you always use near prime (what's a near prime number?) or odd numbers?

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 06:58:55 pm
content: Quote from: Simon on May 06, 2019, 12:52:05 pmWhat do you mean by "point of a curve"? LTspice is not a DSO with a limited sampling rate..The more periods of a signal you put into the FFT the better.The FFT can do up to 16mil "samples" of the "signal trace" (you have 3 choices what time range to include).

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 07:02:38 pm
content: Well the time step is the resolution of the simulation is it not? the RC charge/discharge is not a rise/fall ramp, it's a curve so you cannot just take a couple of points and draw a line between them.

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 07:07:50 pm
content: I think not.The FFT works such you set the number of "FFT points" (up to 16mil) and the TIME INTERVAL (3 choices you get).So the lowest freq in the spectra is given by the time interval (ie 100ns). The highest is related to the number of FFT points you selected.There is not such thing like "number of points in the signal trace".The trace you see is a "continual curve", and as such is taken into the FFT (with up to 16mil "sampling points").It does not matter whether the time scale is fs, ps, ns - those are just "numbers" for LTspice.If you see a square wave 50/50 in the trace it takes "the smooth picture" of the trace, cuts it into up to 16mil "sampling points" and creates the spectra.Then it recalculates the freq axis.

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 07:24:36 pm
content: No, I am not talking about the FFT but the initial simulation. Getting the data that the FFT is to calculate from.

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 07:31:09 pm
content: An example:The square red or green wave/trace you see in the picture has unlimited numbers of "points".The rising and falling edges are there, in those unlimited numbers.. You cannot see them because of set zoom. You can zoom in, however.I selected 16.7mil of them for FFT.I can select the entire 10ns transient sim time for FFT. And the trace will be split into the 16.7mil points.

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 07:36:34 pm
content: So what is the smalest time step in the simulation for?

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 07:38:40 pm
content: Sorry it's the maximum not the minimum i am looking at. So presumably it decides the minimum by itself and is then allowed to use up to the maximum when it detects a steady state condition.

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 07:51:01 pm
content: Spice is adjusting the "time steps" dynamically during the transient simulation such it gets best results within required voltage/current tolerances.Imagine you do transient analysis 1sec long of a circuit.When the circuit is "smooth enough" (from math point) it uses "large steps".When there is a lot of nonlinearities (ie complex highly nonlinear models), the time step could decrease such the iteration results are "smooth enough".There is not such setting like min step therefore.You may set for the transient analysis a "maximum timestep" that forces the solver not to use "large" steps when the iterations are already within the abs/rel V/A tolerances.

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 07:57:15 pm
content: And the FFT on 1'000 cycles is completely different from what it is on 20 cycles

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 08:17:39 pm
content: The both are the same, but you see different details.See below.A 500GHz square wave from my above example - upper is 100ps long transient analysis, lower is 5000ps long one.No windowing, 260k samples.The spectra are the same afaik..

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 08:22:26 pm
content: So if I do FFT over a smaller period it will give a larger frequency sweep.

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 08:26:12 pm
content: Below the same with 100ps and 5000ps long waveform.16.7mil points FFT, B-H window.Again, the spectra are the "same", where the bottom one (5000ps long) has got much lower min frequency in the spectra, AND, it is much more detailed.Fundamental is 500GHz, square-wave where the rise is 0.1ps and fall is 0.3ps.

author: Simon
author_rank: Unknown
timestamp: May 06, 2019, 08:34:57 pm
content: i am getting the reverse, 1s of data gets an FFT from 1Hz to 8MHz, but for 20ms it goes to about 300MHz from 50Hz. But below 1KHz there is no useful data and there is data well beyound the 100MHz.Is this all predictable? or do I have to guess and play around when I want to look at specific frequencies?

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 08:45:38 pm
content: Quote from: Simon on May 06, 2019, 08:22:26 pmWith constant N FFT points a shorter transient analysis duration gets "smaller FFT sampling time steps" - therefore the max spectral freq is higher.Again, the time domain waveform coming from transient analysis is "smooth" with none "time steps".

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 08:51:55 pm
content: Quote from: Simon on May 06, 2019, 08:34:57 pmSure it is predictable.Let the transient analysis is "ta" seconds long.Let the number of theFFT pointsis N.Thenyou will get N/2 spectral lines and* the highest spectral line isfmax = (N/2)/taand the lowest spectral line isfmin = 1/taor something like thatPS: An example:ta = 20msN = 16.7milfmax = 417MHzfmin = 50Hzta = 1sN = 16.7milfmax = 8.35MHzfmin = 1Hz* the spectra is again "smooth" with theoretical max N/2 spectral lines.

author: iMo
author_rank: Super Contributor
timestamp: May 06, 2019, 09:10:39 pm
content: And as always you may zoom in into the spectra:PS: in order to get the best spectra you have to apply a Windowing function before you do the FFT.There are dozens of W functions, each suitable for a specific case.LTSpice offers many.Otherwise it is a rocket science..

author: Simon
author_rank: Unknown
timestamp: May 09, 2019, 06:44:02 am
content: OK, thanks, if the shorter data still yields results then it makes sense with the shorter data. I thought the idea of FFT was to assume that the portion of signal supplied repeats itself over and over to infinity.

author: pwlps
author_rank: Frequent Contributor
timestamp: May 09, 2019, 07:52:32 am
content: Quote from: Simon on May 09, 2019, 06:44:02 amYes exactly, it repeats itself, this is why windowing or at least padding with zeros is recommended to attenuate the artifacts generated by the wraparound. The artifacts are even more dramatic when you try to restore the original signal from its FFT spectrum, you might have a look on this :https://www.eevblog.com/forum/beginners/fft-and-signals/msg2321997/#msg2321997

author: Simon
author_rank: Unknown
timestamp: May 14, 2019, 03:09:30 pm
content: So I assume the period of time i analyse should correspond to the signal period so that when it wraps it's a carrect signal.

author: pwlps
author_rank: Frequent Contributor
timestamp: May 14, 2019, 04:44:41 pm
content: Quote from: Simon on May 14, 2019, 03:09:30 pmOr even to many signal periods, depending on the frequency resolution you need. To examine the harmonic content of a signal one period will be sufficient but if you want to measure the phase noise of your signal then you need many periods (although I suppose there won't often be any phase noise in simulations, maybe except when you want to simulate a PLL capturing dynamics).

author: Simon
author_rank: Unknown
timestamp: May 15, 2019, 06:30:28 am
content: I'm just looking at RC filtered waveforms and square waves with various rise/fall times.