transistor gain and loudspeaker

I'm trying to power a small loudspeaker (8ohm 0.5W) off an attiny output using a transistor and I have to hand THESE and THESE. I'm trying to calculate my base-pin resistor value but I'm struggling to ascertain what the gain is for either of these transistors: the specs mention "Minimum DC Current Gain" but then display a value in Volts - I thought the gain should be a simple ratio... am I missing something here?

Also, am I right in thinking "Maximum DC Collector Current" is the max current the transistor will allow through the device I'm powering?

Lastly, I remember reading one should be wary of voltage spikes when coil devices discharge and a diode can help protect against this. Should I be worried enough to introduce one here?

Thanks.

the specs mention “Minimum DC Current Gain” but then display a value in Volts - I thought the gain should be a simple ratio

The gain is a simple ratio, but is specified for a particular collector-emitter voltage (VCE) and a particular collector current (IC) - usually the higher the current, the lower the gain.

Apologies if this is obvious but I'm still a little confused. Looking at those specs could someone tell me how to calculate the base pin resistor value that would have the speaker running at max output? And perhaps why the "Minimum DC Current Gain" uses a unit in volts.

englebert22: I'm trying to calculate my base-pin resistor value but I'm struggling to ascertain what the gain is for either of these transistors:

It's on the datasheets under hFE...

englebert22: the specs mention "Minimum DC Current Gain" but then display a value in Volts

The datasheet tells you the gain when there's that many volts across the transistor.

eg. hFE=100, VCE=5V means the gain is 100 when there's 5V difference between collector and emitter.

1k base resistor is always a good value. But you must insert a resistor in series with the loudspeaker as well (for example 220ohm).
8ohm loudspeaker is too low impedance to be connected that way.
Or you may use an output audio transformer with 2k:8ohm ratio.
Or I would rather do it this way (to get the speaker out of the large DC currents):

speaker.jpg

Also, am I right in thinking "Maximum DC Collector Current" is the max current the transistor will allow through the device I'm powering?

No it is the maximum current that you should allow the transistor to pass. Given a low enough resistance load you can pass any amount of current but the transistor will melt.

pito: 1k base resistor is always a good value. But you must insert a resistor in series with the loudspeaker as well (for example 220ohm). 8ohm loudspeaker is too low impedance to be connected that way. Or you may use an output audio transformer with 2k:8ohm ratio.

That depends on the transistor, but misses the most important point, a (moving coil) loudspeaker needs AC drive with no/little DC bias (else it will travel to the end-stops and get hot and distort the sound). You thus cannot drive a loudspeaker from a single transistor well - either you have DC bias (bad) or you have to use a blocking capacitor and need to add a load resistor (inefficient).

This is fundamentally the same reason that a reversing motor cannot be driven from a single transistor (and needs an H-bridge). Usually for audio amps a blocking capacitor is used and only half an H-bridge is needed (ie a push-pull driver, needs 2 transistors). Bridge-mode audio amps lose the capacitor and have a full H-bridge configuration (but linear rather than switching brdige).

That depends on the transistor, but misses the most important point, a (moving coil) loudspeaker needs AC drive with no/little DC bias (else it will travel to the end-stops and get hot and distort the sound).

Therefore I suggested another simple wiring - see above. Transformer does remove DC too..

The right base resistor to get is easy for that wiring: 1. decide on the required collector current, for example Ic=20mA. 2. look at datasheet - hfe is the gain under similar conditions, let say 100. 3. you need base current Ib = Ic/hfe, Ib = 200uA 4. base resistor value will be Rb = (5V - Ube)/Ib = (5 - 0.7)/0.0002 = 21500 ohm, for this wiring, approximately (some may suggest lower values, if saturation is required).

The biq Q is how to decide on the Ic. If you want PWM the amplifier, the design has to consider that. As a beeper it may work that way (the loudspeaker coupled via capacitor or a transformer).

Thank you to everyone who commented, they all helped. What confused me the most was the specs listed on the e-tailer's product page (they list the gain using a voltage?) but pulling the actual data sheet made more sense with the min/max gain. I think I've also got my head round the subject of using transistors for switching in terms of...

  1. calculating the current requirement at the collector
  2. calculating the min base current for saturation using the worst case gain
  3. calculating the required base pin resistor

My circuit ended up as:

Compared to before where I was powering the speaker directly off the attiny output pin with a 100ohm resistor this is noticeably louder.

Can someone however tell me the best way to introduce a variable resistor so I could adjust the volume lower if needed? Would it be as simple as placing the variable resistor in series with the existing 100ohm resistor?

pito: Or I would rather do it this way (to get the speaker out of the large DC currents):

pito, not sure if you posted an image or something but nothing is showing for me and I'd be interested in seeing it.

http://www.ebay.com/itm/170850491058

englebert22: Compared to before where I was powering the speaker directly off the attiny output pin with a 100ohm resistor in series this is noticeably louder.

