Let's Make Robots!

Transistors -[Page 3] Switches, common or uncommon

[Added note: while I had intended to add more to this series of pages, to explain FETs (jfet, mosfet, etc.) and so on, I have decided at least for now to not do so. I realised I would just be "reinventing the wheel" as the saying goes, when there are already so many good books on the subject. One you can get currently is called, "The Art Of Electronics" (2nd Ed.) -Horowitz & Hill. It reads a lot like a textbook and can be a bit obtuse at times, but has a lot of good information on transistors and ICs (mainly OpAmps).]



This Page continued from: http://letsmakerobots.com/node/28927


       By practical definition, a switch is anything that is used to turn a device (or function) on or off.  This does not have to resemble a physical switch. It could be a light emitting diode and a photo-diode or phototransistor. The switching can be either when the LED is on or off, or it could be triggered by items passing between the two. Similarly, it could be the rim of a wheel (or gear) with holes drilled around the edge, so the light is interrupted or not as the wheel turns. It could be a transmitter circuit that oscillates or not (or oscillates on two different frequencies) according to whether nearby conductors change the resonance of a coil or the capacitance of a capacitor.


       The possibilities are numerous and robot builders are amongst the few with the imagination to think of different ways to apply these ideas.


                                             A Few Common Switches 



       Now this current discussion is about transistors, so let us take a look at applying transistors to the problem. Many of the more advanced sensors you might use in a robot or a robotic control use transistors in some form. One little note to remember in designing with transistors is that transistors do not actually switch things fully on or fully off. The 'OFF' state still passes a tiny amount of current (generally a few nano-amperes) while in the 'ON' state, the transistor still dissipates some of the power due to its internal resistance.  This does not normally cause any problems, but it could in certain applications, and thus is worth keeping in mind.


       The ON state carries many, many times the current than the OFF state.  This gives us two definite alternate states, much removed from one another that we can interpret as "on" and "off". Look at the 2N3904, which is a commonly used switching transistor. Even in the off state, the 2N3904 still carries a small leakage current, which approaches 50 nanoamps when we have 30 volts between collector and emitter. That is five hundred-millionths of an ampere. The ON state can pass 0.2 amps, which is a current 4 million times bigger than the cut-off state current.  In other words, it would be extremely hard to confuse the two and come up with an error.


                             General Chart of Current vs. Voltage


       To further avoid errors, we use the transistor only in the saturated state to represent the ON state and in cut-off to represent the OFF state. Operating in these end regions gives us a bonus, in that, in both states the transistor should run cool. In the off state, we have a voltage such as 30 volts across the transistor, but the current is 0.00000005 amps. The heat dissipation in the transistor is one and a half microwatts, which is small enough that it might as well be zero. In the on state, the dissipation is higher, but still relatively low. We are passing 200 milliamps, but the collector-emitter voltage is only 200 millivolts, so we have only 40 milliwatts dissipated in the transistor.   (.2 A x .2 V = .04 W) So even in the 'fully on' state, the transistor does not dissipate enough power to overheat easily. This is one reason we should design our switching circuits so they use only these end states of saturation and cut-off.  In this way, the transistor has the least effect on the rest of the circuit. It has the least voltage drop across it and exhibits the least internal resistance.

       Ok, how do we wire up a transistor circuit?  Take a look at the next drawing. The first circuit in the upper left shows a general-purpose single battery circuit. By setting certain resistors in the first circuit to either zero or infinity, you generate the other configurations, all of which function, but with slightly altered characteristics.


       In figures A, B & C, resistors R1 and R2 provide a divider network to bias the base at any voltage you desire and thus these circuits may be used for either analog or digital signals. Figures D and E have no direct provision for biasing the transistor at the cut-off point and will thus be commonly used for analog amplification. Bear in mind, however, that the off biasing could come from the previous stage, so the use of these circuits for digital (switching) applications is still quite feasible. Finally, figure F is set to directly receive its base biasing from the previous stage. You might use this simple design as an output driver coming from a microcontroller, for instance. R3 then serves only for current limiting and the microcontroller provides the on and off signal.

       In all of these, the "load resistors" could be actual resistors, relays, lights, servos, buzzers, LED and resistor, load transformers, or any number of other things, as long as they limit the current to within the capabilities of the transistor and other components.


A refresher on designing a transistor switching stage:  (I will presume this will be a common emitter switch, since those are the most commonly used.)

Step 1) Take the load you have to drive and figure out what voltage you will need to drive it. (Most things will have a stated maximum voltage rating that you will not exceed.)

Step 2) Knowing the resistance of the load and the voltage, you can calculate the current needed.

Step 3) Since you are turning the load on or off with a transistor, the load current will pass through the transistor as well.

Step 4) Locate a transistor that will handle that much collector current in continuous duty. (If the listing says "Absolute Maximum Ratings" or words like that, those are usually PULSE values, NOT continuous. There should be a listing that says Continuous Collector Current.

Step 5) Pick the circuit design you are going to use. (Let us presume you elected to build a circuit like figure C above.)

Step 6) Since your load to be switched will be in the collector circuit, the current will pass through the emitter resistor (Re) as well. Make that resistor no more than one-tenth the resistance of your load. For the sake of example, if the load is 1000 ohms, the Re should be no more than 100 ohms (so we will use that in this example). It will only be in the circuit to hold the emitter a little off ground to provide more positive switching action.

