# A cheap LoFi speaker – Impedance II

I needed to make a little speaker. The real reason? Because of a retro gaming session at work. However, there have been several times that I’ve needed a small cheap speaker that was suitable for delivering simple stimuli. I thought I would post a schematic and take this opportunity to give you an example of how Matlab can make impedance calculations easier, something I’ve talked a little about before.

The core of this amplifier is an LM1875 om-amp. The circuit shown above is a complete rip off of the schematic shown in Figure 2 of the data sheet, with a few unnecessary parts removed. Instead of trying to design a one from scratch, the point of this post will be to analyse the schematic given. After that, you’ll hopefully be able to make any changes.

Because we want to use a single sided power supply (i.e. our power supply gives us a positive rail and ground), we will need to “bias” the input to our amplifier, so when it receives no other input, it rests at half the supply voltage, giving the op-amp the ability to move negatively, and positively. We then place a capacitor in between the audio source (Vin) and the biased input, so that the bias voltage doesn’t leak back into the audio out. We also need some capacitors to stabilize our supply voltage, just in case the op amp needs to draw lots of current. All of this combines to be the input stage of our amplifier. We then want to amplify our input in a vaguely linear fashion, so we have negative feedback (where we can try to make sure the amplifier doesn’t waste current amplifying our bias voltage). Finally, on the output we have a large capacitor to make sure the speaker doesn’t see any of the bias voltage. The input stage is a bit of a pain to analyse, but I’ll be gentle.

Input Stage

All these capacitors and resistors will end up creating quite a filter, and we need to be aware of what properties it will have. To do a full analysis of this with pen and paper would be a real pain, but with Matlab, this will be quite quick.

So the input stage is the parts of the circuit shown on the right. It looks complex to deal with because on top of all the capacitors, it also has a second voltage source. However, because at this point in the circuit we have solely linear elements, we can use a a technique called “superposition“. In this, what we do is analyse the circuit twice, once for each voltage source, and then add the results. In turn, we change all voltage sources to short circuits, apart from one. Thus, if we change Vcc to a short (to earth), not only does it get rid of the issue of the secondary voltage, but it also removes the 100 µF capacitor from the circuit (because it has an earth on both terminal).

If we then redraw the input stage circuit, we can quickly see that the circuit wont be too difficult to solve. Let’s start with the two 22 kΩ resistors, and one 10 µF capacitor in parallel, these can be replaced with a single impedance $Z_{p}$. We know that the impedance of a capacitor is given by:

$Z_{cap} = \frac{1}{j \omega C}$

and for impedances in parallel, the equivalent impedance is:

$Z_{equiv} = \frac{1}{ \frac{1}{Z_{1}} + \frac{1}{Z_{2}} + \frac{1}{Z_{3}}}$

Thus we can calculate the impedance of the three elements in parallel as:

$Z_{p} = \frac{1}{ \frac{2}{22000} + j \omega 10^{-6} }$

In matlab we can then calculate $Z_{p}$.

>> f = 0.1:0.1:100000; % Frequecy
>> w = f*2*pi; %Convert to angular frequency
>> zp = 1 ./ (2/22e3+j*w*100e-6);


We can then calculate the impedance of the whole right hand side ( $Z_{R}$ ), by adding $Z_{p}$ to the 10 µF capacitor and 22 kΩ resistor that are in series with it.

>> zr = zp + 22e3 + 1./(j*w*10e-6);


At this point, we should look back at the simplified circuit of the input stage. We can see that the voltage $V_{+}$ is simply $V_{in}$ minus the voltage lost over the 1 µF capacitor $V_{cap}$. In order to calculate that, we need to know that current which passes through the $Z_{R}$ ( $i_{R}$), which is simply found via Ohm’s law.

$i_{R} = \frac{ V_{in} }{ Z_{R} }$
$V_{cap} = i_{R} \frac{1}{j \omega 1^{-6}}$
$V_{+} = V_{in} - V_{cap}$
$V_{+} = V_{in} - i_{R} \frac{1}{j \omega 1^{-6}}$
$V_{+} = V_{in} - \frac{ V_{in} }{ Z_{R} } \frac{1}{j \omega 1^{-6}}$

Factoring…

$V_{+} = V_{in} (1 - \frac{ 1 }{ Z_{R} } \frac{1}{j \omega 1^{-6}} )$

Finally, the transfer function is…

$\frac { V_{+} } { V_{in} } = 1 - \frac{ 1 }{ Z_{R} } \frac{1}{j \omega 1^{-6}}$

Which we can calculate and plot in Matlab.

>> input_transfer = 1 - 1 ./ zr * 1./(j*w*1e-6);
>> loglog(f, abs(input_transfer)); xlabel('Frequency (Hz)'); ylabel('|V(out)/V(in)|');


So, we have made a high pass filter, with a cut-off of about 10 Hz. But remember, we’re trying to do a full analysis here, and we’re using superposition, so now we have to turn $V_{in}$ into a short to ground, and repeat our analysis. But don’t freak out, this is going to be super simple. Why? Because we can treat $V_{CC}$ as being purely DC, and hence all of the capacitors will act as open circuits.

So if we convert all the capacitors to open circuits, we are left with a circuit with three resistors, one of which isn’t in the circuit because it is in series with a capacitor. Now the circuit has been simplified to a voltage divider with equal resistors. We know that means the input voltage ($V_{CC}$) will be halved, and so in this case,

