15

I'm trying to build a unity-gain push-pull output stage to drive a small ~8 Ω speaker (measured DC resistance is 7 Ω; I don't have a datasheet for it).

This is for use with a single rail battery supply, so for the op-amp I've chosen an LM324. For the transistors I've used BD139 and BD140. Input and output are both AC-coupled.

I simulated it in LTspice and all was good using a 7 Ω resistor to represent the speaker with an input of 2 kHz, 300 mV pk-pk.

Then I built the circuit for real, replacing R1 with a real speaker.

When driving Vin with 2 kHz, 300 mV pk-pk, the amplitude of the output at Vout is as expected, but looking at the signal across the speaker I see two problems:

  1. A "nick" in the output which I think is the residual crossover distortion, which I was hoping the feedback would have managed better.
  2. More strange (to me) is the distortion 'blob' in the bottom of the cycle. Zooming in it looks like ringing superimposed on the output. I estimated its just over 800 kHz. I'm guessing it has something to do with the inductance of the speaker, but why not in the positive cycle as well?

Neither of these distortions are audible and the speaker works OK, I hear the 2 kHz tone fine, but then the speaker would not reproduce this high frequency anyway - so it's effectively filtered out.

Being a bit of a perfectionist I'd really like to understand what is happening and ideally how to fix it. I tried a 1 µF cap across the speaker which helped, but still the -ve cycle is distorted whilst the +ve cycle is fine.

Schematic and scope traces are below. Green is thecinput taken at Vin on the schematic, magenta is across the speaker taken at Vout on the schematic.

Any help and suggestions much appreciated.

Schematic (R1 is replaced with a real speaker): Schematic

The distortions (crossover and 'blob'): The blob distortion

Adding a 1 µF capacitor across the speaker: better, but still not great: With 1uF

Finally, no speaker (or the 1 µF cap), just a plain 10 Ω resistor: enter image description here

UPDATE: The latest schematic is as below. This incorporates both solutions offered (resistor R5), and a frequency-compensated feedback (R6 & C3). Experimenting, the feedback compensation alone did not solve it, but adding the R5 did - when connected to the speaker. But when I replace the speaker with a dummy 10 Ω resistor the oscillation comes back. Traces are below: green is the input, magenta is the output at the load.

I guess I have it 'working' into the speaker, but as this is a learning exercise for me I don't feel I have really understood what is happening.

Latest schematic: Latest schematic

Into speaker load: into speaker

Into dummy resistor load: into resistor

ocrdu
  • 8,705
  • 21
  • 30
  • 42
