Computing stuff tied to the physical world

Easy Electrons – Transistors

In Hardware on Jan 19, 2011 at 00:01

Another installment of the Easy Electrons series. This time I’m going to follow up on the diode post, and go into transistors.

Transistors. Phew. Biiig topic!

There are several types of transistors. The most common one is the BJT. There are two variants, which are schematically drawn like this (from that same Wikipedia page):

Screen Shot 2011 01 18 at 23.32.33

A transistor has three pins, called Base, Collector, and Emitter. Using the convention that current “flows” from “+” to “-“, it’s easy to remember which in an NPN transistor (the most common variant):

  • the collector, eh, “collects” current – IOW, this is where current flows into the transistor
  • the emitter is where the current flows out again, to ground at some point
  • the base is the main control which determines what the transistor does

So what does it do?

One way to look at it, is as a current amplifier: put 1 mA into the base, and the current from C to E will be a multiple of that – anywhere between 50 and 500 times depending on the particular model, i.e. 50 .. 500 mA!

Note that I’m not suggesting that a transistor generates current. Only that when a voltage is applied between C and E, then the current flowing will be a multiple of the “control current” fed into the base.

Things are not quite that simple, though. How do you “put a current” into a component? You can’t just put a voltage on all the pins… before you know it, the current might easily exceed some allowed maximum rating! Transistors have pretty rigid limitations. When you exceed them, they can easily overheat and get damaged.

We don’t really have an easy way to control current, but what we can do is turn ATmega I/O pins on and off, i.e. control the output voltage on those pins. It’s relatively easy to turn that into current though – Ohm’s law: use some resistors!

Here’s a simple circuit to let us explore this behavior:

Screen Shot 2011 01 19 at 00.21.58

The input pin can be fed a voltage, and the R1 resistor will make sure that the current flowing into the base of the transistor will be limited. Likewise, R2 makes sure that no matter how much current the transistor wants to pass from its collector to its emitter, there will be a limit.

How much are these limits? Depends on the voltages and resistor values, of course. Let’s assume the following:

  • the “+” voltage is 3.3V (and GND is 0V, as always)
  • the input pin can have voltages between 0 and 3.3V applied to it
  • resistor R1 is 1000 Ω
  • resistor R2 is 100 Ω

The maximum current flowing into the base will never be more than when IN = 3.3V, i.e. 3.3V over 1000 Ω = 3.3 mA (using “I = E / R”).

The maximum current flowing from collector to emitter is what you’d get if the transistor were a complete short circuit between C and E, i.e. 3.3V over 100 Ω = 33 mA.

Note how I’ve made all sorts of worst-case assumptions about the transistor. In fact, I’ve calculated these values as if B, C, and E were all shorted together, and hence tied to ground (since E is tied to ground).

A real transistor behaves somewhat differently. But no matter how it actually behaves, I know that no more than 3.3 mA will be flowing into the base, and not more than 33 mA will be flowing into the collector and out of the emitter. Just about any NPN transistor can handle that.

Here’s what happens when IN is 0V (i.e. GND):

  • no current will flow into the base
  • since the transistor amplifies the current, no current will flow from C to E
  • if no current flows from C to E, then it’s basically like an open (unconnected) circuit
  • if unconnected, there will be no current flowing through R2
  • with Ohm’s law, the voltage across R2 is (E = I x R) = 0 x 100 = 0
  • so the voltage on the OUT pin will be 3.3V, the same as on the other side of R2

Now, when IN is 3.3V, this is what happens:

  • current will flow through R1
  • lots of current will flow from C to E
  • that’s the same as saying that C and E are more or less shorted
  • that means the OUT pin will now be (close to) 0V

We’ve created a signal inverter: 0V in = 3.3V out and 3.3V in = 0V out!

As I said, big topic. I haven’t even touched on some important details of a “real” transistor.

Stay tuned…

  1. Just for completeness: The base current flows out of the emitter as well, so the upper bound for the emitter current in your scenario would be 36.3mA.

  2. I have been studying analog electronics lately, made a “big discovery” : Transistors have datasheets !! I thought that was a chips thing, but fortunately you can find all you need to know about a transistor from the internet.

    maybe a good idea to include in the easy electrons an example of how to infer useful information from such a datasheet. electrons might be easy, inkblobs are often difficult ;-)

  3. another possible easy electrons subject (please..) : propose a few actual components that are – often found in schematics – obtainable – reasonably modern, i.e. most bang for the buck.

    as a newbie, after digesting all the theory you often still do not know what to order…

    I was thinking small signal transistor : 2N2222 ? BC547 ? JFet : ? enhancement type fet : ? Mosfet high power : ? small signal diode : ? protection diode : ? audio frequency rail-to-rail op-amp : ? tl074 seems outdated

    • I understand the need. This too is a big topic – eventually, you’re bound to end up with lots of components. For resistors and caps: just get several of the decade range: 100 Ω, 1 kΩ, 10 kΩ, 100 kΩ and you’ll have plenty of ways to make other values using them in series or parallel. Same for caps: 0.1µ, 1µ, 10µ, and 100µ will get you a long way. And you’ll learn to quickly estimate the results of tying these things together, which is a useful experience, IMO.

      For the rest, it really depends completely on what you want to do. Get a couple small signal diodes (1N4148), power diodes (1N4007), NPN (BC547/8/9) and PNP (BC557/8/9) transistors, just to be able to construct simple driving circuits, would be my suggestion.

      Op-amps are fantastically interesting and powerful for all sorts of circuits, and well worth getting. I like the dual rail-to-rail OP2340 in a DIP8 package to play with. Be prepared for many evenings of experimentation if you go into that stuff – it’s fascinating.

      As soon as you start going into hiugher-power circuits, MOSFETs are very useful, but you better make sure you can do the basic electronics calculations in your head before you start out on that. High power means sparks, fried components, smoke, blown fuses, etc. if you get it wrong! – in that case I advise getting a current-controlled lab power supply to limit the damage, because things will go wrong once in a while. Which is part of the fun, BTW :)

  4. As Reinhard mentions, the current going into base also flows out of the emitter. If you are driving a LED with the transistor then you would normally put the LED between the Emitter and Ground. In this way the base current actually yields extra light instead of going into ground! Now i am starting to have doubts about this, because some designs don’t seem to agree with me ( Can someone enlighten me?

    • Good point, thanks!

      The reason this is not always done is that the driving voltage has to be (0.7 + LED_forward_drop) volts if you put the LED between emitter and ground, whereas from “+” to collector you can drive any LED, e.g. a 3.7V power LED with a supply of say 5V, even if the voltage on the base is just 3.3V.

Comments are closed.