$V_{+} = V_{CC}/2$.

To complete the analysis, we add the two cases together, and so:

$V_{+} = V_{in} (1 - \frac{ 1 }{ Z_vv{R} } \frac{1}{j \omega 1^{-6}} ) + V_{CC}/2$

Feedback Stage

This wont be as bad as the above. We just need to remember that because we have negative feedback, the voltage at the inverting terminal of the op-amp $V_{-}$ will be the same as at the non-inverting terminal. We also need to use superpositioning again.

If we look from the perspective of $V_{out}$, then $V_{-}$ looks like the center of a voltage divider, between a resistor, and a resistor/capacitor. First, let’s calculate their impedance. The feedback resistor ( $R_{f}$ ) has a simple impedance of 22 kΩ. The resistor/capacitor section ( $Z_{g}$) has a complex impedance. So in matlab:

>> rf = 22e3;
>> zg = 22e3 + 1./(j*w*10e-6);


The point of the voltage divider is, unsurprisingly to divide the voltage. Specifically, as $R_{f}$ gets larger relative to $Z_{g}$ then $V_{out}$ has to get larger and larger to keep $V_{-}$ equal to $V_{+}$ (because more of the voltage is generated over $R_{f}$ rather than $Z_{g}$). With a normal resistive voltage divider, we could say $v_{out} = \frac{v_{in} R_{2} }{R_{1} + R_{2}}$, here we can say:

$V_{-} = \frac{ V_{out} Z_{g} }{ R_{f} + Z_{g}}$

However, as we know the value of $V_{-}$, we can rearrange, and get:

$V_{out} = \frac{V_{-} ( R_{f} + Z_{g} )}{ Z_{g}}$

So, given that we know $V_{-}$ is equal to $V_{+}$ we can now say (for the superposition case where $V_{CC}$ is off):

$V_{out} = \frac{ V_{in} (1 - \frac{ 1 }{ Z_{R} } \frac{1}{j \omega 1e-6} ) ( R_{f} + Z_{g} )}{ Z_{g}}$
$\frac{V_{out}}{V_{in}} = \frac{ (1 - \frac{ 1 }{ Z_{R} } \frac{1}{j \omega 1^{-6}} ) ( R_{f} + Z_{g} )}{ Z_{g}}$

So in Matlab, once we notice that most of that equation is the input_transfer variable we calculated earlier:

>> full_transfer = input_transfer .* (rf+zg) ./ zg;


Here it would be a good idea to think about what is actually going on. We did some filtering at the input stage, and then applied some amplification and filtering. We can view those all by plotting:

>> loglog(f, [abs(transfer); abs((rf+zg) ./ zg); abs(full_transfer)]); xlabel('Frequency (Hz)'); ylabel('|V(out)/V(in)|');
>> legend('Input Transfer Function', 'Feedback Transfer Function', 'Full Transfer Function')


So as you can see, most of the high pass filtering was achieved by the passive input filter, but because of the series capacitor to ground in the feedback path, low frequency signals were not amplified (because to DC signals, the ground half of the voltage divider provided infinite impedance).

Finally, we should address the other superposition case, where there is no input apart from $V_{CC}$. We know that in this case, $V_{+} = V_{CC}/2$. Because of negative feedback, that means $V_{-} = V_{CC}/2$. Using the equation we calculated earlier, we can then say:

$V_{out} = \frac{V_{CC}/2 * ( R_{f} + Z_{g} )}{ Z_{g}}$

However, here we need to stop and think. $V_{CC}$ is purely DC. That means all the capacitors act as open circuits. That means $Z_{g} \Rightarrow \infty$. Which means that the above equation is really:

$V_{out} = V_{CC}/2$

We could have guessed this from looked at the graph above, and the feedback transfer function: it tends towards 1 for DC values.

Thus, the true, absolute final output equation is:

$V_{out} = \frac{ V_{in} (1 - \frac{ 1 }{ Z_{R} } \frac{1}{j \omega 1e-6} ) ( R_{f} + Z_{g} )}{ Z_{g}} + V_{CC}/2$

.

Output Stage

There is no point doing a full output analysis here, because the speaker is so cheap that it doesn’t have full specs. The only thing worth noting is that the huge capacitor on the output blocks the DC component of the output, i.e. $V_{CC}/2$. By being such a large capacitor, it presents almost no impedance to anything but the lowest of frequencies.

Build

Pallet wood, a 2.25″ hole and some screws

DescriptionSupplierPart NumberCost
LM1875 Op-ampFarnell / Newark1468913 / 41K3523£2.05 / $3.08 8 Ohm speakerFarnell / Newark4262323 / 19J5689£1 /$3.33
2200 uF, Electrolytic CapacitorFarnell / Newark2282194 / 65R2740£0.245 / $0.198 10 x 100 uF, Electrolytic capacitorsFarnell / Newark1902882 / 55T0367£0.34 /$0.36
10 x 10 uF Electrolytic capacitorFarnell / Newark1902913 / 55T0590£0.685 / $0.39 10 x 22k ResistorsFarnell / Newark£0.1 /$0.1
12 V DC supplyFarnell / Newark2424065 / 83T4338£5.41 / $10.04 TOTAL£9.83 /$17.50