10
\$\begingroup\$

There seem to be about 4 major flavors of transistors, and then there are NPN/PNP versions. There are also relays, SCRs, and TRIACs.

When I need an microcontroller-controlled switch, what rules of thumb should guide me in choosing? Are there a few common ones that people like to keep around for use when there are no particular high-performance specs?

I'd like to learn the general rules so I don't end up googling 37 variants of the same question.

For a concrete example, the application I am choosing for right now involves driving a 5 V, 160 mA (80 mA average at 50% duty cycle), 3.1 kHz buzzer with an output from a 3.3V MCU that can sink 8 mA or source 4 mA.

\$\endgroup\$
  • \$\begingroup\$ I won't use Triacs to switch low voltage \$\endgroup\$ – mbx Jun 6 '11 at 19:10
  • 1
    \$\begingroup\$ Do you have a link to the piezo's datasheet? (That 160 mA seems like a lot) \$\endgroup\$ – stevenvh Jun 7 '11 at 6:01
  • \$\begingroup\$ @stevenvh Yeah, it sounds like a lot to me too. But it says 5V, 30 ohms (~= 165 mA), and max current 80 mA. Since it also says 50% duty cycle, and since 80 is close to half of what the 30 ohms would give, that's what I'm thinking? I may be misreading it, I have not played with one of these before. soberton.com/NewFiles/Product%20PDFs/GT-0950RP3.pdf \$\endgroup\$ – Doug McClean Jun 7 '11 at 13:46
  • \$\begingroup\$ @Doug - It says coil resistance; it's not a piezo at all, but rather something like a speaker. I suspected this, but you seemed so positive in mentioning the piezo. \$\endgroup\$ – stevenvh Jun 7 '11 at 14:32
  • \$\begingroup\$ @Doug - Don't forget to place a diode parallel to the buzzer (cathode on Vcc) to protect the driving transistor. \$\endgroup\$ – stevenvh Jun 7 '11 at 14:38
8
\$\begingroup\$

Bipolar transistors and FETs work about the same on the output side when you are using them as switches in low power applications like you mentioned. Both come in two flavors to make either high side or low side switches. The NPN bipolar and N channel FET are the low side switches, and the PNP bipolar and P channel FET are the high side switches.

The difference between bipolar and FET is mostly how they are turned on and off. Bipolars are turned on by running some current thru the base. This allows a much greater current to flow thru the collector. The ratio of the possible collector current to base current is the gain of the transistor. FETs are controlled by voltage instead of current. A basic N channel MOSFET might require 12-15 volts on the gate to be fully on, with 0V fully off. There are things called "logic level" FETs that can switch between on and off well enough to be driven directly by 3.3V or 5V logic outputs.

I'm going to disagree with Starblue and say that for very simple switching applications for hobby use, get a handful of good logic level FETs like the IRLML2502. They will cost of 10s of cents each, but are very fogiving as long as everything is limited to 20V. I would certainly not start with that for a volume design done by a professional, but if you just want to get started with one answer that serves the most needs, this is a good first part to get used to.

Once you're ready to experiment with bipolars get 100 each of 2N4401 and 2N4403. They are dirt cheap, widely available, and all around pretty robust for their size. They would also be fine for switching 200mA loads, but you need to know a little more to use them well. You can't just connect them directly to a microcontroller ouput in a switching application.

\$\endgroup\$
  • \$\begingroup\$ with a BJT, you just have to remember to use a small (say 100 ohm) base resistor, it's not a whole lot more complicated (admittedly oversimplifying) than that really :) \$\endgroup\$ – vicatcu Jun 6 '11 at 21:33
  • 1
    \$\begingroup\$ Yes, you have to add a base resistor, but it's not as simple as plunking down 100 Ohms. You need to consider the load current, divide that by the transistor gain to get the minimum base current, find the voltage drop accross the base resistor considering the B-E drop, then calculate the base resistor value. You also have to make sure the logic output can actually drive that amount of current at the assumed voltage. \$\endgroup\$ – Olin Lathrop Jun 7 '11 at 13:12
6
\$\begingroup\$

Prefer the simplest and cheapest solution.

If an NPN transistor can do the job, use that. For your buzzer you could use some small power NPN transistor. Small signal NPN transistors are for currents less than about 100mA, small power for up to about 1A.

If that is not powerful enough, consider a MOSFET.

Relays, SCRs (thyristors) and triacs are more for switching higher voltages.

\$\endgroup\$
  • \$\begingroup\$ Why not start with a small MOSFET? BJTs were cheaper some time ago, but MOSFETs are catching up in price, and are easier to use as switches (in my opinion). \$\endgroup\$ – Kevin Vermeer Jun 7 '11 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.