Shop OBEX P1 Docs P2 Docs Learn Events
How to use transistor as relay? — Parallax Forums

How to use transistor as relay?

RubyRuby Posts: 35
edited 2012-01-19 11:14 in Propeller 1
Hi , i want to use transistor 2n2222 as a relay. But the thing is i only want to close circuit. Instead of pressing a button just sending signals by parallel port. So I wired the base to the pin from parallel port , emitter to the ground and collector to the wire which has to be 0 V. I mean without Vcc or let's say Vcc=0 V. Is it ok? I tried it and works , but gets hot!
Ps: First i didn't put resistor to the base. Is it because of that or am i missing something?
Thanks.

Comments

  • LeonLeon Posts: 7,620
    edited 2012-01-16 14:09
    You should have a resistor in the base connection, otherwise you will get a lot of base-emitter current. It depends on the transistor, but you could try 200 ohms. How much current is it controlling?
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-01-16 15:02
    Datasheet for the transistor is here http://www.next.gr/components-datasheets/2N2222.pdf

    Max collector current is 600mA but for a small signal transistor a more usual number is 100mA. How much current are you switching?

    The useful number on that datasheet is the hFE which is the gain. Scroll down for a graph of the gain, but ballpark it is about 100. So you put 1mA into the base and it switches 100mA.

    Then you can work out a base resistor value. V=IR and V is 3.3V, I is 0.001 so R could be something like 3.3k.

    If you are switching higher loads than 100mA there are many other options, eg the ULN2003 (and family) where you get 7 darlington transistors in one package and can switch 500mA per transistor http://www.jaycar.com.au/images_uploaded/ULN2003.PDF
  • JonnyMacJonnyMac Posts: 9,198
    edited 2012-01-16 17:22
    Then you can work out a base resistor value. V=IR and V is 3.3V, I is 0.001 so R could be something like 3.3k.

    Remember, you'll want to subract the base-emitter voltage (for an NPN) first:

    base_resistor = (3.3 -Vbe) / base_current
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-01-16 17:30
    Good point JonnyMac.

    So redoing that calc comes up with a 2.7k resistor.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-16 18:54
    Also remember that hFE can range all over the place for a given transistor model. If the specs give a minimum value, use that in your computations, since "typical" values should never be relied upon for circuit design.

    -Phil
  • shimniokshimniok Posts: 177
    edited 2012-01-17 01:11
    In addition to keeping the current below max specs, you want to make sure the BJT is in saturation to keep the heat down.

    What I've done in recent experiments (based on what I remember from school & read about in my old text):

    Determine the desired current through the load (and into the collector) when it's on, then calculate current for the base using hfe with Ib = hfe*Ic ; that's the Ib for the threshold of saturation. To drive the transistor into for-sure saturation, now multiple the resulting base current by some fudge factor to account for hfe variances, etc. Seems 10x comes to mind. To pick the resistor, use ohm's law, given the V feeding the base and the Vbe drop (approximately 0.6V IIRC) and the desired base current.

    If you need more than 500-600mA there are TO92 transistors out there that do it. The one I ran across was the ZTX649/749 from Zetex which can do 2A continuous.

    Btw, if there's a load to be switched, place it between Vcc and the collector. Tie emitter to ground. The above assumes NPN since you mentioned a 2N2222.

    HTH.
  • Mark_TMark_T Posts: 1,981
    edited 2012-01-17 11:22
    Also remember that hFE can range all over the place for a given transistor model. If the specs give a minimum value, use that in your computations, since "typical" values should never be relied upon for circuit design.

    -Phil

    If you want to switch a load, then you need to put the transistor into _saturation_, so I would say take the minimum value for hFE and halve it before doing the calculations - that way you'll be putting at least 2x the minimum current into the base which will guarantee saturation (where the voltage across the transistor is properly low).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-17 11:40
    Better yet, just ignore the hFE and look for a chart such as Figure 4 in this datasheet:

    This gives you the saturation voltage for various combinations of gate current and load current.

    BTW, I assume that when you refer to a "2N2222" that you really mean a "PN2222", which is more common than the metal-can version.

    -Phil
  • shimniokshimniok Posts: 177
    edited 2012-01-19 06:56
    Good tip on the chart. Didn't know about the 2N2222 being in TO18's; I could swear all my devices marked 2N2222 (A or not) are in TO92 cases. I'll have to go check 'em now.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-01-19 11:14
    Well the "Official" 2N222A and the complementary 2N2907 are in metal TO-18 packages.
    The same chip can be put in a plastic TO-92 package and should be called PN2222A / PN2907A with less performance.
    Basically the metal hermetically sealed package can dissipate considerably more power.

    Sure, there may be some venders that put 2N2222A transistors in a plastic package and mus-label them but this would be wrong.
    Just saying! Buyer be ware.

    Duane
Sign In or Register to comment.