0

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)

NPN Transistor Switch

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.

The4thIceman
  • 105
  • 1
  • 5
  • 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
  • The voltage across R2 will give you the current in the collector leg. The buzzer is a dynamic load, so there is an AC component to this current (not constant). The collector must handle your peak instantaneous current – John Birckhead May 27 '16 at 18:18
  • Why does the buzzer need a 1000uF across it? – JIm Dearden May 27 '16 at 18:19
  • Same reason - instantaneous current – John Birckhead May 27 '16 at 18:20
  • @user110971 Vce = 1V Vbe = 0.7 (both when switch is on) – The4thIceman May 27 '16 at 18:20
  • @JImDearden So the buzzer with get louder and softer as the capacitor charges and discharges – The4thIceman May 27 '16 at 18:22
  • @JohnBirckhead I understand what you are saying, but how would I know what the peak instantaneous current will be? – The4thIceman May 27 '16 at 18:24
  • Instantaneous current? Where from? Until the transistor is turned on the voltage across the capacitor is zero (so no instantaneous charge available). To the transistor the capacitor looks like a short circuit so there's only the 100R resistance to limit the initial current. – JIm Dearden May 27 '16 at 18:27
  • I'm afraid that doesn't make sense to me either - there is nothing to make the voltage across the capacitor increase and decrease as a sort of modulation to loudness unless your talking about begining and end of switching (initial charge - final discharge) – JIm Dearden May 27 '16 at 18:29
  • @JImDearden Correct. It is only at the beginning and end of switching that the capacitor will charge and discharge – The4thIceman May 27 '16 at 18:33
  • Ah, the penny is beginning to drop. Initially only the 100R is in circuit giving the current through the transistor as about 80mA (8V/100) indicating you have a gain of about 10 for that transistor. The capacitor charges up causing the buzzer to turn on and get louder as the voltage across the capacitor increases. This charging also reduces the current through the transistor and disappears once the capacitor is fully charged (back to your 13mA). When turning off the transistor the capacitor discharges causing the buzzer to fade away. – JIm Dearden May 27 '16 at 18:39
  • One more try - if the problem is the instantaneous current rather than average, you can probably mitigate it by putting a large capacitor between base and ground. Then try a higher-value base resistor – John Birckhead May 27 '16 at 19:09

1 Answers1

1

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.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
  • 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
  • And even if it is indeed a piezo buzzer, why would that need such a low resistor on the base to run it properly? – The4thIceman May 27 '16 at 19:55
  • I am thinking that with a high value resistor, when the buzzer current is at its peak, the collector current drops and there is not enough current to start the buzzer. A piezo buzzer demands max current at start, up to 10 times its average current. – John Birckhead May 27 '16 at 20:28
  • Soooo.....The transistor was backwards afterall. All the math was being done properly, but that doesn't matter if the transistor is put in wrong. I have to say I look a bit of a fool after this gaff. – The4thIceman May 27 '16 at 20:53