Step 7) Now the step that is confusing to many people; deciding how much current must flow at the base to switch your load fully on and fully off. Most transistors need 1/10th the base current that is being switched in the collector-emitter loop, and sometimes as much as 1/8th. How to figure this out is to ignore the beta or Hfe gain and look at the saturation values. There will usually be two entries on most spec sheets; one for collector-emitter at saturation (VCEsat) and one for base-emitter at saturation (VBEsat). On those lines you will find the collector current (Ic) and the base current (Ib) that was needed to produce it. Like I say, usually it is a 1:10 ratio, but these lines will answer the question.

Step 8) R1 and R2 will act as a divider to set the base voltage. By rule of thumb they will be designed to carry ten times the current needed at the base. If the gain at saturation was 10, the base will need 1/10th the current switched through to the load. Now if R1 & R2 are going to carry 10 times the current needed at the base, then they will be carrying the same current as collector to load. Calculate what their combined resistance will be.

Step 9) Next you will figure out what part of that combined resistance belongs to R1 and the leftover will be the resistance of R2 (or vice versa). To do this we must figure the base voltage.

          Back to our example above, Rload was 1000 ohms (1K) and we picked Re to be 100 ohms.

          Let us say we were using a 12-volt battery. The C-E drop (collector-emitter) for a 2N3904

          (The transistor used in the drawing) at saturation is 0.3 volts.  That leaves 11.7 volts and

          Rload + Re is 1100 ohms. ~10.6 mA will flow through this path and the voltage at the

          emitter equals 100 ohms x 0.0106 amps = ~1.06 volts. The base will be 0.6 volts

          higher than that (or 1.66 volts) to switch on the transistor. If R1 + R2 = 1100 ohms

          the current is the same 10.6 mA and the voltage across R2 must be 1.66 volts.

Step 10) Now that we know the base voltage, we can calculate the resistors R1 & R2.

          1.66 v. / .0106 A. = ~157 ohms for R2, leaving 1100-157=943 for R1.

          Now remember the rule of thumb value does not have to be exact, so let us try and

          find two common resistor values that preserve the same ratio. 943 to 157 is almost

          exactly 6 to 1... or 12 to 2...   1200 ohms and 200 ohms is the same ratio and is

          "close enough". The current will still be several times the base-emitter current needed.

          So we now have R1 = 1200 ohms (1K2) and R2 = 200 ohms.


       Wiring up a circuit with all these values will give us a working circuit. If the input is 'Low' the load will be switched off (because the transistor will not conduct if the base is below 1.66 volts) and a 'High' at the input will switch the load on.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Can you explain (again?) why we want a resistor between emitter and ground when doing switching?

As far as I can figure out it will just raise the need for base voltage when sinking a heavy load in the collector.

If we wire the emitter directly to the ground, as in D and F, the base will be around 0.7v all the time, and the drop across the base resistor will be constant too.

Many loads do not draw a constant current, at least not the inductive ones we tend to use here on LMR. And if the load varies, the drop over the emitter resistor will too, and then the base voltage will too, and then the base current will too, if we use a fixed base resistor and a fixed drive voltage.

Or am I completely misunderstanding my transistors now?

Sure. In figures D and F there is no emitter resistor as it will be used in circuits where you do not have to have one.

       In this example, I picked the circuit design I did to show a case where you DO need an emitter resistor. What the emitter resistor adds to the circuit is a more positive switching action. It is easier to put the transistor into cutoff. I picked the design I did to show a case where this is important.

       To wit: Depending on the type of circuit driving the input, the voltage outputs for high or low can have different values. Some circuits may not put out a definite 'low' signal that is below 0.6* volts and the transistor will stay on (and therefore the load stays energised). By adding the emitter resistor it effectively raises the point at which the stage can be switched off. With the emitter resistor present, an input of a volt or even higher will still be considered a "low". (In the example above any signal coming in below 1.66 volts will be interpreted as a logic low.)

       *(Side note about the base-emitter voltage: even though I put 0.6 volts, different silicon transistors will typically fall in the 0.6 to 0.7 volt range, while germanium transistors fall in the 0.2 to 0.3 volt range.)

       This can be important if the input level cannot be assured as always being below 0.6 volts to switch off the transistor. I am guessing you are thinking of examples where the input comes right from a logic circuit or a standard on/off switch, but there are other possibilities. For example, what if either R1 or R2 were a light dependant resistor?  The voltage at base can be a wide range of values depending on available light. Use of the emitter resistor can help you define the cut-off point so it is in the range of inputs you can expect.


       The resistor Re is not needed only if the input signal is guaranteed to always be below 0.6 volts for a low. (In which case you could make your transistor switch according to figure D or F instead, leaving off the need of an emitter resistor.)

       As to loads that draw different currents, you want to design your circuit for the maximum current your load will draw. For instance if you are designing a motor driver, you should plan for the transistor to provide enough current to supply a motor under heavy load (such as a 'stall' condition). The load is inductive meaning the actual load is not a pure resistance but an inductive reactance combined with the physical resistance of the coil wire. Since the transistor is a current device it doesn't care if the load is inductive, capacitive or pure resistance; it just regulates the current flow through the load, so the load can still be represented as a resistance (shown as Rload), albeit one that fluctuates in value.

       [ In a small line-follower robot, you could easily have this combination of an LDR on the input and driving a low-current DC motor directly.]