My attempts at a design of a 3 stage amplifier

Administrator
Joined 2007
Paid Member
Simulating power supplies can be done a couple of ways. One method is to set each rail up as a voltage source that appears like ripple. The three images show the settings for a - and + 45 rail of fixed ripple. This can be useful for evaluating power supply rejection.

A second method is to add an AC voltage source and bridge rectifier to the simulation. Here I have used just 1000uF reservoir caps to highlight the ripple.
 

Attachments

  • V3 +45 Volt Rail.JPG
    V3 +45 Volt Rail.JPG
    74.5 KB · Views: 359
  • V4 -45 Volt Rail.JPG
    V4 -45 Volt Rail.JPG
    75.9 KB · Views: 357
  • Capture.JPG
    Capture.JPG
    187.8 KB · Views: 351
  • Capture2.JPG
    Capture2.JPG
    287.7 KB · Views: 336
Administrator
Joined 2007
Paid Member
One thing to note, the ripple simulation is now exclusively a 'transient' type meaning that DC analysis (the .op command) does not work. This is because there is no fixed DC rails powering the circuit, they are derived just like the real thing from an AC source.

If you right click the two voltage sources feeding the bridge you will see how they are set up. Note the 180 degree phase shift for one of them. Here is the sim file. If you are using LTXVII then the 30 amp rectifiers may not be included in the model library... just pick something else that is.
 

Attachments

  • Draft2.asc
    13.9 KB · Views: 80
In KiCad I used PWR_FLAG and the error did not appear anymore. However, there is still one remaining problem before I can proceed to successfully process my schematic. KiCad is telling me transistor footprints like To-92, To-225, To-3PL, etc are legacy and that I must enter their modern equivalents manually. I tried good-old-google, but it seems, at google they are more interested in giving links to commercial sites rather then giving me a link to a site that can help me.

Does anyone know of a list listing these legacy footprints and their modern codes?
 
I am reading tutorials about using LTSpice, and in fact succeeded to produce charts for a simple circuit diagram, but I am still stuck to produce meaningful output from ltspice. The reason is I cannot make heads or tails of how nodes of a circuit are represented in the list of variables displayed whenever I try to draw a new chart.

What is the meaning of these?
V(p001)
V(n001)
V(n002)
V(n003)

I assume the meaning of Ie(Qn), Ic(Qn), Ib(Qn) are for the emitter, collector and base currents of Qn respectively.

How are nodes numbered? Is there a way of avoiding this ambiguity?
 
Nodes are numbered automaticaly by LTSpice when you make connections on your schematic. If you hover the mouse over a connection you can see the node number in bottom left of window.
You can label nodes with meaningful names if you want: put mouse over connection -> Right click -> label net.

If you want to plot the voltage at node n007, you just select V(n007) from the list in the plot dialog.
 
I am using LTspice to simulate a simple amplifier which I am designing for learning purposes. Feedback and suggestions are welcome and appreciated.

These are the screenshots from LTSpice.
 

Attachments

  • trial-cct.png
    trial-cct.png
    43.7 KB · Views: 167
  • freq-response.png
    freq-response.png
    42.1 KB · Views: 299
These are my results after increasing key resistors for the circuit to use +/- 60V DC. The simulation amplifier has been added an output stage that drives directly from the VAS. I know driving a large output stage directly from the VAS is rather naive, but there is nothing wrong in simulating an amplifier like that if it helps undestanding of key concepts.

The blue and red plots are currents from the power supplies. The blue plot is the output voltage developed across the output load resistance of 25 Ohms. The simulation frequency is 4500Hz. The thing that is exciting me is the 'nice' looking sine wave, which suggests distortion should be low, but how do I tell LTspice analyse for distortion?

The next step will adding more workhorses in the output to drive a proper 8 Ohm load and a driver stage.
 

Attachments

  • cct-with-added-output-stage.png
    cct-with-added-output-stage.png
    44.8 KB · Views: 169
  • output-with-added-power-stage.png
    output-with-added-power-stage.png
    35.1 KB · Views: 133
