Spice simulation

estuart said:
Hi Grey,
You're really lazy, aren't you. :) Never mind, his nick is MarcelvdG, or look at:
http://www.diyaudio.com/forums/member.php?s=&action=getinfo&userid=5881
Cheers,

Hi Grey,

This is the article: "Noise and moving-magnet cartridges", Marcel van de Gevel, EW, October 2003, pp. 38...41.
Theoretical noise reduction: 6dB, in practice: 3dB. If you promise you'll make no more nasty remarks about simulators, I'll scan it for you. :)

Cheers,
 
estuart said:


Hi Grey,

You're really lazy, aren't you. :) Never mind, his nick is MarcelvdG, or look at:
http://www.diyaudio.com/forums/member.php?s=&action=getinfo&userid=5881

Regarding simulator version xx.01 vs xx.02 etc., you probably missed my point. If we are dicussing the merits and flaws of simulators, it's not unreasonable to suppose that we mean today's simulators. So, if someone is complaining about missing features of a 25 years old version or so, that is totally irrelevant IMHO.



Cheers,


I don't recall mentioning 25 year old software...but that's okay, I've about used up all my grumble quotient for this week. (Having a six month-old throw up on you kinda causes you to refocus...) Bear in mind that I'm not John Curl. He's mentioned older hardware/software several times, but I don't recall doing so, myself. Yes, I know it seems silly that someone might mistake me for John Curl, but I've been accused of being Nelson Pass's doppleganger enough times that I'm wary of the possibility.
As for MarcelvdG, thanks. To the best of my knowledge they don't have an "actual name" search function here and for all I know he'd be one of these members who feels they have to come up with something cutsie like PhrostyPhono or ChillyCircuit for a user ID.
As for a scan, yes I'd love one if it's not too much trouble.

Grey
 
LTSpice techniques for simulation of loop gain

Over in the error correction thread I posted an LTSpice simulation of Bob's EC output stage that used a loop gain probe component for doing stability analysis of the EC loop. There are some special configuration settings that need to be used for such simulations, which I mentioned in that thread. Anatech asked me to post that info in this thread, so I am doing so here.

The whole loop gain/stability simulation thing in LTSpice is confusing because there have been a number of methods used over the past few years. I'll describe them in chronological order below. All the LTSpice examples I'll refer to below are in the LTSpice installation in examples\Educational.

1) Easiest but can be inaccurate The simplest way to simulate loop gain is documented in the LTSpice example project "audioamp.asc". Only a single voltage is used to inject a test signal. Depending on the impedance levels where this voltage is injected, accuracy can range from very good to completely wrong. For this reason, I'd recommend avoiding this technique. No special setup of LTSpice is required.

2) Accurate but a total PITA This technique and the rest that follow make use of the "double injection" technique (voltage and current) due to R.D. Middlebrook. The earliest LTSpice example of this in the LTSpice example file "LoopGain.asc". This technique is a PITA because it must be done with two copies of the circuit under test. For this reason, it's best avoided. Still, it does illustrate the concept. To use this technique, you must go into the LTSpice control panel and enable "Save Device Currents" on the "Save Defaults" dialog tab.

3) Accurate but easier than (2) In the LTSpice users' group, people were looking for a way to do double injection without needing to make two copies of the circuit under test. An improved technique was developed by Frank Wiedmann, and used a subcircuit to inject the test voltage and current. This, combined with a .STEP PARAM command to turn the voltage and current sources in the subcircuit on and off, and some strange looking syntax to access voltages and currents for the different STEP states allowed loop gain calculations without circuit replication. In addition, results from a paper by Tian were incorporated, which take into account reverse transmission of the network (non-unilateral behavior). This particular approach does not have an example in the LTSpice installation, but can be found in the files section of the LTSpice users' group. I posted the loop gain probe subcircuit and symbol files here, and an example of its use in analyzing stability of Bob's EC output stage here.

