DIYstompboxes.com

DIY Stompboxes => Building your own stompbox => Topic started by: fryingpan on September 06, 2024, 02:17:47 PM

Title: Is this even stable?
Post by: fryingpan on September 06, 2024, 02:17:47 PM
I'm trying my hand at discrete design and feedback.

It's a simple amp, three transistors, an npn into a pnp into an npn.

(https://i.postimg.cc/GB7zXjby/1725644720708.png) (https://postimg.cc/GB7zXjby)

Power supply is 18V through a 100 ohm resistor, appropriately bypassed through a 220uF capacitor.

This is the AC response taken from the output, simulated:

(https://i.postimg.cc/K4LrTb3L/1725644777905-1.png) (https://postimg.cc/K4LrTb3L)
 
The response seems to be smooth, even at minimum gain (set through the reverse log pot) although it is not Butterworth smooth, it's relatively flat (as simulated, just like a 0.1dB rise before the fall). What I don't understand is whether the amp is stable: at phase reversal the amp shows 4dB of gain. I don't understand if this is simply at the output or if this implies that the amp won't be stable because there will be more than unity gain in the feedback path at phase reversal.

(By the way, I don't understand why this works: feedback should be negative, but here, if I'm not mistaken, it's positive, since the signal injected into Q1's emitter from both Q2 and Q3 is in phase with the input. I tried reversing it but everything falls apart).

I tried adding a 30p cap between base and collector of Q2, and this is the result.

(https://i.postimg.cc/7GSG5xtZ/1725645234001.png) (https://postimg.cc/7GSG5xtZ)

Is this better? Is it worse? Why is there that response rise in the high MHz (I expanded the graph to better show this "interesting" phenomenon)? Is it even truthful, considering that it is only a simulation and these transistors are rated only up to 100MHz or so?

According to Rod Elliott, CFB amps (which this is, essentially) are inherently stable, so am I worrying too much? (I don't have a 100MHz scope, I wouldn't be able to measure the amp if I built it). Am I even going in the right direction?
Title: Re: Is this even stable?
Post by: antonis on September 06, 2024, 03:37:56 PM
Quote from: fryingpan on September 06, 2024, 02:17:47 PMCFB amps (which this is, essentially) are inherently stable

True but the more close to 100% feedback (R11 close to zero ohms) the more stable the CFP configuration.. :icon_wink:
Title: Re: Is this even stable?
Post by: fryingpan on September 06, 2024, 03:49:48 PM
I said CFB (current feedback, not complementary feedback pair). But anyway, would it work?
Title: Re: Is this even stable?
Post by: Rob Strand on September 06, 2024, 05:28:08 PM
Stability is a tricky subject.  There's approximate ways to analyze it where the degree of approximation depends on the circuit.

You are looking at *closed* loop gain which is not what you are concerned with when analyzing feedback stability.   What you want is open loop gain, or simply loop gain.   That's what feedback sees and what causes oscillation.

Stability typically gets *worse* when the closed-loop gain is *low*.  So in your case that would be when the 5k pot is set to 5k.


Scan over the video (BTW there's a document link in the video) to see the issues.

Your circuit has two feedback paths via R11 and R7 which means you need to break the loop after those two components, say at the emitter of Q1.   Otherwise if you try to insert a "big inductor" or loop analysis device at the output you will get the wrong results since you have two output paths.

Also since the input impedance of Q1's emitter is comparable to the impedance of the feedback network driving the emitter, the circuit is subject to analysis errors unless both voltage and current feedback are considered (as per the evolution of analysis in the video).

A simpler but less accurate method, which works for flat response amplifiers, it to inject a square-wave at the input then look at the output.  If there is gross ringing the amplifier is likely to be unstable or does not have enough phase-margin.   You need a to use a small signal square-wave where the amplifier isn't clipping.
Title: Re: Is this even stable?
Post by: PRR on September 06, 2024, 08:50:21 PM
Rob is correct. It is probably stable.

The emitter follower (same device and similar current) will not add much phase shift. So it is a 2-stage loop. Unless you have been very clever, 2-stages will only peak-up, not oscillate.

And we don't see real peaking.

One of R7 or R11 is pointless.

How did R1 become 6.3K? Is that even a standard value? Dartboard? Over-stock special?
Title: Re: Is this even stable?
Post by: Rob Strand on September 07, 2024, 04:38:22 AM
Quote from: PRR on September 06, 2024, 08:50:21 PMOne of R7 or R11 is pointless.

R7 vs R11 will have different characteristics.

Trying to remove R11 would mean Q2 would bias at low currents.
In this case perhaps change the R11 connection from R9 to ground.

R11 without R7:
- Easier to stabilize
  The feedback loop only involves two transistors and
  The load is isolated from the feedback point by the buffer.
BUT
- Having the buffer outside the loop means more distortion and a higher output impedance.

Feedback via R7:
- Harder to stabilize (not impossible as most power amps have this form)
  The load is inside of the feedback loop.
- Putting the buffer in the loop lowers distortion lower the output impedance.

It's generally a good idea to have the option to add a cb capacitor on Q2
to help stability.  It's not uncommon for these things to oscillate, depending
on supply bypassing,  and capacitive loading.

The source impedance feeding the base of Q1 can also affect stability.  Low
impedance helps but there's cases where you cannot control the source impedance
and in this case you need to make allowance for some source impedance when
considering stability (or overshoot in the step response).
Power amps tend to have RC filters at the input but preamps might not, and you
might not want or need it.
Title: Re: Is this even stable?
Post by: fryingpan on September 07, 2024, 06:41:52 AM
The double feedback path was borne out of expediency. It's the easiest way to decrease the gain at minimum gain without affecting maximum gain much. Of course, I could just attenuate the input, but this seemed more elegant. This way I can go from 12 to 35dB (instead of 22-36) at each extreme of the gain pot. 6.3k is an error, I misremembered the standard value  :icon_smile:
Title: Re: Is this even stable?
Post by: Rob Strand on September 08, 2024, 05:40:55 AM
FYI:  I did a  loop-gain plot.  I didn't look very deeply at the design, or try to break the design.    Only enough to get some numbers.  Not did I move the Tian insertion point around to see if the results were the same.

I had to re-enter the Tian equations so I'm kind of using the simpler current injection method as a crude cross-check.  I put the current injection at Q1's collector since it is a current output.  This is far more accurate than a voltage injection method (similar to the Big Inductor method but better) at Q1's emitter, since as mentioned earlier Q1's emitter loads the feedback network.  You can see from the plot how the current injection method is a good approximation to the more accurate Tian method upto about 10MHz.

Here's a plot of the loop gain using the Tian method and a much simpler current injection method.

(https://i.postimg.cc/pmhzz46j/preamp-fryingpan-loop-gain-V10.png) (https://postimg.cc/pmhzz46j)

The phase-margin is pretty good with a compensation capacitance (added collector-base capacitance on Q2) of 1pF or 10pF.

Title: Re: Is this even stable?
Post by: fryingpan on September 17, 2024, 02:04:32 PM
OK, so.

Why does this circuit:

(https://i.postimg.cc/xNQ2nZ3g/immagine.png) (https://postimg.cc/xNQ2nZ3g)

have such appalling drive? I did place a buffer after it.

This is the output open circuit:

(https://i.postimg.cc/Hch6t8VM/immagine.png) (https://postimg.cc/Hch6t8VM)

And this crap is with a simple 3K resistor after it:

(https://i.postimg.cc/LhGyYfdK/immagine.png) (https://postimg.cc/LhGyYfdK)
Title: Re: Is this even stable?
Post by: antonis on September 17, 2024, 03:10:04 PM
3k load forms a voltage divider with 7k5(R3) so output buffer can't go negative (lower to Emitter bias) more than Vout * 7k5 / (7k5 +3k)..

Title: Re: Is this even stable?
Post by: fryingpan on September 17, 2024, 03:17:27 PM
So the solution is to lower the emitter resistor? But I get "worse" characteristics when simulated, namely more high order harmonics produced close to clipping if R3 = 1k.
Title: Re: Is this even stable?
Post by: antonis on September 17, 2024, 04:20:25 PM
Quote from: fryingpan on September 17, 2024, 03:17:27 PMSo the solution is to lower the emitter resistor?

Not necessarily but, for sure, raising Q1 Emitter bias voltage significantly..
(resulting into redesign the whole thing..) :icon_wink:

P.S.
Is 3k actual load value or you're just playing..? :icon_biggrin:
Title: Re: Is this even stable?
Post by: fryingpan on September 17, 2024, 06:30:37 PM
Quote from: antonis on September 17, 2024, 04:20:25 PM
Quote from: fryingpan on September 17, 2024, 03:17:27 PMSo the solution is to lower the emitter resistor?

Not necessarily but, for sure, raising Q1 Emitter bias voltage significantly..
(resulting into redesign the whole thing..) :icon_wink:

P.S.
Is 3k actual load value or you're just playing..? :icon_biggrin:
I'd like it to play good with 10kohm loads (line level, albeit consumer rather than professional). 3kohm was an example of a very low load.
Title: Re: Is this even stable?
Post by: Rob Strand on September 17, 2024, 06:52:19 PM
The problem is the 1k (R5) resistor on Q1's collector is too small.

Q2 is biased near cut-off.

The R5 value is critical for biasing in these designs.

(After fixing R5) You can get more low-side drive by adding a resistor to ground on Q2's collector.  You need to check.

FWIW, the DC bias point isn't biased for optimal swing.
Title: Re: Is this even stable?
Post by: fryingpan on September 17, 2024, 07:25:47 PM
Quote from: Rob Strand on September 17, 2024, 06:52:19 PMThe problem is the 1k (R5) resistor on Q1's collector is too small.

Q2 is biased near cut-off.

The R5 value is critical for biasing in these designs.

(After fixing R5) You can get more low-side drive by adding a resistor to ground on Q2's collector.  You need to check.

FWIW, the DC bias point isn't biased for optimal swing.
I know that Q3 is misbiased and that voltage swing is not optimised. This allows for some gradual moderate distortion, up to 4-5%, mostly 2nd harmonic, before it clips, it's on purpose - it's for a mild track saturator and as it is, at minimum gain, it can accomodate at least 22dB of headroom with respect to a -10dBV level (and distorsion increases quite smoothly, 0.1% at the nominal level, 0.25% at +6dB, 0.4% at +10dB and so on). Of course, if I replace R5 with, say, 12k, and maybe lower R6 and increase R4 (and increase R8-R9) it all works as intended and cleanly (and I also have huge gain). I have tried increasing R4 to 11k while lowering R3 to 1-1.5k and it keeps a similar characteristic while being able to drive 10k better (with some slight increase in distortion close to clipping, but little higher order harmonics).
Title: Re: Is this even stable?
Post by: antonis on September 18, 2024, 05:16:24 AM
Quote from: fryingpan on September 17, 2024, 07:25:47 PMI know that Q3 is misbiased and that voltage swing is not optimised

So why you describe as "crap" the behavior of a heavily loaded misbiased Emitter follower..??  :icon_cool:
Title: Re: Is this even stable?
Post by: fryingpan on September 18, 2024, 06:55:34 AM
Quote from: antonis on September 18, 2024, 05:16:24 AM
Quote from: fryingpan on September 17, 2024, 07:25:47 PMI know that Q3 is misbiased and that voltage swing is not optimised

So why you describe as "crap" the behavior of a heavily loaded misbiased Emitter follower..??  :icon_cool:
Because I assume you can maintain the behaviour of the amplifying stage with a better output buffer.
Title: Re: Is this even stable?
Post by: amptramp on September 18, 2024, 07:11:30 AM
Is it time to consider an op amp output buffer?
Title: Re: Is this even stable?
Post by: fryingpan on September 18, 2024, 07:40:47 AM
I want to avoid integrated circuits altogether (it's just an exercise for me, which I will build, but of course I could do all I'm doing with, like, one chip).

Anyway I experimented with an active load to the emitter follower. Things are much better behaved.

(https://i.postimg.cc/VrFzWC0d/immagine.png) (https://postimg.cc/VrFzWC0d)

The emitter current is 1.3mA, and the current into a 10kohm load is 800uA. The voltage is about where I want it to be. If I set R11 to 24k, then emitter current is 1.7mA (I have more leeway) and the voltage is still about there (just 30mV below or so).
Title: Re: Is this even stable?
Post by: antonis on September 18, 2024, 08:02:38 AM
I presume OP wants to stay discrete & bipolar.. :icon_wink:

If so, and taking into account his contenteness at amplification stage, a stand-alone (not directly coupled) BJT buffer could fulfill his requirements..

e.g. Emitter biased at about 5.5V with Emitter resistor of 3k3 could easily drive Q2 output of about 2.8VRMS (4V amplitude) into a 10k load..

edit:
@fryinpan: I'd configure Q4 as current source (2 series diodes from Base to GND, delete R11, make R3 10k or so and R12 value set according to current taste..)
Title: Re: Is this even stable?
Post by: fryingpan on September 18, 2024, 08:13:14 AM
Quote from: antonis on September 18, 2024, 08:02:38 AMI presume OP wants to stay discrete & bipolar.. :icon_wink:

If so, and taking into account his contenteness at amplification stage, a stand-alone (not directly coupled) BJT buffer could fulfill his requirements..

e.g. Emitter biased at about 5.5V with Emitter resistor of 3k3 could easily drive Q2 output of about 2.8VRMS (4V amplitude) into a 10k load..
Yes. That's certainly an easier (and more economical) way. I was trying not to :icon_biggrin:
Title: Re: Is this even stable?
Post by: antonis on September 18, 2024, 08:20:41 AM
Quote from: fryingpan on September 18, 2024, 08:13:14 AMThat's certainly an easier (and more economical) way. I was trying not to :icon_biggrin:

Then think of my last post "edit.. :icon_wink:

edit:
@fryinpan: I'd configure Q4 as current source (2 series diodes from Base to GND, delete R11, make R3 10k or so and R12 value set according to current taste..)
Title: Re: Is this even stable?
Post by: fryingpan on September 18, 2024, 08:37:05 AM
Quote from: antonis on September 18, 2024, 08:20:41 AM
Quote from: fryingpan on September 18, 2024, 08:13:14 AMThat's certainly an easier (and more economical) way. I was trying not to :icon_biggrin:

Then think of my last post "edit.. :icon_wink:

edit:
@fryinpan: I'd configure Q4 as current source (2 series diodes from Base to GND, delete R11, make R3 10k or so and R12 value set according to current taste..)

Isn't this basically a different way to do what I did?

(And technically isn't it a current sink? Same difference, of course...).
Title: Re: Is this even stable?
Post by: antonis on September 18, 2024, 08:55:29 AM
Quote from: fryingpan on September 18, 2024, 08:37:05 AMIsn't this basically a different way to do what I did?

It's just a matter of taste.. :icon_wink:

(strictly speaking, one of the diodes (in close proximity to Q4) balances for VBE thermal variations..)
Title: Re: Is this even stable?
Post by: R.G. on September 18, 2024, 10:20:44 AM
It's probably stable because the CFP pair doesn't have enough poles in its response to oscillate on its own, and adding the emitter follower adds another pole or two, but because it's gain-bandwidth is all used on bandwidth, not gain, the follower pole is way the heck up in frequency.

This also accounts for the peak in response at very high frequencies in the sim. I would expect the peak to be out near the GBW of the 2N3904, which OnSemi says is a minimum of 300MHz. Our old rue of thumb was that the phase change from a pole starts taking effect one decade before the actual nominal pole location, so it could be starting up at 30MHz, drizzling phase shift above that.

This is only rule of thumb speculation of course, but it seems to fit the facts. It might be interesting to remove the emitter follower and run a stability gain/phase sim on the first two stages to see what they do without the follower.

Title: Re: Is this even stable?
Post by: Rob Strand on September 19, 2024, 09:10:35 PM
Quote from: R.G. on September 18, 2024, 10:20:44 AMIt's probably stable because the CFP pair doesn't have enough poles in its response to oscillate on its own, and adding the emitter follower adds another pole or two, but because it's gain-bandwidth is all used on bandwidth, not gain, the follower pole is way the heck up in frequency.

This also accounts for the peak in response at very high frequencies in the sim. I would expect the peak to be out near the GBW of the 2N3904, which OnSemi says is a minimum of 300MHz. Our old rue of thumb was that the phase change from a pole starts taking effect one decade before the actual nominal pole location, so it could be starting up at 30MHz, drizzling phase shift above that.

This is only rule of thumb speculation of course, but it seems to fit the facts. It might be interesting to remove the emitter follower and run a stability gain/phase sim on the first two stages to see what they do without the follower

There's plenty of things that eat-up the phase margin of the basic circuit a lot earlier than that.
- A big one is lead inductance of the power supply.
  Bypass caps don't always help as well as you would expect.
- Capacitive loading.
- The impedance feeding the input line.
  You don't want the circuit oscillating at some position of the volume pot.
  Even simple things like being stable with the input open and shorted.
  For the open case I don't mean capacitive coupled positive feedback, which makes things worse.
  I mean the act of opening the input changes the loop gain and phase-margin.

That's why it's a good policy to add a compensation cap.   It will ensure the amplifier
is stable under all *practical* conditions.   For a preamp on a PCB you will get away with less.

You might build a unit and it's stable on the bench but it's only stable for those conditions.
When you change the set-up it's not uncommon for it to oscillate.
Title: Re: Is this even stable?
Post by: amptramp on September 20, 2024, 07:14:26 AM
You may not be able to see oscillation if it is at RF frequencies.  It may show up as loss of headroom as the radio frequency signal riding on top of the audio reaches the headroom limits and causes the audio to appear to be compressed at voltages it should be able to pass.  I use a 10 MHz scope for audio signal tracing and even then, there may be some RF signal riding along at higher frequencies that I could miss.
Title: Re: Is this even stable?
Post by: R.G. on September 20, 2024, 11:24:33 AM
Quote from: Rob Strand link=msg=1289810 date=172679463

There's plenty of things that eat-up the phase margin of the basic circuit a lot earlier than that.
[...list...
You might build a unit and it's stable on the bench but it's only stable for those conditions.
When you change the set-up it's not uncommon for it to oscillate.


All too right. There's only so much that can be done in just the bare circuit design without also installing protective measures for the implementation outside the bare circuit itself.
I was mostly answering the question "how is this even stable?" It's stable because the frequency response of the output follower is way out there.

I recognize in this circuit the same basic structure/architecture as early power amplifiers. The input transistor serves as a differential transconductance amp, with the base being the noninverting input and the emitter being the inverting input. It's collector modulates a current input into the base of the PNP voltage gain stage, which provides all of the voltage gain for the circuit. The follower provides a high impedance input (as modified by the feedback networks in this case) to keep the voltage gain up, and the follower buffers the voltage gain stage. What's different about this as compared to real power amps is that the output follower in real amps do not have nearly the wide bandwidth that a single high frequency NPN does, so they add in a much lower pole.

A dominant pole compensation cap from collector to base on the PNP would cut the gain out at the highest pole very easily on this particular circuit, and is an almost exact analog of the compensation cap on most power amps; I completely agree with your note
QuoteIt's generally a good idea to have the option to add a cb capacitor on Q2
to help stability. 
If I were doing this, that's where I'd put it.
And yes, filtering the input is a good idea. Wide bandwidth circuits fed with anything from DC to daylight get into trouble easily.
@amptramp:
QuoteYou may not be able to see oscillation if it is at RF frequencies.  [...] I use a 10 MHz scope for audio signal tracing and even then, there may be some RF signal riding along at higher frequencies that I could miss.
Too right!!