Last edited:
Online, I read in this same forum, that LTSpice is unreliable for distortion analysis, especially, when it comes to calculating the distortion percentage. Yesterday, I did a distortion analysis for a perfectly looking sine wave and got 700%! This is worse than ridiculous. For anyone who took interest to study mathematics beyond secondary level, a distorted sinewave looks like a dented mud-guard and is horrible to look at. The Fourier Analysis results looked more realistic indicating distortion components starting from -20dB downwards. I estimate this as a figure of around 1% of distortion although this is plain guesswork.

I cannot imagine why the fundamental frequency is included in the Fourier distortion analysis. The fundamental is not a distortion but the signal component! A better way would be an analysis of the signal with a pure sinewave removed, so that, only distortion components are left. Plotting that difference would give a very clear idea of the actual distortion signal waveform. if LTSpice can give a list of (t, V), time, voltage, points for a waveform output, I should be able to process that information to get a clear visual idea of the distortion waveform. I assume LTSpice can be directed to draw custom graphs like that.
 
There's a little bit you need to do with LTspice to do good distortion analysis. Straightforward things like ensuring you're simulating an integer number of cycles of your harmonic, turning off compression etc.

Lots of us make really extensive use of LTspice for distortion. It's a very accurate tool if driven intelligently.
 
Here are two attachments with one showing output voltage VS input voltage and the other is the edited circuit with more power transistors.

The output VS input chart shows some hysteresis, that is, distortion as this is a deptarture from the theoretical line form. As can be seen, the distortion figure should be very low.
 

Attachments

  • output-vs-input-voltage.png
    output-vs-input-voltage.png
    32.6 KB · Views: 333
  • circuit-with-added-power-transistors.png
    circuit-with-added-power-transistors.png
    49 KB · Views: 330