There was a quirk in the history of Frank's solutions. Frank created his original examples and uploaded them to the LTSpice users' group files area. Then the LTSpice developer, Mike Englehardt, needed to make some changes to the syntax for referring to voltages and currents in different states of the STEP command. These syntax changes invalidated Frank's original examples, so Frank uploaded new examples using the new syntax. The old and new examples are both still in the LTSpice users' group files area, so be aware that you may run across the older ones if you get all the loop gain probe examples from there. These older examples won't work with the latest LTSpice version.

In order to use this technique, you'll need to go into the LTSpice control panel and enable the following three items on the "Save Defaults" tab

Save Device Currents
Save Subcircuit Node Voltages
Save Subcircuit Device Currents

This results in large ".raw" files being left behind. To fix this problem, you can go into the "Operation" tab of the LTSpice control panel and set "Automatically delete .raw files" to "yes".

I've posted a bunch of examples using Frank's loop gain probe, but that was before I found out there was a slightly easier way. I'll describe that next.

4) Easiest of the accurate approaches Sometime after Frank posted his loop gain probe solution, Mike Englehardt added a loop gain example to the standard LTSpice examples in examples\Educational. This is a slight simplification of Frank's technique which avoids the subcircuit, resulting in cleaner syntax. In addition, the full description of how to use it correctly is all in one file. That file is called "LoopGain2.asc". I'd recommend using the technique described in that file, since it's now part of the standard examples and is the simplest of the accurate approaches. Using this approach only requires that the "Save Device Currents" option be checked on the "Save Defaults" dialog tab of the LTSpice control panel. Subcircuit voltage and current saving is not required. I'd still recommend using "Automatically delete .raw files" on the "Operations" tab of the LTSpice control panel to keep the largely useless ".raw" files from piling up.
 
Hi all

correct me if I'm wrong but all these loop simulations are calculated under AC condictions. Class AB amps run the transistors through a wide dynamic range, so the small-signal values cannot be accurate as the simulator probably uses the prevailing DC conditions (i.e. quiescent) - only applying therefore to small perturbations about the quiescent (100 mW output for a 100W amp?). Sometimes instabilities in the output stage occurs in one side rather than the other due to changes in Cin for example with current.

Therefore transient simulations must be used, which is a problem because you need to sweep across lots of frequencies to build the "large signal" phase diagram - or at least check everything is stable.

Loop gain simulations should work for class A amps!

cheers
John
 
With a little work, you can adapt them. I was recently working on a sim of an amp whose small-signal loop gain showed a phase margin of nearly 90 degrees. But I looked at the error current in the input diff amp when simulating a square wave input that drove the output almost to clipping. There was some really bad ringing in the error current. The ringing was at a frequency near the unity loop gain frequency of the global feedback loop. It was worst when the output voltage was near the negative rail.

So I set up the sim so the amp had a closed-loop gain that was flat to DC. I set the input signal to a simple DC value that put the amp's output almost to the negative rail where the ringing in the error current was worst in the transient sim. Then I did a loop gain test. Sure enough, the phase margin wasn't much better than zero. I modified the compensation so the phase margin was about 80 degrees. When I re-ran the square wave transient test, the error current looked nearly perfect, like a first-order system.

So yes, the transient response test is necessary, and tells you there's something wrong, but doesn't tell you the best way to fix it. A loop gain test with DC offset can be a good tool to determine how to fix it without overcompensating.

Another sim, suggested by mikeks, is to have a low-frequency sine wave input whose amplitude almost drives the amp into clipping. Then you can add a small-amplitude square wave of a frequency about 10-20x higher than the sine wave. You look at ringing on each little pulse on the output. In practice, it seems to be worst when the output is near the rail.
 
Instead of doing Spice, yesterday I bought a book on transistor theory: 'The Bipolar Junction Transistor' Vol3 By Gerold W Neudeck from the modular series on solid state devices, Addison Westley Publishing, once used at a course at Purdue, just to get back to understanding how transistors REALLY WORK.
I hope to cast further aspersion on Spice models in the near future by reading this text. vampire2:
 
andy_c said:
With a little work, you can adapt them. I was recently working on a sim of an amp whose small-signal loop gain showed a phase margin of nearly 90 degrees. But I looked at the error current in the input diff amp when simulating a square wave input that drove the output almost to clipping. There was some really bad ringing in the error current. The ringing was at a frequency near the unity loop gain frequency of the global feedback loop. It was worst when the output voltage was near the negative rail.

So I set up the sim so the amp had a closed-loop gain that was flat to DC. I set the input signal to a simple DC value that put the amp's output almost to the negative rail where the ringing in the error current was worst in the transient sim. Then I did a loop gain test. Sure enough, the phase margin wasn't much better than zero. I modified the compensation so the phase margin was about 80 degrees. When I re-ran the square wave transient test, the error current looked nearly perfect, like a first-order system.

So yes, the transient response test is necessary, and tells you there's something wrong, but doesn't tell you the best way to fix it. A loop gain test with DC offset can be a good tool to determine how to fix it without overcompensating.

Another sim, suggested by mikeks, is to have a low-frequency sine wave input whose amplitude almost drives the amp into clipping. Then you can add a small-amplitude square wave of a frequency about 10-20x higher than the sine wave. You look at ringing on each little pulse on the output. In practice, it seems to be worst when the output is near the rail.


Very good point and approach, Andy. I've also seen lots of cases where the phase margin went south under certain voltage or current conditions.

Bob
 
john curl said:
Instead of doing Spice, yesterday I bought a book on transistor theory: 'The Bipolar Junction Transistor' Vol3 By Gerold W Neudeck from the modular series on solid state devices, Addison Westley Publishing, once used at a course at Purdue, just to get back to understanding how transistors REALLY WORK.
I hope to cast further aspersion on Spice models in the near future by reading this text. vampire2:


Hi John,

I think I remember that series of books. Maybe six fairly small volumes. I think I had the series in one of my courses in college.

You're right that SPICE models are certainly not perfect, but the simulation results can still be very valuable.

Bob
 
john curl said:
Instead of doing Spice, yesterday I bought a book on transistor theory: 'The Bipolar Junction Transistor' Vol3 By Gerold W Neudeck from the modular series on solid state devices, Addison Westley Publishing, once used at a course at Purdue, just to get back to understanding how transistors REALLY WORK.
I hope to cast further aspersion on Spice models in the near future by reading this text. vampire2:

John,

I had Professor Neudeck for a course in transistor circuit design, EE255 at Purdue, around 1976 or so, when he wasn't all that much older than I was. He was a great guy, and also sometimes quite entertaining.

-------

Simulations, and also hand calculations, obviously depend on how good the models are, for the usefulness of their results.

But, given that the models are not perfect, the usefulness of simulations depends at least as much on the assumptions of the person doing them.

Bob Pease's famous "issues" with the use of Spice seem to have more to do with some people's idiotic "blind faith" assumptions about the models and simulation results, than with simulation per se.

One of the main reasons we have "engineering" is to try to be able to design things and then "know" that a design will work, before it is built. That's usually an imperfect process, of course (sometimes "by design"), and often requires iteration, after prototypes are built. However, the basic idea implies that we should consider using whatever design tools are available and helpful, incuding computerized tools, of which Spice is but one. Of course, our brains are our most-important tools. If they are not used properly, tools like Spice can be worse than un-helpful.

Bottom line: Blame the user, not the tool.


- Tom Gootee

http://www.fullnet.com/~tomg/index.html

-
 
You must come to understand that I have been professionally involved with circuit simulation since 1966. That is a long time! I just don't DEPEND on Spice for my circuit designs. It's OK, and it gets better all the time. Still, I don't need it to make a successful product. Neither did the designers who made the ua741 possible.
 
