Author Topic: Floating kilofarad capacitor causes noise in LTspice BJTs  (Read 2210 times)

0 Members and 1 Guest are viewing this topic.

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Floating kilofarad capacitor causes noise in LTspice BJTs
« on: July 09, 2019, 06:45:34 am »
Posting in "beginners" because I'm new to spice and not sure if it's something considered "normal" in this software :-//

Anyway, 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 frequencies :scared: It made completely no sense and, ultimately, removing the capacitor fixed it |O

I 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 here :scared:

Red 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. :D
 

Offline exe

  • Supporter
  • ****
  • Posts: 2647
  • Country: nl
  • self-educated hobbyist
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #1 on: July 09, 2019, 07:54:19 am »
Did you try to reduce the value of capacitor? To, say, 1 farad or even less. May be there are rounding errors or something.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #2 on: July 09, 2019, 08:25:36 am »
Try adjusting RELTOL, VTOL, CHGTOL or whatever TOLs LTSpice has.

Also try TRAP integration, the default hacked integration is notoriously inaccurate.
Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline alanb

  • Frequent Contributor
  • **
  • Posts: 344
  • Country: gb
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #3 on: July 09, 2019, 01:09:45 pm »
Do you really mean Kilo farad i.e. 10^3 farad? that is exceptionally large.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #4 on: July 09, 2019, 02:24:55 pm »
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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #5 on: July 09, 2019, 09:13:14 pm »
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.
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 4135
  • Country: 00
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #6 on: July 10, 2019, 05:02:17 am »
It seems like insufficient dynamic range of data types used in calculations.
For what reason you're needs megafarad capacitors? :)
 

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #7 on: July 10, 2019, 10:11:47 am »
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 impedance ;)

Btw, disregard the 100k resistor in my picture, this is a simplified circuit I made to demonstrate the problem.
 

Offline SilverSolder

  • Super Contributor
  • ***
  • Posts: 6126
  • Country: 00
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #8 on: July 23, 2019, 08:06:49 pm »

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.

 

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #9 on: July 24, 2019, 07:24:32 am »
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 slower

Finally, 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.
 

Offline SilverSolder

  • Super Contributor
  • ***
  • Posts: 6126
  • Country: 00
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #10 on: July 25, 2019, 04:03:26 am »
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.
« Last Edit: July 25, 2019, 04:25:37 am by SilverSolder »
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #11 on: July 25, 2019, 10:23:29 pm »

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.

".OPTIONS numdgt=15"

PS: do read the manual before using a tool :)
I 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..
« Last Edit: July 25, 2019, 10:43:36 pm by imo »
Readers discretion is advised..
 

Offline SilverSolder

  • Super Contributor
  • ***
  • Posts: 6126
  • Country: 00
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #12 on: July 26, 2019, 01:36:46 am »

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.

".OPTIONS numdgt=15"

PS: do read the manual before using a tool :)
I 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..

The 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???  :)
 

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Re: Floating kilofarad capacitor causes noise in LTspice BJTs
« Reply #13 on: July 26, 2019, 07:26:50 am »
I 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..
Fair 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 it :--

By 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. :palm:
 

Offline SilverSolder

  • Super Contributor
  • ***
  • Posts: 6126
  • Country: 00
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf