Linearity simulations for amplifiers - Page 1
Forum section: electronics / projects

author: TheUnnamedNewbie
author_rank: Super Contributor
timestamp: December 22, 2023, 08:21:40 pm
content: What techniques do people use for simulating linearity in amplifiers as hobby/personal project? For the dayjob we tend to use harmonic balance/periodic steady state for this kind of stuff as it allows you to see the harmonics and not having to deal with startup transient behavior and so on. But to my knowledge, most of the free simulators like LTspice don't offer this kind of simulation tool.So what options are there aside from 'simulating transient and then taking fft from the output' are there?

author: G0HZU
author_rank: Super Contributor
timestamp: December 22, 2023, 08:36:40 pm
content: I've not tried to use it but QUCS Studio has a harmonic balance simulation engine. This is free SW.I usually use the harmonic balance simulator in Genesys for stuff like this. It's very powerful and usually gives good results. I've not seen the QUCS version in action so I can't comment on how well it performs.

author: moffy
author_rank: Super Contributor
timestamp: December 22, 2023, 10:37:00 pm
content: For LTSpice setup a sine generator for transient response, choose a minimum time step to give plenty of resolution, then go into the control panel and turn off compression. Run your simulation then do FFT on a completely stable section of the waveform, choose your window and large sample size and you should get heaps of resolution on the harmonics. Choose your section of waveform to be an exact multiple of the generator frequency.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 23, 2023, 12:44:42 am
content: Quote from: moffy on December 22, 2023, 10:37:00 pmI mostly second that, but have a question: why disabling compression?On another note, selecting an exact multiple of the fundamental frequency is a tad annoying, especially with a tool like LTSpice. If you use a large enough window (so with a significant number of fundamental periods) and apply a reasonable window function (my default window func. for FFT, for distortion anayisis, is Blackman-Harris), you'll be fine.Alternatively, if what LTSpice provides in terms of analysis doesn't cut it, you can export the transient simulation data from it, import it in your favorite tool (Matlab, Julia, Python, ...), and run any kind of fancy analysis you see fit. Pretty useful setup if you need to go any further than what the simulation tool provides.

author: moffy
author_rank: Super Contributor
timestamp: December 23, 2023, 01:06:28 am
content: Quote from: SiliconWizard on December 23, 2023, 12:44:42 amYou disable compression to improve the numeric resolution, you get more digits for some reason. Its easy to automatically set the size to a multiple of the sampling frequency just by the start and stop times. I have found that not doing that introduces some artifacts in the FFT and if looking for better than 100db resolution it helps. But at the end of the day it is just a simulation, it is not going to be incredibly accurate because the devices are idealised and simplified.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 23, 2023, 09:22:15 am
content: AFAIK part of the compression is removing points from the result where not much changes. The uneven sampling can confuse the FFT software. Even than one may have to resample the data as the time steps are not necessary all equal to start with - it may get quite good, when one forces relatively short steps.How accurate the simulation is depends on the models. In addition that can be the numerical errors from the simulation, e.g. from time steps not short enough. The simulation for linearity may have much higher demands on the convergence level than a more normal simulation.A point usually not included in the modes are thermal effects, like a trasistor warming up during the cycle and that effects the response.

author: G0HZU
author_rank: Super Contributor
timestamp: December 23, 2023, 10:04:48 am
content: I think the point here is that the transient analysis with LT Spice is going to be clunky and slow compared to a harmonic balance analysis. With harmonic balance, the non-linear analysis is effectively in real time, so you can tweak components values and look at distortion in the time domain and the frequency domain as you tweak. It can be really fluid in operation, like looking at a scope and a fast spectrum analyser at the same time.

author: moffy
author_rank: Super Contributor
timestamp: December 23, 2023, 11:15:53 am
content: Quote from: Kleinstein on December 23, 2023, 09:22:15 amDidn't know that but found this in the LTSpice help file under compression:"LTspice compresses the raw data files as they are generated. A compressed file can be 50 times smaller than the un-compressed one. This is a lossy compression. This pane of the control panel allows you to control how lossy the compression runs....You will probably want to turn off compression when using .four statements or doing FFT's in post analysis of your data with the SPICE directive:"

author: magic
author_rank: Super Contributor
timestamp: December 23, 2023, 11:28:05 am
content: Quote from: TheUnnamedNewbie on December 22, 2023, 08:21:40 pmAnother vote for "this seems to be the norm in hobby electronics"I have seen LTspice compression cause spurious tones to appear in FFTs. Disabling it is the norm, too. Also setting numdgt may increase dynamic range if you are pushing for something crazy.

