Shop OBEX P1 Docs P2 Docs Learn Events
Transistor questions — Parallax Forums

Transistor questions

firestorm.v1firestorm.v1 Posts: 94
edited 2006-04-25 20:34 in General Discussion
I'm really a newbie when it comes to the world of TTL and power requirements. What I am trying to understand is how a transistor works. I understand that there is a base, collector and emitter as shown in the "What's a Microcontroller" manual but what confuses me is the wiring of the device.

From what I can tell, the emitter is always connected to ground, the base is the "trigger" and the collector goes ground when voltage is applied to the base (i.e. a light connected to the collector and GND will not light, but a light connected to the collector and +5V or +12v will light assuming that I have not exceeded the power limits of the transistor)

I am reading the datasheet for the included 2n 3904 transistor at www.fairchildsemi.com/ds/2N%2F2N3904.pdf and just to verify that I'm reading this correctly, I can pull a maximum of 40VDC and 200mA through the transistor's Collector/Emitter pins as long as the voltage I put through the base to the emitter does not exceed 6VDC. Is this correct? If that's the case then I can run the basic stamp off of a 5V power supply and as long as the 5V and the 12V have a common ground, I can use the transistor to switch ground coming from a 12v power supply?

On page #265 of the "What's a Microcontroller" book there are two 100K resistors between the base and the IO pin on the Bs2. What is the purpose of these pins?

According to the chapter 9, first activity (on p263-265) of the WAM book, the voltage that goes into the base, affects how much voltage goes through the collector-emitter. Is there a formula for this ratio? Looking at the datasheet the base's max voltage is 6VDC, and the collector/emitter is 40VDC so obviously it's not a simple 1::1 ratio. Any hints on where I can find this ratio?

The transistor used in the book is an NPN transistor, What are the effects of a PNP transistor?


