0
\$\begingroup\$

I have an 8 Ω speaker and a Raspberry Pi. To play sound, I can connect the Raspi directly to the speaker, which works, but with very limited volume. I assume this is because of the 3.3 V PWM output by the Raspi which provides up to 20 mA (correct me if I'm wrong).

I therefore decided to test an LM358 OpAmp, which essentially is a voltage multiplier when it operates in closed-loop gain. The Raspi signal is 3.3 V already, so with a 5 V power supply I can at most go to 5 V, corresponding to Vout/Vin = 1/β = 1.5 (therefore R1 = 1 kΩ and R2 = 2 kΩ).

As the LM358 can provide around 20 mA as well, I would expect the loudspeaker to be slightly louder as it is driven with 5 V instead of 3.3 V, and P = U · I.

The result is that the loudspeaker is indeed a bit louder, but mostly quite distorted and noisy. So not the expected output.

schematic

simulate this circuit – Schematic created using CircuitLab

Why do I get such bad output audio? Shouldn’t the OpAmp just do a linear transformation of the signal?

(I probably lack some basic understanding of how OpAmps and speakers are supposed to be used. If so, I’d be happy to get some hints or references to read.)

Edit – WPM measurements

Since knowing the input is important to this question, here some measurements – the first one shows the normal audio waveform, the second one is recorded at higher frequency which shows how the Raspi constructs the waveform. The signal is ± 1 V in these measurements.

I have also found this paper about biasing which provided a nice explanation of scaling and biasing.

Raspi output in PicoScope

Closer look at the waveform

\$\endgroup\$
6
  • 1
    \$\begingroup\$ What is WPM in your title? Tip: when using the CircuitLab button on the editor toolbar the editable schematic gets saved inline with your post. No need for screengrab, file upload or background grid. We can also copy and edit in our answers. \$\endgroup\$
    – Transistor
    Commented Nov 21, 2018 at 15:23
  • 4
    \$\begingroup\$ The LM358 is an opamp and not designed to drive an 8 ohm speaker. It could drive a 600 ohm headphone though. To drive an 8 ohm speaker, use an audio power amplifier like the LM386. Shouldn’t the OpAmp just do a linear transformation of the signal? Yes but you have to understand the LM358's limits, which you violate by connecting an 8 ohm load to ground. Also you biased the input to 0 V DC which simply cannot work with a single 5 V supply. \$\endgroup\$ Commented Nov 21, 2018 at 15:45
  • 1
    \$\begingroup\$ PWM audio depends on the speaker filtering out the square waves. If you put more power behind the square wave, you just get more distortion. You need to filter out the square waves first, then amplify the audio using an amplifier meant to drive a speaker. Class D amplifiers get away with driving the speaker directly because they use other means to filter out the square wave. \$\endgroup\$
    – JRE
    Commented Nov 21, 2018 at 18:22
  • \$\begingroup\$ @Transistor Pulse-width modulation – I have made some measurements to better see what it looks like, screenshots added in the question. Thanks for the hint, I previously failed at the registration process with pay-to-use. Added the inline circuit. \$\endgroup\$ Commented Nov 22, 2018 at 10:15
  • \$\begingroup\$ @Bimpelrekkie Can I simply calculate the current as usual with I = U / R, and with 600 Ω headphones and 15 V I would get a 25 mA current which the LM358 is designed for, but the 8 Ω speaker would require 200 mA? – Biasing: The OpAmp’s Ground? Is the issue that (+) is on ± 1 V and (−) is on 0…x V which breaks the subtraction in the OpAmp? \$\endgroup\$ Commented Nov 22, 2018 at 10:39

1 Answer 1

2
\$\begingroup\$

Ah, specmanship! Look closely at the LM358 data sheet section:

enter image description here

The manufacturer gets to the "typical" 20 ma sink current when there is a one-volt difference between Vin+ and Vin- (not usually typical for an op amp), and with a 15-volt supply. The sink current values are different at different voltages, dropping down to microamps as you approach the rail. So the signal will be badly distorted. The fact that you can recognize the sounds coming out is a testament to the effectiveness of the human brain and ear.

What you need is a push-pull driver circuit that goes all the way to both rails. If you don't want to build one from discrete components, you might try a gate driver.

\$\endgroup\$
2
  • \$\begingroup\$ This is what “Figure 11. Output Characteristics Current Sinking” describes? So this OpAmp is not suitable for audio amplification because output current is too low in general and also not linear especially for lower voltages. This would probably cause the waveform to stick to the maximum amplitude values and hence cause the distortion? Would the push-pull driver go behind the OpAmp and amplify the current linearly? \$\endgroup\$ Commented Dec 2, 2018 at 14:04
  • 1
    \$\begingroup\$ The Raspberry Pi output is PWM which is essentially still a digital signal. To accurately replicate the intended output, you will want the output of your driver to go from rail to rail, so that the average voltage is halfway between when the audio signal passes through zero. This will be a 50% duty cycle and the positive and negative peaks will approach 0% and 100% duty cycle. You are then using the capacitor to level shift this signal so that it swings around zero and the inductance of the speaker blocks the high (PWM) frequency, leaving only the audio frequency. \$\endgroup\$ Commented Dec 3, 2018 at 16:53

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.