Checking my work I noticed I put in a 10ohm resistor instead of a 100ohm one by accident which is why it seemed louder. Swapping it for a 100ohm one and it seems to match the sound output it had before which is again a little low for my liking. Also just learned a multimeter isn't the best tool for taking measurements when frequency/pwm is involved.

Thinking about it some more it seems using a 47ohm resistor in series with the speaker would mean a current flow of 90mA which is within spec of the transistor and it does improve the volume somewhat. Is there any other cheap improvements I could make to achieve a higher volume such as pito's example circuit with the capacitor?

pito, not sure if you posted an image or something but nothing is showing for me and I’d be interested in seeing it.

There is a picture in my post - I can see it.

PS: Not sure whether your calculation is correct: 46mA/110 = 4.18uA, my calculation shows 418uA.

Is there any other cheap improvements I could make to achieve a higher volume

No, there is not, without using a transformer or other complex wiring.
To get maximal power, you must match the impedance of the source and of the load. Your source is the transistor’s output impedance in that wiring, and your load is the 8ohm speaker impedance. Typical output impedance of the transistor in that wiring is hundreds of ohms, maybe kiloohms, so you have to transform it down to 8ohm, for example with an output audio transformer. You may use a standard amplifier chip, like LM386 or others.

The simplest stuff I can imagine, which may work better, when you want to listen pwm music, is following (see below):

  1. set the R1 such you get 2.5V on R2.
  2. You will have Ic=53mA current with no signal
  3. this is not an amplifier, but an impedance matcher, with better linearity as your switch
  4. the input pwm from arduino is filtered (5kHz low pass), and AC coupled to the final stage.
  5. The max collector current could be ~100mA peak
    No warranties of any kind :slight_smile:
    Have fun!

pwmfinal.jpg

If you want louder then you really need to go to a better speaker and a MOSFET.
If you ignore the switch at the top left (which is set to either have the two 68 ohm resistors in series or in parallel as a high/low volume control),
the design is pretty much the same as the NPN design from a few posts back.
The combination of 12V supply, the much lower voltage drop across the MOSFET vs an NPN, and this 4 ohm impedance speaker

means this thing cranks! I play a two-tone warble thru it at my fencing club when a touch is scored, it sounds like a really loud cell phone ring.
P = V^2/R = 1212/( (6868)/(68+68)+4) = 4.2W with the resistors in parallel
and
12*12/((68+68)+4) = 1W with the resistors on series.

Wife complains both are too loud :slight_smile:

Part of the sound is the 25V, 220uF cap that lets a lot of current flow to the speaker.

hi every one what if we used a push pull B class amplifier using two complementary transistors such as 2n3904 and 2n3906 and feed their common bases through a 120 ohm resistor will this give us a good amplification of the audio signal if their vcc was same as arduino mega 2560 (which is 5v) ? do we need to put a resistor before the speaker to reduce current to protect speaker and stay within the transistors allowable IC current? please advice on this?

You could try the enclosed…

BC327/337 are rated 1A , so should be OK.

Allan

amp.pdf (19.6 KB)

I have planned this using these same transistors but used 220 ohm to get about .4 w, why use 470 ohm for input signal what is the advantage over a 220 ohm one ? in addition if i am to use pin 11 & pin 12 of the arduino mega 2560 for the tone(ac) library how can i connect them to this proposed push pull circuit? should i connect one to base of bc327 and the other to base of BC 337 each separately if not and I should use it as is what pin should i connect to GND? 11 or 12?

220 or 470 limit the current flow to/from the base of the transistors. When the Arduino output is high and the capacitor is discharged, the current path looks like a diode thru a short to an 8 ohm resistor to Gnd. Current from the Arduino pin is then initially (5V- 0.7V)/8 ohm = 537mA (dropping off as the capacitor charges up). The base resistor limits that current to a safe level: (5V-.7V)/(220+8ohm) = 18.8mA, or 8.99mA with the 470 ohm resistor. If that was the only current source charging the capacitor, then slower charging/discharging might be heard as some loss of upper frequency. However, the transistor is acting like a switch to allow current flow from the 5V source. The body of the transistor when turned on also looks like a conducting diode, so the current into the capacitor is then the addition of the base current, 18.8 or the 9mA, plus the current thru the body of the transistor. The datasheet for the BC337 shows Ic = 500mA with base current Ib of 50mA. https://www.fairchildsemi.com/datasheets/BC/BC337.pdf So 18 or 9mA will limit the current from the 5V source.

If you want more volume, I'd go with the 220. You could go even lower, to (5V-.7)/35mA = 120 ohm, or 150 for ~ 28mA.

For the most volume, go with logic level MOSFETs. Then the current from the 5V source can be (5V)/(8 ohm + Rds of the MOSFET), so the current can be nearly 625mA with a very low Rds part and minimal current from the Arduino to charge the gate of the MOSFET.