mountainmad
  • 277
  • 8
  • Please provide the actual part number and values for all the components you are using. If you are using LTspice, run a simulation to see if you get a similar effect. It may help to add a resistor of a couple hundred ohms between the bases and emitters of your power stage. Also make sure you have bypass capacitors on the power supply, and maybe add some ESR to the output capacitor, and maybe a 10k resistor in the feedback. – PStechPaul Dec 14 '22 at 00:04
  • 2
    Well, you can sure see the cross-over distortion notches! You may need to add a little bias in such a way that the emitter currents in the BJTs more gradually turn on and off. Don't know what opamp you are using but it may not have sufficient output drive. Is it an ideal opamp? And you may need to deal with any realistic opamp with more parts than I see. – jonk Dec 14 '22 at 00:05
  • 2
    There's no supply bypass caps in the schematic. Do you have them in your real circuit? Also the scope is set to AC coupling, it makes it more difficult to see where the problem is. The DC bias is important as that's approximately the second oldest op-amp type that exists, so the input and output don't work well near supply voltages. The input might go near ground but certainly not near positive supply. – Justme Dec 14 '22 at 00:34
  • You will find it educational to put a scope probe on point "C" and look at it with respect to the output voltage -- especially as it pertains to the crossover distortion. – TimWescott Dec 14 '22 at 02:09
  • 1
    the "blob" isn't ringing--it's oscillation. Different things. Oscillation is caused by a poorly tuned feedback network; ringing can happen in the absence of feedback. – Hearth Dec 14 '22 at 05:25
  • mountain, You will want something [closer to this](https://i.stack.imgur.com/mDlE5.png). The voltage gain is about 3.8, or so. But this is easy to adjust by playing with \$R_{19}\$, for example. Anyway, you need to make a few adjustments. Things aren't quite so easy. – jonk Dec 14 '22 at 06:32
  • mountain, Why not just use a bridge-tied [TDA8551](https://www.nxp.com/docs/en/data-sheet/TDA8551_T.pdf)? Cheap. Common. But Vcc-limited to under 5.5 V. Or [TDA8541](https://www.nxp.com/docs/en/data-sheet/TDA8541.pdf) which has a much wider Vcc range but must use a gain of 2 or more. They are nice and save lots of trouble designing and are cheaper and smaller than going discrete. – jonk Dec 14 '22 at 23:43
  • Thanks jonk, I'm using it as a learning experience so would rather not got for an all in one package, though on the flip side I'm happy to use opamps rather than go for full discreet which would be too much of a leap for me with my current knowledge and experience. – mountainmad Dec 15 '22 at 09:01
  • The lousy old LM324 quad and LM358 dual opamps are NEVER used for audio because they are noisy, have a limited high frequency output due to a poor slew rate and They Produce Crossover Distortion. – Audioguru Dec 21 '22 at 23:59
  • @Audioguru thanks for the tip. I guess you're saying I should give up on the LM324. Any recommendations? - Project is audio up to ultrasonic (100kHz), battery powered at 9V, so single supply rail to rail. – mountainmad Dec 22 '22 at 10:39
  • 1
    I have used audio opamps that are low noise, are very low distortion and with an output to 100kHz. But they are not rail to rail. Powered from a 9V battery that drops to 6V during its life, an ordinary audio opamp produces plenty of output level without being rail to rail. Any opamp can use a single supply if it is biased near half the supply voltage and has coupling capacitors. – Audioguru Dec 23 '22 at 16:17

2 Answers2

18

That's oscillation due to improper compensation of the feedback loop. Your circuit is likely going to get damaged by it if you let that continue for too long.

You can fix it by inserting a compensation network, like in this partial schematic:

schematic

simulate this circuit – Schematic created using CircuitLab

The cross-over frequency of the RC compensation network is about 150kHz. Above that frequency, feedback to the OpAmp comes directly from its output (via the capacitor) and not from the slow output transistors anymore. You might have to play with the value of C1 a bit, 1nF is just an educated guess. (In particular, if the oscillations don't go away, make C1 bigger, up to a maximum of 4.7nF.)

The reason why the circuit only oscillates during the negative portion of the output signal is that while the output is negative, only the PNP transistor conducts. (Vice-versa, when the output is positive, the NPN transistor is active.) Bipolar PNP transistors (especially power types) are slower than their NPN counterparts, often by a factor of two, and also have much greater parasitic capacitance. This means that the PNP introduces more phase shift and therefore makes it more likely for the circuit to become unstable when it's active. Since your circuit seems to be just barely unstable, it's not unexpected that it only oscillates during the negative portion of the signal when the slower PNP transistor is active.

Note that the crossover distortion will of course still be terrible (it will in fact be worse after fixing the oscillation due to the reduced slew rate). You might want to look into class-AB output stages.

Also, don't connect any capacitors from the output of your amp to ground. (Series caps are ok.)

Jonathan S.
  • 14,865
  • 28
  • 50
  • 6
    A resistor from the transistor bases to the junction of C1 and the op-amp output may also help, to isolate the op-amp output from the base capacitance. You want it sized with respect to the op-amp's open loop output impedance -- so, probably 500 to 1000 ohms for the LM324. – TimWescott Dec 14 '22 at 02:12
  • 1
    Do you know why the oscillations only occur in the negative half cycle? – Math Keeps Me Busy Dec 14 '22 at 03:19
  • 2
    @MathKeepsMeBusy PNP transistors are slower and have more parasitic capacitance than their NPN counterparts, which means that phase margin is lower during the negative half-cycle. OP's amp seems to just barely be on the edge of instability. In any case, a proper class-AB output stage would be much better. – Jonathan S. Dec 14 '22 at 07:49
  • The presented solution for the oscillation will likely make the crossover distortion worse as it cuts away feedback bandwidth for the opamp. A quick fix might thus be to use a much "drivier" opamp with higher GBW and phase margin. But the permanent solution to address both issues is to make a Class AB or Class D output stage. – tobalt Dec 14 '22 at 07:50
  • 2
    @JonathanS. That makes sense. Would you care to add that to your answer? That issue was bugging me, and I'm sure others would appreciate that insight, and might miss it if they don't read the comments. – Math Keeps Me Busy Dec 14 '22 at 11:33
  • @JonathanS. I'm still struggling with this problem. Initially just putting the resistor between transistor base and emitter sorted it when driving the speaker. But replacing the speaker with a 10ohm resistor and the oscillation is back again, so as you said it seems my circuit is on the edge of stability. I tried the solution you suggested with the feedback network which made a lot of sense, but to no avail. Any other ideas or suggestions? – mountainmad Dec 20 '22 at 23:12
  • You can combine the two solutions, too. If that still doesn't make it stable, it's possible that the physical implementation of the circuit has issues. It'd be ideal if you could post pictures of it. Do you have bypass capacitors on the supply voltages? How long are the connections? – Jonathan S. Dec 20 '22 at 23:21
  • @JonathanS. I've updated the question at the end with latest schematic and traces with speaker or resistor as load. I added supply bypass caps 0.1u. I can't help thinking that it has something to do with it being a single supply, so in the negative cycle the speaker is effectively driven by the decoupling capacitor discharging (I think this is right?). Physically it is built on one of the white breadboards. I've kept links short as I can. In one sense its solved as it works with the speaker, but being new to electronics and trying to learn I don't feel I've understood what is really going on. – mountainmad Dec 21 '22 at 21:04
11

While the output of the op-amp is between -0.65 V and +0.65 V the transistors are turned off so the overall open-loop gain is reduced to a small value making feedback ineffective. Placing a resistor as shown will allow current to bypass the base-emitter reducing the impact on the open loop gain allowing feedback to reduce the distortion. The lower limit for the resistance is based on the op-amps drive capability. It is not perfect. If quality of sound is required, then a proper class AB stage is required.

schematic

simulate this circuit – Schematic created using CircuitLab

RussellH
  • 12,496
  • 2
  • 9
  • 34
  • Adding a 100 ohm resistor as suggested solved the oscillations in the negative cycle, still a bit of cross over but to solve that it seems I need to look at class AB. I'll edit question to include the scope trace. – mountainmad Dec 15 '22 at 20:49