Thanks for the base resistor sizing explanation. There's plenty of circuits that pass through the list using transistors but I don't ever remember seeing the resistor sizing explained. wrt to switching high/low side, isn't there a UL requirement for switching high side so the device has no power when not enabled. Does this only apply to AC devices? thanks chuckc -------Original Message------- From: Olin Lathrop Sent: 05/04/03 10:48 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [EE]: Transistor switch - PNP vs. NPN > > > When using a transistor for a simple switch (in this case, because the > amount of current will exceed the capability of the I/O pin on a PIC) is > there a rule of thumb for when to use a PNP and when to use an NPN? > Since the I/O pin, controlling the base, obviously can either be set > high or low, it seems that either would work equally well. But > perhaps there are some "gotcha's" that I don't know about? To a first approximation, consider NPN and PNP transistors as having the same capabilities but mirror images of each other. Its not a question of which one will work better, but which orientation makes the most sense in your circuit. The simple answer is to use an NPN as a low side switch (one side of load to positive supply, other side of load to collector, emitter to ground), and a PNP as a high side switch. If you don't care which way the load is connected, use an NPN in a low side switch configuration. There are some subtle reasons why NPN is preferred over PNP when all else is equal. This is partly due to device physics, and partly due to semiconductor manufacturer tooling and process optimization. The subtle differences won't matter in everyday applications, except that the equivalent PNP will usually have slightly poorer specs and/or slightly higher cost. In designing an NPN low side switch, connect the collector to the low side of the load, the emitter to ground, and the base to the PIC pin via a resistor. First determine the maximum current the load will require and select the transistor to comfortably handle it. Now divide this current by the "beta" or "Hfe" to determine the minimum base current required to sustain that load current. Then size the base resistor so that the base receives 1.5x to 2x that current when the PIC pin is high. Stop if the base current gets close to the PIC max source current - you need a different topology then. Figure the base will be at 700mV for this purpose. With a PIC supply of 5V, the base resistor will drop 4.3V. For example, let's say your maximum load current is 250mA. That can be easily handled by a "jelly bean" NPN transistor like a 2N4401 ($6 per bag of 100 from Jameco). These have a gain of about 100 at that current, so this means you need at least 250mA/100 = 2.5mA base current. To be safe, I'd want to see 5mA base current. This is still well within the PIC output pin drive capability, so we can proceed. The base resistor will drop 4.3V, so R = 4.3V / 5mA = 860 ohms. We should check the power dissipation just to make sure. Figure the collector to emitter voltage drop at 250mA will be 500mV (probably half that in practise, but we're trying to check with pessimistic assumptions). The power dissipated by the transistor is therefore 250mA x 500mV = 125mW. That will get noticeably warm, but is still well within the operating limits even with these pessimistic assumptions. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.