Amplifying a small speaker

Hi guys,

I'm playing around with a few sensors and circuits to try and get my head around electronics a bit. I've got some background with theory having taken a couple electrical subjects but my practical knowledge is sadly lacking.

For a small project I'm working on, I'm trying to amplify the input to a small speaker. It's an 8Ohm, 0.25 Watt speaker. Connected in series with a 100Ohm resistor, it produces decent sound but it draws about 45mA of current. It's already fairly quiet and with a 150Ohm resistor it'll be too low.

I bought an LM386 but am a little unsure how to connect it. I've looked in the datasheet and am confused by the circuit for basic amplification. Even though the op amp has 20x gain, the max output voltage is limited to the supply voltage, right? So I'd want a resistor between the output pin of the Arduino and the positive terminal of the op amp.

I'm struggling to come up with a resistor value to limit the input to the op amp. IIRC, as the negative terminal of the op amp is connected to ground, the voltage of the positive terminal will also be ground. With the simple non-inverting op amps we learnt about at uni the analysis is simple, but I've no idea how to do the analysis with the LM386. Is the current across the limiting resistor the same current that's present at the output of the op amp?

What's the need for the capacitor at the output? I assume it's to remove the DC component of signal but why isn't there one present here: http://arduino.cc/en/Tutorial/tone ? The output from the Arduino would be between 0 and 5V, so wouldn't it still have a DC component of 2.5V? Is the cap at the output to ground a decoupling capacitor? And if so, why the need for the resistor in series?

I know that's a lot of question but I'd really like to gain a decent understanding of circuits (given that I'm majoring in Mechatronics). At the very least, can somebody point me in the direction of resources/books where I can get an understanding of these and other practical considerations of electric circuits? Would a book such as Beginning Arduino cover these questions?

You'll need a resistor divider as well as RC low-pass filter from the Arduino to the amp - the easiest way to do this is to add a capacitor in parallel with the lower leg of the divider. To remove the DC component of the Arduino's output then feed the mid-point of this divider/LPF via a capacitor to the input of the LM386.

Yes, capacitor in the output is to remove DC bias from the output (DC bias will push the speaker's voice coil well away from the centre position, causing severe distortion (and heating it up).

Basically the LM386 can amplify small AC signals around 0V, but they can only go a little bit negative, hence the need for 20x gain or more. You are only wanting the current amplification so the resistor-divider will cancel the voltage gain you don't need.

Ok, let me see if I understand this.

The tone() function outputs a 50% duty cycle square wave at the required frequency. I can connect this directly through a resistor to a speaker and get the tone to play. The wave toggles between 5V and 0V, so the 'ground' is 2.5V.

The midpoint of the voltage divider is what's amplified by the op-amp. I want to drop this down so I get an output voltage from the op-amp that induces a current through the speaker which won't cause the speaker to exceed its power rating. So, I want the voltage at the divider to be Vout / 20, where Vout = sqrt(0.25W / 8Ohms).

The low pass filter filters out the higher harmonics of the square wave, (ideally) leaving a clean sinusoidal signal at the frequency at the square wave. Is this just to produce a better quality output by getting rid of unwanted harmonics or is it integral to the operation of the circuit?

I'm assuming the input to the op-amp would still oscillate between 0V and Vout/20?

As the op-amp isn't ideal, there is a slight voltage difference across the input terminals which is amplified. This needs to be removed, hence the series capacitor in the output. Will it also cause the signal to oscillate between -Vout/2 and +Vout/2 (instead of 0 and Vout), hence protecting the speaker?

You could also use a simple transistor (or mosfet) to increase the current available and then put the low pass filter to convert PWM to Analog after the transistor.

OK, I drew up the circuit as MarkT described it in LTSpice.

Does that output look reasonable (green line is voltage from the pin, blue line is voltage across the speaker, which is the 8 Ohm resistor)? The pin outputs a 450Hz square wave.

Is it possible to get something resembling a pure sinuosoid at the output without excessive complexity? Will that signal produce a decent tone through the speaker?

Also, I'm not entirely sure I'm operating anywhere near the max power output of the speaker. Power = V^2/R, but for AC, do I take V as V_max - V_min (which is about 1.4V), or is it just the peak voltage (about 0.7V).

If the former, the power output is about 0.25 Watts, which is what I'm after. If the latter, it's only 0.07 Watts, which is far too low. If it's Vrms of the peak, then it is 0.125 Watts, which is still pretty low.

OK, looking at the output in more details, I've realised the parallel cap is way too low. Increasing its value to 3.2uF, then decreaing R1 to 9000 ohms and increasing R2 to 500 Ohms results in much nicer results. Decreasing the output cap to 100 uF results in a fairly rough approximation of a sine wave, and the program tells me the power across the resistor peaks at 0.16W.

Now to go out and buy some more capacitors. My largest on hand is only 10uF.

I implemented the circuit I mentioned below but it didn't work very well at all. The sound was low and didn't sound pure at all. I'm not sure what the issue is.

Is a sound wave meant to oscillate between -V and V or between ground and V? Currently it's the former, but I'm not sure if it should be the latter. Also, would having the output as a square wave be better than the non-symmetrical sine-ish wave I've got at the moment?

The TBA820 is an easy to use small amplifier, needs some external capacitors all explained in the datasheet. Costs less than 1$. 8pins DIL chip.

This is not an OpAmp it's an IC designed to drive speakers directly.
This device is around for many years but not too common.

It can be interesting if you don't have the time to develope analogue circuits.