Saturday, December 26, 2020

Audio Amplifier Feedback - Dominant Pole ("Miller") Compensation

This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

In the last post, I tried to compensate a typical three stage audio power amplifier by raising its gain from the original 20dB to 70dB. It worked, but an audio power amplifier with a gain of 3,000 clearly is not a practical solution.

A better way to compensate is to add a small "Miller" capacitor between the output and the input of the second stage of the amplifier:


With the compensation capacitor, the open loop gain (red line) uniformly falls at 20dB/decade and meets the desired closed loop gain of 20dB (blue line) at 800kHz, the new intercept frequency. The phase lag at that frequency is now 100 degrees, which gives us $180 - 100 = 80$ degrees of phase margin - the amplifier is stable.

The compensation capacitor plays several important roles in this elegant and efficient compensation scheme:

    1. It reduces the output impedance of the second stage of the amplifier, thus moving to a higher frequency the pole (that is, gain roll-off and phase shift) that that impedance creates together with the input capacitance of the last (output) stage;
    2. It reduces the input impedance of the second stage, so that the voltage at the collectors of the input stage transistors does not change as much with the signal, reducing the effect of parasitic capacitances and making the input stage more linear;
    3. It makes the loop gain fall below unity before the other poles introduce too much phase shift.

    All three effects are achieved by enclosing the second stage of the amplifier in a local feedback loop formed by the compensation capacitor:

    It looks like, and it is, an I/V converter - a transimpedance stage which inputs current and outputs voltage. (Never ever call it a Voltage Amplification Stage, or VAS.)

    The input current is provided by the first stage (a differential pair), and for small signals the current is proportional to the differential input voltage: $$i=v_{diff} \times g_m$$ where $v_{diff}$ is the difference between the input signal and the portion of the output signal supplied by the feedback network, and $g_m$ is the transconductance of the differential pair, which is determined by the tail current $I_{tail}$ and the emitter degeneration resistors $R_e$ of the differential pair:

    $$g_m \approx {1 \over {r_e + R_e}} = {1 \over {{V_T \over I_c} + R_e}} \approx {1 \over {{2 V_T \over I_{tail}} + R_e}}, V_T \approx 26mV$$

    In the schematic above $I_{tail} = 1mA, R_e = R_5 = R_6 = 470 ohm$, so $g_m=1.9{mA \over V}$. (Note that without the current mirror, the transconductance $g_m$ would be half of that.)

    If we ignore the input current of the second stage, then the output current of the differential pair $i=v_{diff} \times g_m$ flows through the compensation capacitor, and the resulting voltage drop becomes the output voltage of the second stage. It depends on the capacitor's impedance $Z_c={1 \over {2 \pi f C}}$: $$v_{out}={i \times Z_c}={i \over {2 \pi f C}}={v_{diff} \times g_m \over {2 \pi f C}}$$ Since the output stage of our amplifier is an emitter follower with approximately unity gain, the output voltage of the second stage becomes the output voltage of the whole amplifier. The open loop gain of the whole amplifier is then: $$A_{OL}={v_{out} \over v_{diff}}={g_m \over {2 \pi f C}}$$ This is a remarkable result. By choosing the parameters of the input differential pair (and thus its transconductance $g_m$) and the compensation capacitor $C$, we completely define the gain of the whole amplifier.

    The open loop gain is inversely proportional to frequency (hence the straight red line in the log-log Bode plot above), and their product (gain-bandwidth product or $GBW$) is a constant: $$GBW={A_{OL} \times f}={g_m \over {2 \pi C}}$$ If we want a closed loop gain ${1 \over B} = {A_{CL}}$ from this amplifier, the zero-dB-loop-gain (intercept) frequency becomes $$f_0={GBW \over A_{CL}}={g_m \over {2 \pi C A_{CL}}}$$ In the case of the schematic above, $A_{CL}=10$, giving the intercept frequency of $f_0=916kHz$ (to match the 800kHz from the simulation, we need to add a couple picofarads of parasitic capacitance to the nominal value of the compensation capacitor).

    The ratio (=difference in dB) between the open loop gain and the closed loop gain becomes the loop gain: $$LG={A_{OL} \over A_{CL}}={g_m \over {2 \pi f C A_{CL}}}$$

    The design procedure for this type of compensation should ideally be based on the $f_0$ required to ensure stability, but this is usually not known. Instead, the design starts from the desired loop gain at the top of the audio band (20kHz), and the stability of the amplifier is confirmed experimentally. For example, if you want $LG=30dB$ of loop gain at $f=20kHz$ in the above amplifier with closed loop gain $A_{CL}=10$, you calculate $$C={g_m \over {2 \pi f A_{CL}LG}} \approx 50pF$$Part of the capacitance will be strays and parasitics, so the actual compensation capacitor should be a bit lower, say 47pF or 33pF.

    In this post, I covered the benefits of Miller compensation, but it comes with some costs, such as the decreased loop gain and the interdependence of the loop gain and the amplifier's bandwidth. These will be covered in future posts.

    Saturday, December 19, 2020

    Audio Amplifier Feedback - A Realistic Power Amplifier and its Phase Margin

    This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

    In the last post on this topic, I mentioned that any real amplifier has multiple poles, which cause phase lag at the amplifier's output. The lag increases with frequency, and it affects the behavior of the amplifier placed in a feedback loop. As the phase shift at the intercept frequency (where the amplifier's open loop gain equals to the closed loop gain, and thus the loop gain is unity) approaches 180 degrees, the signal at the output of the starts exhibiting overshoot and ringing:


    If the phase lag at the intercept frequency reaches 180 degrees , the amplifier becomes unstable - this is called the Barkhausen stability criterion. 

    The difference between 180 degrees and the actual phase lag at that frequency is called the phase margin and is an indicator of how close the amplifier to instability. A practical requirement is to have at least 30 degrees of phase margin - that is, the phase lag at $180 - 30 = 150$ degrees or less - at the frequencies where the loop gain is between 10db and -10dB.

    Let me look at a realistic example of a conventional three-stage audio power amplifier with the desired closed loop gain of 10 (=20dB):


    It has multiple poles, and at the crossover 0dB frequency (about 6MHz), when its open-loon gain (green line) reaches the desired closed-loop gain set by the feedback network (blue line), the phase at the output lags that at the input by over 240 degrees, indicating the negative phase margin of about -60 degrees:


    With a negative phase margin, the amplifier is unstable and will oscillate:

    To make it stable, one needs to compensate it - to make somehow the phase lag at the intercept frequency less than 180 degrees. The simplest way is to increase the closed loop gain by modifying the feedback network. If we, for example, set the closed loop gain at 3,000 (or 70dB), the intercept frequency moves from 6MHz to 300kHz, and the gain margin becomes positive 50 degrees, making the amplifier stable:
    The problem with this approach is, of course, that no one needs an audio power amplifier with the gain of 3,000. 

    Thankfully, there are more practical ways to compensate this amplifier, and I will look at them in the next posts.

    Sunday, December 13, 2020

    Velleman K4040, take three

    This is the last of three posts on Velleman K4040. Here are the links to the first and second posts.

    Over 10 years ago, I built a Velleman K4040 power amplifier from an (expensive) kit. The amplifier still looks quite impressive:

    Not satisfied with the out-of-the-box performance, I modified the amplifier (see my previous post for details). The result was a dramatic improvement in sound. However, without its global feedback, the amplifier had higher measured distortion, higher input sensitivity and more hum.

    Ten years later, I (slightly) revised the amplifier. I replaced the resistors in the signal path with mil-spec metal film from Vishay, tidied up the wiring of the phase splitter and added a global feedback loop that encloses the input stage. With it, the amplifier has 0.015% distortion at 1W (that is, one-sixth of its original specification), the hum is much reduced, and the input sensitivity is in line with the output voltage of today's signal sources.

    The final schematic:

    Measurement results compare well to those of tube power amplifiers made by major brands and priced at up to $10,000, as measured by Stereophile. The modified Vellemn K4040 offers respectable measured performance typical of a classic tube design.


    More photos (click for higher resolution):

















    Saturday, December 12, 2020

    Audio Amplifier Feedback - Amplifier with Multiple Poles Inside Feedback Loop


    This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

    In the last post, I mentioned that any real amplifier's gain sooner or later goes down as the frequency goes up. As the gain declines, the phase at the output starts lagging that at the input (the amplifier has a pole):

    Declining gain and lagging phase as the frequency grows are the characteristics of a low-pass filter:

    Screen Shot 2020-11-20 at 3.00.05 PM.png

    With some simplification, one can say that every capacitance in a circuit can form a low pass filter and can create a pole. Even in a very simple circuit, there are many capacitances, intended and parasitic:
    so there are many poles.
    Let's say an amplifier has three poles, at 2kHz, 1MHz and 20MHz, and is placed inside a feedback loop with B=-1/10 (say a resistive divider made of a 9kOhm and a 1kOhm resistors from the output of the amplifier to its inverting input):
    The Bode plot of the amplifier's open loop gain and the ideal closed loop gain:

    If we apply a square wave to the input of such an amplifier, at the output we will observe the following:

    which is not what was intended. The signal transfer function has a pronounced peak and is not the flat 20dB line that the feedback network demands:

    Turns out that at about 4.5MHz, where the open goop gain $Aol$ approaches $1/B$and the loop gain $Aol \times B$ approaches unity, the amplifier's multiple poles together create a phase lag of almost 180 degrees. Together with the 180 degrees created by applying the feedback to the inverting input, the phase shift is close to zero at the point where the loop gain is unity. As a result, the signal transfer function $STF={LG \over {1 - LG}}{1 \over B}$ and the error transfer function $ETF={1 \over {1 - LG}}$ can become very large, leading to instability.
    To avoid instability and make $STF$ and $ETF$ what they should be, the amplifier needs to be compensated, which will be the topic of my future posts.

    Saturday, December 5, 2020

    Audio Amplifier Feedback - Amp with Frequency Dependent Gain

    This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

    In the last posts, I looked at the feedback theory basics and at how it applies to an opamp in both inverting and non-inverting configuration.

    No amplifier can have a constant gain over an infinite bandwidth, as that would require infinite power. Any real amplifier's gain sooner or later goes down as the frequency goes up. For example, for most opamps designed in the past 50 years, their open loop gain (that without any feedback applied) starts going down at 100Hz or less:

    The open loop gain Aol keeps going all the way down to unity (0dB) at a rate 20 dB/decade. At the same time, the phase (dashed line) at the output starts lagging that at the input (the opamp has a pole):

    Eventually, the lag reaches (almost) 90 degrees. (Should there be more poles, each would add its own 20 dB/decade decline to the gain and up to 90 degrees phase shift. For now, I am going to look at just one pole.)

    If such an opamp is connected to a feedback network (a resistor voltage divider) with gain 1/10:

    setting the closed loop gain Acl=1/B at x10, or 20 dB, the error transfer function ETF and signal transfer function STF become frequency dependent:

    At low frequencies, the magnitude of STF is 20dB, and the phase is constant - feedback stabilizes the gain of the opamp. The magnitude of ETF is -80dB (in this example), that is, any distortion that the opamp may generate will be reduced by a factor of 10,000. As frequency goes up, however, the open-loop gain Acl falls, and ETF grows. At 20kHz, ETF is only -27dB, so the distortion is reduced by only 20 times.

    Loop gain LG is the product of open loop gain Acl and feedback network gain B, which is the same at the ratio of Acl and 1/B and, on the log plot, is simply the vertical distance between Acl and 1/B curves. The point where Acl meets 1/B is the crossover point - the loop gain become unity (0 dB), and feedback ceases to stabilize the STF and correct any distortion:


    For large loop gains, ETF is approximately equal to loop gain, so commonly, it is the loop gain and not the ETF that is considered the measure of feedback's power to correct distortion. The more loop gain, the more distortion is reduced by feedback.

    Loop gain falling with frequency shifts the spectrum of uncorrected distortion to higher frequencies, which creates a peculiar sonic signature - the bass, largely unaffected by distortion, become incredibly powerful and "tight", which is frequently attributed to the low damping factor or massive power supply of the audio amplifier.

    There is an opinion, not scientific but useful, that, in case an amplifier has insufficient loop gain to correct distortion, it is sonically better to have loop gain, and thus distortion, approximately equal across audio range of frequencies, rather than allow loop gain to fall, and distortion to grow, with frequency as above.

    Next week, I will look into what happens when the amplifier has multiple poles.

    Friday, November 27, 2020

    Audio Amplifier Feedback - Inverting and Differential OpAmp

    This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

    Last week, I examined how the basic feedback theory applies to a non-inverting opamp. 

    Let's look at the other common way of connecting an opamp - the inverting amplifier:

    In the diagram:
    • $A$ is the gain of the amplifier with no feedback applied (its open loop gain)
    • $x$ is the input signal
    • $y$ is the output signal
    The feedback network consists of two resistors $R_1$ and $R_2$. The gain $B$ of the feedback network is that of a voltage divider: $$B=-{R_1 \over R_1+R_2}$$The minus sign here accounts for the fact that the feedback is applied to the inverting input of the opamp. This is the same as in the non-inverting configuration.

    Unlike in the non-inverting configuration, the input signal arrives at the amplifier's input via a divider consisting of the same resistors $R_1$ and $R_2$. Effectively, the inverting configuration is a superposition of two circuits, one for feedback:
    and one for the input signal:


    The gain of the input divider is: $$-{R_2 \over R_1+R_2}$$As before, the minus sign here accounts for the fact that the attenuated input signal is applied to the inverting input of the opamp.

    Now we can write down the Signal Transfer Function, the Error Transfer Function and the Loop Gain:
    $$STF=-{A*{R_2 \over R_1+R_2} \over (1+A*{R_1 \over R_1+R_2})}$$
    $$ETF={1 \over (1-A*B)}={1 \over (1+A*{R_1 \over R_1+R_2})}$$
    $$LG=A*B=A*{R_1 \over R_1+R_2}$$
    As $A$ (and hence $LG$) increases, $STF$ approaches the familiar $-{R_2 \over R_1}$.
     
    The differential connection with R1=R3 and R2=R4 has the same STF and ETF as the inverting:


    Friday, November 20, 2020

    Audio Amplifier Feedback - Non-Inverting OpAmp

    This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

    Let us see how the feedback theory from my last week's post applies for a opamp in a typical non-inverting configuration:

    In the diagram:
    • $A$ is the gain of the amplifier with no feedback applied (its open loop gain)
    • $x$ is the input signal
    • $y$ is the output signal
    The feedback network consists of two resistors $R_1$ and $R_2$. The gain $B$ of the feedback network is that of a voltage divider: $$B=-{R_1 \over R_1+R_2}$$The minus sign here accounts for the fact that the feedback is applied to the inverting input of the opamp.

    Using the formulas from last week's post:
    $$STF={A \over (1-A*B)}={A \over (1+A*{R_1 \over R_1+R_2})}$$
    $$ETF={1 \over (1-A*B)}={1 \over (1+A*{R_1 \over R_1+R_2})}$$
    $$LG=A*B=A*{R_1 \over R_1+R_2}$$
    As $A$ (and hence $LG$) increases, $STF$ approaches the familiar ${R_1+R_2 \over R_1}=1+{R_2 \over R_1}$.

    One special case here is an opamp connected as a unity gain buffer:

    This is equivalent to the general non-inverting connection with $R_1$ open and $R_2$ shorted. In this case, $B=-1$ and 
    $$STF={A \over (1-A*B)}={A \over (1+A)}$$
    $$ETF={1 \over (1-A*B)}={1 \over (1+A)}$$
    $$LG=A*B=A$$
    $LG$ equals $A$ - in this configuration, all available open loop gain is applied to reduce the output error. As $A$ increases, $STF$ approaches unity.

    In the next post, I will look at the opamp in the inverting configuration.

    Friday, November 13, 2020

    Audio Amplifier Feedback - Basics

    This post is a part of the series on audio amplifier feedback. The contents of the series can be found here.

    To make sure everyone is on the same page, here is a super simplified feedback loop that can be found in an audio amplifier:

    In the diagram:
    • $A$ is the gain of the amplifier with no feedback applied (its open loop gain)
    • $B$ is the gain of the feedback network (typically, the feedback network attenuates the signal, so $|B|<1$) 
    • $x$ is the input signal
    • $\epsilon$ is the error (noise, distortion) that the amplifier adds to the signal
    • $y$ is the resulting output signal
    That is, the amplifier receives the input signal $x$, amplifies it by $A$, adds some noise and distortion $\epsilon$, resulting in the output signal $y$. A portion $B$ of the output signal $y$ is fed back to the input by adding it to the input signal (hence 'feedback').

    Working from the right side of the diagram to the left, we can write:
    $$y=\epsilon+A(x+y*B)$$
    Solving for $y$:
    $$y={A \over (1-A*B)}*x+{1 \over (1-A*B)}*\epsilon$$
    The output signal $y$ has two components:
    • Input signal $x$ amplified by ${A \over (1-A*B)}$
    • Distortion $\epsilon$ amplified by ${1 \over (1-A*B)}$
    Let us call the input signal amplification factor ${A \over (1-A*B)}$ the Signal Transfer Function, or $STF$, and distortion amplification factor ${1 \over (1-A*B)}$, the Error Transfer Function, or $ETF$:
    $$STF={A \over (1-A*B)}$$ $$ETF={1 \over (1-A*B)}$$
    The promise of feedback is that, as the open loop gain $A$ increases, the $ETF$ approaches zero, while the $STF$ approaches $-{1 \over B}$. In other words, the contribution of noise and distortion in the output signal becomes small, and the closed loop gain of the amplifier becomes independent of the amplifier's open loop gain $A$.

    The sum of the input signal $x$ and the feedback $y*B$ that the amplifier sees at its input is normally small and gets smaller as $A$ increases: $$x+y*B={1 \over (1-A*B)}*x+{B \over (1-A*B)}*\epsilon$$
    The quantity $A*B$ is called loop gain, and is the correct term for the "amount of feedback". We can rewrite $STF$ and $ETF$ with the loop gain $LG$:
    $$STF={LG \over (1-LG)}*{1 \over B}$$ $$ETF={1 \over (1-LG)}$$
    In the next post, I will show how the above math applies to an opamp.

    Friday, November 6, 2020

    Audio Amplifier Feedback - Introduction and Contents

    An apple was laying in the grass, a good apple with just a small rotten spot. The teacher picked it up and said: "There are two options. One can eat the apple as is, right away. Or one can take a knife, cut out the rot, and eat then. It would take some work, but the apple without the bad spot will be more enjoyable, and you would probably have more of it, as you won't need to avoid the rotten part. These are two different takes on anything you do." He took a knife, cut out the rotten spot and started eating. "Will you share with us?" - "No," he joked, "so that you remember".

    This is the first post in a series of posts on audio amplifier feedback, written in the spirit of that parable. The focus of the series will be on the common feedback networks in audio power amplifiers and their effect on distortion and stability, with simulations and some formulas.

    The contents of the series:

    1. Feedback Basics (definitions, etc.)
    2. Feedback in a Non-Inverting Amplifier
    3. Feedback in Inverting and Differential Amplifiers
    4. Feedback in an Amplifier with Frequency Dependent Gain
    5. Feedback with Multiple Poles Inside Feedback Loop
    6. A Realistic Power Amplifier and its Phase Margin
    7. Dominant Pole (Miller) Compensation
    8. Limitations of Dominant Pole Compensation
    9. Nested Feedback Loops
    10. Input Stage Linearity
    11. Transient Intermodulation Distortion (TIM)
    12. Two-Pole Compensation
    13. NCore style compensation
    14. LTP with Frequency Dependent Load
    15. LTP with LR compensation
    16. Lead Compensation
    17. Rate-of-Closure (ROC)
    18. Lag Compensation
    19. Lead-Lag Compensation
    20. Estimating Poles in Lead-Lag Compensation Scheme
    21. Hawksford's Error Correction (H.ec)
    22. Hawksford's Error Correction and "Distortion Selector"
    23. High Precision Composite Op-Amps, Part 1
    24. High Precision Composite Op-Amps, Part 2  
    25. High Precision Composite Op-Amps, Part 3
    26. High Precision Composite Op-Amps, Part 4 
    27. High Precision Composite Op-Amps, Part 5
    28. Bootstrapped Collector Loads
    29. Current Dumping Revisited 


    Friday, May 1, 2020

    Aikido Cathode Follower Preamplifier

    After all that work removing hum from the Aikido ACF-2 board (see the previous post), it would be a shame not to make a complete preamplifier with it, and this is what I did.

    The enclosure is from Modushop with front and rear panels custom made and engraved by Front Panel Express.

    The rear panel has three pairs of gold plated RCA input connectors and two pairs of outputs (connected in parallel), plus an AC power inlet.
    Inside, besides the ACF-2 board, are a toroidal power transformer, an output muting board from Pete Millett, a volume control, and and input switch. The input switch is mounted in the rear and is connected by a shaft extender to the front panel knob. All connections are made by teflon insulated, sliver plated copper wire.
    The front panel has a sub-panel holding the volume control potentiometer (ALPS RK27) and the bearing for the extended switch shaft. The sub-panel allows hiding the bottoms of the knobs inside the front panel for a more professional look.
    The tubes are E88CC.