Administrator
Joined 2007
Paid Member
Have a look at this, a 20kHz voltage source and resistor (resistor isn't even needed actually).

We have added the commands to calculate distortion, and added the plotwinsize=0 to turn off compression.

Now I'll add a timestep. The simulation is set to run for 4ms and the FFT sample is at the default of 262144. Dividing 4ms by 262144 gives us 0.0000000152587890625 seconds. Now we'll paste that into the timestep window and run the simulation.

Finally another trick up our sleeve. We can add the command .options nundgt=7 which gives double precision to the calculation of variables. Again we run the sim. This is as good as it gets. The fundamental and nothing else. Distortion is 0.000000000000...…
 

Attachments

  • DS1.JPG
    DS1.JPG
    295.6 KB · Views: 310
  • DS2.JPG
    DS2.JPG
    218.3 KB · Views: 323
  • DS5.JPG
    DS5.JPG
    196.5 KB · Views: 314

PRR

Member
Joined 2003
Paid Member
I did a distortion analysis for a perfectly looking sine wave and got 700%! This is worse than ridiculous. ...

Then you did something wrong. (Good on you for "knowing the right answer", and not taking SPICE as "Truth".)

Online, I read in this same forum, that LTSpice is unreliable for distortion analysis,

Does LTspice still have the .DIST card? That was always under-developed and is why .FOUR (Fourier) was developed.

In .FOUR you may specify the Center Frequency. If this is not your source frequency (as when you plot THD vs Freq and get out of sync) then it will get the right answer for the wrong question.

I cannot imagine why the fundamental frequency is included in the Fourier distortion analysis. The fundamental is not a distortion but the signal component!

Because the % is the ratio of the garbage TO the desired signal. So the fundamental (or whatever reference) must be in the report. .FOUR often shows the actual value of Harmonic #1, then Normalizes it to 1.000. Normalizes the other harmonics by the same ratio. Then does the sum and division and %.

.FOUR does usually give the "right" results, if you ask the right question, if your models are complete (none are).

Mooly has given some Advanced Tips for SPICE distortion. I didn't have his notes when I blundered into Pspice and fooled-around. For "small simple" distortion it is not essential to run magic numbers and odd incantations (for extreme low numbers it is).

Here is a perhaps rude example. A vacuum bottle with a large drive and heavy load. Without SPICE I would expect 5%-15% THD (depending on drive level).
tubeout-circuit.gif

When I simulate over one cycle, I get a zig-zag plot and a plausible 8.1% THD.
tubeout-1cycle.gif
The 1KHz 2KHz 3KHz 4KHz 5KHz peaks look plausible; the troughs between look to be sketched-in with a matchbook.

I increase the run to 200 cycles. The in-between, which perhaps should be zero, are now way-low and in fact are numeric "noise". (You see the same coarse/fine curves with spectrum analysis on audio signals; same Fourier formulas.) The total still computes to 8.1%.
tubeout-200cycle.gif

As in analog THD measurement, we can't get cleaner than out sine source. What is SPICE giving me??
rawsource-200cycle.gif

Not 700% but zero point three-oh something.
 

Attachments

  • tubeout-circuit.gif
    tubeout-circuit.gif
    6.8 KB · Views: 141
  • tubeout-1cycle.gif
    tubeout-1cycle.gif
    25.8 KB · Views: 114
  • tubeout-200cycle.gif
    tubeout-200cycle.gif
    24.4 KB · Views: 113
  • rawsource-200cycle.gif
    rawsource-200cycle.gif
    27.5 KB · Views: 107
Administrator
Joined 2007
Paid Member
I'm just going to say that I didn't read PRR's reply in that way at all :)

My take on it was that he is actually saying that you knew the result looked wrong and its good that you didn't just accept the answer. Many just accept the results that flash up on a screen, or blindly take the result of tapping away on a calculator as correct.

You didn't, you questioned it realising there was a problem ;)
 
To visually see distortion I plotted the input versus the output. For a non distorting amplifier, this should be a straight line passing through the Cartesian origin (x, y) = (0, 0). LTspice produced a neat straight line as described implying the distortion was very very low.

Why I am saying this? The reason is that any curve with a 1-1 relation can be expressed with the Maclauren Theorem which gives rise to a polynomial as follows:

y = k+ ax + bx^2 +cx^3 + ... + zx^n

First, constant k = 0, otherwise there would be a DC output for no signal. Second, constants b, c, ..., z must be very small. If we substitute x = A*sin(wt) as the input, we get an output:

y = a[A*sin(wt)] + b[A*sin(wt)]^2 + c[A*sin(wt)]^3 + ... + z[A*sin(wt)]^n

The powers over 1 generate other frequencies with various amplitudes. This is distortion.

For the first non linear term:
y = a[A*sin(wt)] + {bA^2/2}{1 - cos(2wt)} + ....

The harmonic cos(2wt) is a distortion component. bA^2/2 is its amplitude. Comparing this with the signal's amplitude we get
the ratio:

D = bA^2/(2aA) = BA/(2A)

P.S.
Attached there is an amplifier using a low voltage input stage with a high voltage output. I used droppers to reduce the voltage to +/- 15V for the input stage. LTspice is telling me it is stable but fiddling with some resistances, a sawtooth waveform superposes itself on the the output. I am liking this circuit because it fulfills what I intended at first but more measures to improve stability do not do any harm.
 

Attachments

  • low-volt-diff-input-and-high-volt-output.png
    low-volt-diff-input-and-high-volt-output.png
    56.2 KB · Views: 160
For distortion analysis, I'd suggest using the FFT: Run a transient analysis over at least 15-20 sine cycles. Select graph window, View menu >> FFT, select output voltage, 65536 points will do, Windowing function = Kaiser-Bessel, Beta = 20 or so. (Don't forget the ".option plotwinsize=0" SPICE directive. Insert = Press "S".)

One thing to note, the ripple simulation is now exclusively a 'transient' type meaning that DC analysis (the .op command) does not work. This is because there is no fixed DC rails powering the circuit, they are derived just like the real thing from an AC source.
JFTR, I prefer inserting a second voltage source in series just for the ripple instead, avoiding this particular problem. Linear superposition FTW. ;)
 
Last edited: