15
\$\begingroup\$

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

\$\endgroup\$
11
  • \$\begingroup\$ 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. \$\endgroup\$
    – PStechPaul
    Dec 14, 2022 at 0:04
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – jonk
    Dec 14, 2022 at 0:05
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – Justme
    Dec 14, 2022 at 0:34
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Hearth
    Dec 14, 2022 at 5:25
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Audioguru
    Dec 23, 2022 at 16:17

2 Answers 2

11
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\begingroup\$ 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. \$\endgroup\$ Dec 15, 2022 at 20:49
18
\$\begingroup\$

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.)

\$\endgroup\$
8
  • 6
    \$\begingroup\$ 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. \$\endgroup\$
    – TimWescott
    Dec 14, 2022 at 2:12
  • 1
    \$\begingroup\$ Do you know why the oscillations only occur in the negative half cycle? \$\endgroup\$ Dec 14, 2022 at 3:19
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ Dec 14, 2022 at 7:49
  • \$\begingroup\$ 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. \$\endgroup\$
    – tobalt
    Dec 14, 2022 at 7:50
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ Dec 14, 2022 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.