Floating kilofarad capacitor causes noise in LTspice BJTs - Page 1
Forum section: electronics / beginners

author: magic
author_rank: Super Contributor
timestamp: July 09, 2019, 06:45:34 am
content: Posting in "beginners" because I'm new to spice and not sure if it's something considered "normal" in this softwareAnyway, I was simulating some discrete amplifier and added a 1k capacitor from feedback input to ground to test its AC open loop behavior. When I was done, I disconnected it from ground but left it there in case it would be useful again.After some further changes, the circuit developed weird noise issue and I spent a whole hour trying to nail it down. It looked like there is some serious current noise or oscillation in the input BJT, sometimes reaching into GHz frequenciesIt made completely no sense and, ultimately, removing the capacitor fixed itI presumed that leaving dangling passives like that makes them effectively disabled. But some people on the Internet say that floating nodes may cause simulation errors unless a high value resistor is added to ground. Not sure why would it be, but I added 1Meg and it's still the same. 1k solves it though, as does direct short of course.I looked closer at the currents and it's evident that spice doesn't even respect Kirchhoff's law hereRed is feedback resistor current, it follows IN- to OUT differential voltage quite well. Green is current though that damn capacitor, almost zero almost all time, but not always. Blue is transistor base current and it goes into weird oscillation every now and then, mysteriously pulling voltage on IN- down.Not sure what to think of that.

author: exe
author_rank: Unknown
timestamp: July 09, 2019, 07:54:19 am
content: Did you try to reduce the value of capacitor? To, say, 1 farad or even less. May be there are rounding errors or something.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 09, 2019, 08:25:36 am
content: Try adjusting RELTOL, VTOL, CHGTOL or whatever TOLs LTSpice has.Also try TRAP integration, the default hacked integration is notoriously inaccurate.Tim

author: alanb
author_rank: Frequent Contributor
timestamp: July 09, 2019, 01:09:45 pm
content: Do you really mean Kilo farad i.e. 10^3 farad? that is exceptionally large.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 09, 2019, 02:24:55 pm
content: Yup! It's a common strategy for testing the AC response of a circuit, without having to worry about DC bias (.op solve it for you) or LF cutoff.Tim

author: magic
author_rank: Super Contributor
timestamp: July 09, 2019, 09:13:14 pm
content: Okay, I found those options."Modified trapezoid" is the default integration method in LTspice, whatever it is. Other options are "trapezoid" (same results) and "gear", which gives regular 70GHz oscillation.Relaxing tolerance parameters to some really poor values helps, in the sense that the circuit stabilizes after a few µs of jumping around. Also reducing the feedback resistor makes it stabilize after a moment.It still disturbs me that a floating capacitor has any influence on the circuit, but I'm not inclined to mess with it further. The obvious fix (which helps) is to disconnect the capacitor from IN- rather than from ground when it isn't needed.

author: radiolistener
author_rank: Super Contributor
timestamp: July 10, 2019, 05:02:17 am
content: It seems like insufficient dynamic range of data types used in calculations.For what reason you're needs megafarad capacitors?

author: magic
author_rank: Super Contributor
timestamp: July 10, 2019, 10:11:47 am
content: Together with normal feedback resistors it implements a first order lowpass filter which passes DC and stabilizes the output around zero but wholly rejects AC upwards of 1Hz so the amplifier runs at full open loop gain. Then I can use AC analysis to get a gain/phase plot like those in opamp datasheets.It does take a bit of capacitance to reject 1Hz more than 120dB from 500Ω source impedanceBtw, disregard the 100k resistor in my picture, this is a simplified circuit I made to demonstrate the problem.

author: SilverSolder
author_rank: Super Contributor
timestamp: July 23, 2019, 08:06:49 pm
content: One possible trap with LTSpice for high precision work is the need to add ".OPTIONS numdgt=7" somewhere on the sheet, in order to tell LTSPICE to switch to double precision math on dependent variables. Otherwise, the results can be too coarse/ noisy.

author: magic
author_rank: Super Contributor
timestamp: July 24, 2019, 07:24:32 am
content: Did you mean to simply click "add spice directive" and paste this text? That makes no difference.I discovered another wonkiness in LTspice while trying to use an RC filter in simulation. It seems that DC operating point analysis somehow assumes 1TΩ/C of resistance for capacitors. This is in strict contradiction with the info text, which says that DC analysis considers capacitors open circuit.So the following circuit has DC operating point of 10nV. If I increase C1 to 1T or R1 to 1G, it reliably changes to 5V.It also shows some initial burst of current through C1 and later an oscillation, which could be the things that upset my BJTs. Changing anything here, including simulation time, makes the oscillation go away. Apparently, it may be retriggered by external factors in a more complex circuit.One option which I found to eliminate oscillations (so far) is switching to "alternate" solver, supposedly more accurate but slowerFinally, the output doesn't decay towards zero as one could expect. I can increase time from 10 to 10k, which is 10 time constants, and it's still 10nV at the end. I reduced C1 to 1 such that τ=1s and after 1s the output was still 10pV. I'm not sure if that's because transient simulation also shunts C1 with 1GΩ, or because of some aberrations caused by the erroneous initial condition.

author: SilverSolder
author_rank: Super Contributor
timestamp: July 25, 2019, 04:03:26 am
content: Try a transient analysis instead, with the "Start external DC supply voltages at 0V" checked.Now, the curve looks a lot more realistic.Also, if you don't like the default parallel resistance for C1, you can change it by right clicking on it and entering a suitably astronomical value. I got the current down to the femtoamp region that way.

author: iMo
author_rank: Super Contributor
timestamp: July 25, 2019, 10:23:29 pm
content: Quote from: SilverSolder on July 23, 2019, 08:06:49 pm".OPTIONS numdgt=15"PS: do read the manual before using a toolI would also recommend you to start with more realistic scenarios. LTSpice is basically a math engine, working on the SISO principle.. Also mind it does not use an unlimited floating point precision..

author: SilverSolder
author_rank: Super Contributor
timestamp: July 26, 2019, 01:36:46 am
content: Quote from: imo on July 25, 2019, 10:23:29 pmThe manual says "In LTspice, if 'numdgt' is set to be > 6, double precision is used for dependent variable data."By setting it to 15, aren't we needlessly and wastefully using up too many numbers in between???

author: magic
author_rank: Super Contributor
timestamp: July 26, 2019, 07:26:50 am
content: Quote from: imo on July 25, 2019, 10:23:29 pmFair enough, but IEEE754 has not even just one but a whole two ways of representing zero with absolute accuracy.I naively expected DC conductance of capacitors to be just that. It seems I can override their leakage resistance, but sometimes I would rather simply disable itBy the way, the reason I created this RC circuit was to get AC coupling of some signal for more convenient viewing. Is there a better way of doing that?Now going back to my first problem, I think what may have happened is that this leakage resistance added by SPICE created a loop with the capacitor and allowed SPICE to think that current flow through the capacitor is possible, resulting in numeric glitches due to the unusually high capacitance or whatever. Lesson learned: don't leave floating nodes in places that matter and expect hidden parasitics even in ideal components.

author: SilverSolder
author_rank: Super Contributor
timestamp: July 26, 2019, 10:58:06 am
content: Sadly, nothing is ideal...e.g.https://stackoverflow.com/questions/588004/is-floating-point-math-broken