# Calculate Base Resistor in a NPN transistor switch

I am building a switch for a buzzer that will charge up a capacitor and sound the buzzer as they hold the button down. When they release the button the buzzer will fade away as the capacitor discharges. The Charging and discharging will only happen on the initial switch down (charge) and the switch up (discharge) Everything works as expected and works well. But the question is why. I have used transistors to make switches and h-bridges before and understand the function and how to calculate the variety of currents and resistances, but the addition of the active buzzer has thrown me.

Part of the issue is that I know nothing about the active buzzer. It came in another kit with no information or part number. So basically I started with a high resistance for R1 and worked my way down until it worked (even a 470 Ohm resistor was to much). This is not a great way to do it, but I figured if I had a working model, I could reverse engineer why R1 had to be that resistance.

What I know from using my multimeter:

• The buzzer is a 5v buzzer
• The current on the Load when R1=220 is 13mA

So if I wanted to calculate R1 (or the current going into the base) without just using trial and error, how would I go about it? It just seems that a current of ~7mA is a lot to control a small load.

UPDATE

Sometimes you have to learn the hard way. Indeed the transistor was backwards. I was looking at the wrong spec sheet. credit to @JIm Dearden for first suggesting that and to @Olin Lathrop for crunching the numbers and reconfirming the backwards transistor debacle.

• Perhaps you have your transistor upside down and its giving you a very low gain. – JIm Dearden May 27 '16 at 17:59
• You should get a gain of around 10. What is the CE and BE voltage? – user110971 May 27 '16 at 18:04
• If you have a scope, measure the voltage on R2. If not, and your multimeter has RMS AC measurement capability, use your multimeter to measure the AC voltage across R2. Your circuit must provide the maximum instantaneous current required by the buzzer circuit, which may be higher than the average. If this is the case, you could use an n-channel FET instead of the 2N3904 – John Birckhead May 27 '16 at 18:09
• @JImDearden Yes the transistor is properly oriented – The4thIceman May 27 '16 at 18:14
• @JohnBirckhead I am using DC Current from a 9v battery and a couple of AA. – The4thIceman May 27 '16 at 18:15

You find this by first determining the collector current requirements of the transistor, then working backwards to find the base current, then the resistor to support the base current.

To find what current the transistor needs to switch, remove the transistor and close the switch with a ammeter instead. That will tell you how much current the string of R2 and the buzzer require when the bottom end of the buzzer is grounded. That's the collector current the transistor must be able to support.

Actually, that's the average current. Depending on the type of buzzer, this current may be in bursts that are higher. However, the capacitor will help to smooth this out. I'd want the transistor to support at least twice what you measure given no other information.

It's not totally clear, but let's assume this is the 13 mA figure you gave. We will therefore want the transistor to support 26 mA minimum.

The base current is the collector current divided by the transistor gain. You get the gain from the datasheet. I'll use 50 as the minimum guaranteed value in this example. It's your job to look up the real number. (26 mA)/50 = 520 µA, which is the minimum required base current.

Figure the B-E junction drops 700 mV. Since you're starting with 3 V, that leaves 2.3 V across the base resistor. Lose the diode in series with the base. I can't even guess what you think it's purpose is. Now it's just Ohm's law, (2.3 V)/(520 µA) = 4.4 kΩ.

Since you found you need a much lower base resistor, something is rather different from this example, even considering the gratuitous diode you had in series with the base. I suspect the peak current required by the buzzer is much more than you think.

Even with the extra diode, you should be getting 7.3 mA base current. The maximum possible collector current is with the transistor saturated, say 200 mV, and the remainder across the resistor. (8.8 V)/(100 Ω) = 88 mA. The maximum required transistor gain is (88 mA)/(7.3 mA) = 12. That is well below what a 2N3904 can do at that current, so something in your setup is wrong. You may have misread a resistor value someplace, or as Jim Dearden mentioned, have C-E of the transistor flipped. They still work like a transistor that way, but usually with lower gain.

• I removed the transistor and the current required when the bottom end of the buzzer is grounded is 18mA, so not much more than the original reading of 13mA. – The4thIceman May 27 '16 at 18:52
• But indeed you are right, something is rather different from this example. Because i got similar numbers when I did my calculations as well. How would I figure out the peak current of the buzzer? – The4thIceman May 27 '16 at 18:54
• @Jim Dearden - the buzzer is probably a piezo device that is at resonance, so you charge it up at each audio cycle which causes its geometry to change, and then it discharges, providing current back to your circuit. During the charging, current is higher than average, and lower during discharging. SO you will have current peaks at the output audio frequency. – John Birckhead May 27 '16 at 19:18
• When the current is high, the base current x HFE must be greater. – John Birckhead May 27 '16 at 19:19
• Also keep in mind, if I remove the capacitor so it is a straight switch for the buzzer on and off, the issues are the same. There is just no charging and discharging. So i guess maybe I am underestimating the current. – The4thIceman May 27 '16 at 19:30