author: macboy
author_rank: Super Contributor
timestamp: December 23, 2023, 12:51:01 pm
content: I set up a variable for frequency, then define the start and stop times from that. For this task, one doesn't want startup data but steady state, so I will set start time to say {990/freq} and end time to say {1000/freq} to capture 10 cycles, and min time step to e.g. {freq/10000} for 100000 FFT points. The simulation runs much faster during the time when it isn't saving data. Don't forget that in addition to the graphical FFT, you can also use the .four command/directive to get a numerical analysis of harmonics including a %THD figure. Turning off compression or setting plotwinsize = 0 is a must.

author: mawyatt
author_rank: Super Contributor
timestamp: December 23, 2023, 02:39:22 pm
content: When we were doing extensive chip design linearity simulations long ago (1990), one issue with doing FFTs on SPICE type simulations was, the unequal time sample spacings. The FFT resamples and interpolates the simulated samples into an equal spaced data set for the FFT, this interpolation introduce errors that show up in high dynamic range simulations. A solution worked out was to force the simulation at equal valued time spacing, if this isn't an option, then using very small time steps which produces large data sets for the FFT but reduces the interpolation errors.In the end, wether FFT based or Harmonic Balance based, the active device models limit results. For bipolar transistors, the popular Gummel-Poon models are limited and don't represent Quasi-Saturation, VBIC is better, MEXTRAM or HICUM are models of choice for high dynamic range simulations if available.For MOS, the older BSIM models have a built-in flaw that we discovered ~2000 and brought up to the Berkeley folks (fundamental model creators). This involves conditions when the Drain and Source interchange wrt to the Gate, as in an analog switch or high limiting action (MW Power Amp). The model used an absolute value when Drain and Source interchanged to keep the Vgs correct for satisfying computational needs and this caused a discontinuity in the 1st derivative of the transconductance. Normally this was hidden from results unless one was doing high DR simulations, which showed a higher harmonic content that suppressed TOI results used as Microwave metrics. At that time for CMOS we were forced to use the PSP (Penn-State Philips) model (when available) created by Dr G Gildenblat which was physics based rather than behavioral based like BSIM, and didn't have an issue with interchanging Drain and Source but caused significant additional computational overhead (longer sims & crashes). Later Berkeley solved this BSIM issue with later version models by referencing all device voltages to the substrate, rather than to each other.http://class.ece.iastate.edu/djchen/ee501/BSIM470_Manual.pdfhttps://briefs.techconnect.org/papers/linfet-a-bsim-class-fet-model-with-smooth-derivatives-at-vds0/https://www.nxp.com/docs/en/supporting-information/bctm94vreede.pdfhttp://km2000.us/franklinduan/articles/hspice/hspice_2001_2-113.htmlhttps://www.rfglobalnet.com/doc/philips-penn-state-develop-new-transistor-mod-0001The general message if one expects accurate high dynamic ranges results, quality high fidelity device models are paramount.Best,

author: MarkT
author_rank: Frequent Contributor
timestamp: December 23, 2023, 03:26:31 pm
content: Of course any simulation is only as good as the models for the devices, and typically doesn't simulate device-variation which can be a factor for real circuit. Layout issues also aren't simulated unless you go to the trouble to add a resistor for every pcb trace segment!Thinking about it, it would great to have a tool that took a PCB layout and build a circuit node model for all the trace resistances and stray L's and C's

author: mawyatt
author_rank: Super Contributor
timestamp: December 23, 2023, 03:32:22 pm
content: Quote from: MarkT on December 23, 2023, 03:26:31 pmI'm sure this must exist for PCBs, it's been around forever in IC layout tools, called "Parasitic Extraction"Another thing to consider, if one expects accurate simulation results, then knowingexactlyhow the simulator works andexactlyhow the models behave and are created, otherwise one is like a blind man at a shooting gallery!!Best,

author: G0HZU
author_rank: Super Contributor
timestamp: December 23, 2023, 03:36:48 pm
content: It's possible to simulate the PCB layout effects using EM tools like Sonnet. I've been using Sonnet at work to do stuff like this for about 20 years now.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 23, 2023, 07:40:37 pm
content: Quote from: moffy on December 23, 2023, 11:15:53 amThanks, I was not aware that compression would affect analysis in such a way.Otherwise I recommend ngspice if you have the Spice models for all your parts and don't rely on LT/AD parts with proprietary models. It's a lot more controllable and automatable.