# PIC speark driver

Discussion in 'Electronic Basics' started by Michael, Apr 15, 2007.

1. ### MichaelGuest

I'm generating a 1K Hz "tone" using an output pin on a PIC
microcontroller. I'd like to increase the volume. I can (and have
tried) using additional pins to source more current, but I'm hoping to
use a very low pin count MC for the final version. Any ways to maximize
the current without additional components? Otherwise, any simple
circuits to accomplish function (e.g. single transistor).

Currently PIC output pin is directly connected to 8 ohm speaker via 10uF
cap.

Thanks

2. ### Anthony FremontGuest

You can effectively double the voltage by using one pin on each speaker
lead. You drive one pin high and drive the opposite pin low at the same
time.

3. ### MichaelGuest

I'm generating a 1K Hz "tone" using an output pin on a PIC
Doesn't this just yield the difference between a high pin output
(~Vdd-0.7) and a low pin output (~0)? It would only yield double if a
low pin output was the negative of a high. I tried it and the output
level was lower than what I'm currently getting (probably from the ~.7V
loss since it's currently connected between Vdd and a low pin output).

4. ### john jardineGuest

Would've thought you'll get 5V driving speaker current in one direction,
then 5V driving speaker current in the other direction. Speaker cone
movement 'll be full out, back to neutral, then full in. I.e twice the
original distance.
(and 4 times the power!)

5. ### John PopelishGuest

The peak current with a 5 volt possible swing is half the
swing divided by the resistance. So in this case
2.5V/8ohms=.31amperes. Obviously your PIC cannot deliver .3
amps in either direction, so almost all of the 2.5 volt
swing is dropped across the output stage of the PIC. Even 5
outputs in parallel are limited by the total port current
spec for the chip and will make it hot. There are two
simple ways to get more volume to your speaker. One way is
to use a transformer to get a less terrible impedance match
between the output and the speaker.
Something like this:
at about \$10 each. If you look through the surplus
suppliers you may find one for a dollar or two.

The other approach is to add a current booster stage to the
output. The simplest would be an NPN and PNP transistor
connected as a complementary emitter follower. This can
boost the available peak current by something like 20 to 50
times higher, and will keep the output current at the PIC
within specs.

This requires just the two transistors (e.g. 2N3904 and
2N3906 or 2N4401 and 2N4403). Both bases connect to the PIC
output, both emitters connect to the coupling capacitor to
the speaker. The NPN collector connects to the 5 volt
supply, and the PNP collector connects to ground.

6. ### petrus bitbyterGuest

You may get some nasty (current) spikes while switching. I'd advise a small
resistor between the collector of the NPN and the Vcc and a decoupling
capacitor near the transistor circuit.

petrus bitbyter

7. ### John PopelishGuest

I agree that a bypass capacitor from collector of the NPN to
the ground return point for the speaker is a good idea. But
there is so little extra voltage available, that I would
of the NPN and the 5 volt supply, to retain as much voltage
as possible for the transistor driver. If the supply cannot
handle the current drawn by this driver, then it can't
handle this volume from an 8 ohm speaker.

8. ### MichaelGuest

I'm generating a 1K Hz "tone" using an output pin on a PIC
I see your point, but I tried it again and the results were the same.
My understanding of analog electronics is limited, so maybe someone can
explain why what you stated doesn't result (or what I might be doing wrong).

9. ### Jonathan KirwanGuest

My guess (I'm a hobbyist, nothing more) is that this is due to the
driver impedance. Figure about 120 ohms source and 80 ohms sink. When
you were driving just one pin, you only got one of those inserted.
With two pins, you've always got both reducing current.

Jon

10. ### feeboGuest

your speaker will pull a lot more power that the PIC can source (or
sink) directly... put a transistor in the way (same as you would drive
a relay)... much better.