Re: sophisticated amplifiers

estuart said:
BTW, Bob, there is a difference between sophisticated amplifiers and real sophisticated amplifiers. ;)
Let's say 20dB less THD and IMD, or, if you like, anything equal or better than Halcro.

Cheers. Edmond


Hi Edmund, I must have missed a post you made (maybe it was not in this thread).

I don't want to get into semantics between sophisticated and real sophisticated, but I think my definition above was adequate, and of course I think that the MOSFET power amplifier with error correction that I did 25 years ago lies in that realm. It achieved 6 ppm (0.0006%) at 20 kHz THD in a 200 khz measurement bandwidth.

With regard to Halcro, are you referring to Halcro's stated performance or actual performance? I've seen no evidence that they meet their stated performance (even after Stereophile reviewed the DM38 again), but I allow for the fact that properly measuring performance in the range that they state can be difficult.

Forgive me if I missed a post, but have you actually built and measured an amplifier that does 1 ppm or below ( e.g., <120 dB) across the full spectrum from 20 Hz to 20 kHz on both THD and CCIF IM at any power from 1 watt to full power? If so, that is very impressive, and please refresh my memory and/or tell us more.

Simulations don't count. Although I am a firm believer in SPICE, I have always been reluctant to depend on it for estimates of distortion achievable in practice.

Cheers,
Bob
 
Re: Re: sophisticated amplifiers

Bob Cordell said:
Hi Edmund, I must have missed a post you made (maybe it was not in this thread).


Hi Bob,

Yes, probably you did. In my post#1552, I was just a little bit joking, as somebody was referring to "sophisticated" amplifiers, which shows quite a lot of distortion. Therefore I stated: "Real sophistication starts at thd<1ppm, not at 0.02% or 0.25% in case of tubes."


Bob Cordell said:
I don't want to get into semantics between sophisticated and real sophisticated, but I think my definition above was adequate, and of course I think that the MOSFET power amplifier with error correction that I did 25 years ago lies in that realm. It achieved 6 ppm (0.0006%) at 20 kHz THD in a 200 khz measurement bandwidth.

Sure, you definition is adequate, but also 25 years in the future? :)
6ppm? NO, 7 ppm, according my simulation. :)

Bob Cordell said:
With regard to Halcro, are you referring to Halcro's stated performance or actual performance? I've seen no evidence that they meet their stated performance (even after Stereophile reviewed the DM38 again), but I allow for the fact that properly measuring performance in the range that they state can be difficult.

Maybe Candy is lying, but I never trust these measurements performed by such magazines. Besides, as you said, it's difficult to check the performance of a Halcro by means of an AP, for example. They should consult you to get reliable numbers. :smash:

Bob Cordell said:
Forgive me if I missed a post, but have you actually built and measured an amplifier that does 1 ppm or below ( e.g., <120 dB) across the full spectrum from 20 Hz to 20 kHz on both THD and CCIF IM at any power from 1 watt to full power? If so, that is very impressive, and please refresh my memory and/or tell us more.

Built? No, I'm retired and don't have the facilities any longer to build such amp. :sad: But I have designed amp's on paper with a thd (at 20kHz) around 20ppb. If some body give me the money and facilities to build such thing, I should really love it.

Bob Cordell said:
Simulations don't count. Although I am a firm believer in SPICE, I have always been reluctant to depend on it for estimates of distortion achievable in practice.

Cheers,
Bob

Well, it depends on the tools and models, and of course who is doing the simulation, it's really an art, just as building the real thing, to understand the power and limitations of a simulator.
Anyhow, my latest design shows, a thd (20kHz) of 20ppb. Maybe my sim is one order of magnitude wrong, that still leaves a 0.2ppm of distortion.

Cheers, Edmond.

edit: if you are really interested in my design, I'll send you the schematic (confidentially, of course).