Thank you for helping me understand.. [noparse]:)[/noparse]

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-04-25 15:07
    You're basically right about switching 12V loads with a 2N3904. Keep in mind that a switched on transistor still has some resistance and therefore dissipates some power and this becomes heat. At the higher currents specified for a device, you really have to look at the on-resistance curves and power dissipation curves on the datasheet. It's safer to just pick a device made for higher power, maybe use a heatsink. There are ICs specifically made for switching loads up to 500ma from a logic level. Look at the ULN2000 and ULN 2800 series Darlington arrays. A Darlington pair is just a pair of transistors connected for high current gain, used for switching, and easily included in an integrated circuit.

    The 100K resistors in series with the transistor bases are used to limit the base current to prevent the transistor from being destroyed or the I/O pin circuitry from being damaged. Functionally, the base-emitter junction is just a forward-conducting diode and has no inherent limit to the amount of current than can flow (it's a low resistance). Most CMOS outputs are very happy with currents up to 10-20ma and, with a 5V supply, a 220 to 470 ohm resistor works just fine. For most uses, you don't need that much base current, so a higher resistor saves on power (100K gives about 50ua).

    The gain of a transistor is specified as hFE and is a ratio of currents rather than voltage. For an hFE of 10, a current into (or out of) the base of 10ma results in a collector current of 100ma. This is actually not very useful since, for most transistors used for switching like the 2N3904, it is specified as a minimum gain and, as you can see from the datasheet, varies somewhat with current and supply voltage.

    A PNP transistor is the inverse (polarity-wise) of an NPN transistor. The emitter gets connected to a positive supply, the collector switches to the positive "ground", and the direction of the current that causes conduction is reversed. For practical purposes, a PNP switching transistor is usually used to connect something to the positive supply rather than ground, and is activated by connecting the base to logic zero.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 15:10
    You shouldn't try to think of the base as being voltage driven.· That's how a MOSFET works.· Instead think of the base on the transistor as being current driven.· That's why you always see a resistor between the Stamp I/O pin and the base since the there will be current draw from the Stamp I/O pin that is related to how much current you're driving on the collector-emitter leads.· You can calculate this using the transistors gain or hfe rating and knowing how much current you will be driving.· To be safe you can usually use a 1K resistor on small-signal transistors configured as a switch and the component will exceed its own ratings before you ever draw enough from the I/O pin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 15:13
    I see Mike was typing at the same time.· =)· Well, that gives you some more information then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-04-25 16:22
    Ahh, that information is extremely helpful Thank you both.

    To make sure I understand, the BS2 doesn't do anything current-wise when connected to the base except to connect it to Vdd. The two resistors draw the current through the base lead on the transistor which in turn allows a proportinate amount of current through the collector down into the emitter, on to Vss.


    Now, my next question.

    How do I figure out how many mA that a resistor pulls? I would assume that if I connected 300some resistors to a pin of the Bs2 and Vdd then brought hthe pin low I'd blow it.. :P I know that the bs2 pins have a sink/source rating in mA but darned if I can't find it. I'm messing with transistors and things now and I don't want to exceed the power limitations of the hardware. [noparse]:)[/noparse]

    Thanks again for the info!
  • Mike GreenMike Green Posts: 23,101
    edited 2006-04-25 16:46
    Ohms Law: Voltage across a resistor = Current through the resistor * Resistance

    This is very very basic. Keep in mind that an I/O pin doesn't get switched exactly to 5V or 0V for a logic high or low. For I/O currents up to maybe 20ma and a 5V power supply, the high voltage is about 4.3V and the low voltage is about 0.6V. For example: You want to have 10ma go through an LED when the I/O pin goes high. The high voltage is about 4.3V, the voltage drop across the LED is about 1.7V leaving 2.6V to drop across the resistor. At 10ma (0.01A), the resistor should be: R = 2.6 / 0.01 or 260 ohms. The closest standard value is 270 ohms. There you go.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-04-25 16:58
    Download the datasheets for the SX series microprocessors from Parallex's website. These are the microprocessors used in the Stamps and the datasheets give the information on the capabilities of the I/O pins. They typically give the maximum total current limits for I/O and the limits for each I/O pin. They also give the information on output voltage levels for logic high and low at specific currents. The voltage thresholds for input logic high and low are also specified. Most of the time, these are related on the power supply voltage which you can assume is near 5V. The Stamps include their own voltage regulator which should be accurate within at least 10%.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-04-25 17:20
    Thanks for more great info, my printer is going to be busy tonight.. :P

    How do I find out the voltages that various components use? You mentioned an LED dropping 1.7v. Is there a way I can test this using a voltmeter without damaging the component? One of the projects I may be designing is a switch array that Chris Savage posted in another forum, using RCTIME to create a switch resistor network using push buttons in order to conserve IO pins.

    That will help greatly, now if I didn't suck so bad at math, I'd have something.. :P
  • radiodiverradiodiver Posts: 3
    edited 2006-04-25 17:45
    Firestorm,

    I think you need to get a book on basic electronics and maybe one on algebra.

    These will help you be better understand component data sheets.

    There are several people on this form to help you understand the basics.

    Good luck,

    radiodiver
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 17:46
    firestorm.v1 said...(trimmed)
    To make sure I understand, the BS2 doesn't do anything current-wise when connected to the base except to connect it to Vdd. The two resistors draw the current through the base lead on the transistor which in turn allows a proportinate amount of current through the collector down into the emitter, on to Vss.
    No, you're not just connecting the base to Vdd, as was said by both Mike and myself, it's the current that matters.· Yes the voltage matters to some degree, but if you connect the base to Vdd you will likely burn both·the I/O pin and the transistor.There should always be a resistor between the base and the I/O pin, and usually its value will depend on the current you are driving as well as the hfe of the transistor.· You can almost always safely use a 1K resistor on small signal transistors safely as well as on my power transistors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 17:47
    As a side-note you could search Google for transistor tutorials.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-04-25 19:15
    Radiodiver: I dug through my pile of books and found an older book called "TTL Cookbook" by don lancaster. I'll give it a read and we'll see what develops..

    Chris Savage: When the pin goes high by the BS2 doesn't that connect it to Vdd?. The resistors in the Bs2 and the two resistors give the transistor the current draw that the transistor is looking for, correct? I had tried initially to find transistor tutorials, but my search wasn't as fruitful. I'll try it again.

    I feel really stupid but I have forgotten what current is... :P I know that current is amps and some other basic information, but I am not confident that I know enough to start messing with transistors.

    Thank everyone for your patience. I really appreciate it.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-04-25 20:34
    You really need to go to your local library and check out a basic book on electronics, transistors, etc. Sometimes the hobby electronics magazines run series on electronics basics. The ARRL has an excellent Handbook for Amateur Radio that has chapters on basic electronics. I think their website is <www.arrl.org>.
Sign In or Register to comment.