Shop OBEX P1 Docs P2 Docs Learn Events
firing a npn problem. — Parallax Forums

firing a npn problem.

Jayguy5000Jayguy5000 Posts: 139
edited 2008-04-01 16:36 in BASIC Stamp
I have a npn transistor I am trying to get wired back up to work correctly. It USED to work with this schematic but Now I am having problems getting it work. The LED Is in correctly and working. I tested that small portion of the circuit. When I say I tested that portion of the circuit I mean I took the wire that connects the collector to the one end of the coil and took it out of the collector and straight to ground. That put 5vdc across the coil and 5vdc through the relay and the LED lit up! after I connect that wire back to the collector I get nothing. My goal is to get this to make the ground connection on a larger relay. The Resistors I am using are yellow violet brown. As you can see The collector goes across the coil of the larger relay connecting ground to 5VDC and making the larger relay work! Like I said this used to work great and now it doesn't..I Hope I have said everything you need to know to answer this question! If not ask away.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.

Post Edited (Jayguy5000) : 3/30/2008 11:50:54 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-30 23:54
    I guess I don't really understand what you're trying to accomplish. You have a transistor (NPN according to you) connected to turn on a relay. The base lead will provide something on the order of 10mA (using Ohms' Law I = E / R = 5V / 470 Ohms). If the transistor's gain is around 20, the collector current will be on the order of 20 x 10mA = 200mA which might be enough to turn on the relay. That's information you might have. I assume the LED is the dot in the upper right of the drawing and you've got it set to turn on (with about 10mA of forward current) when the +5V power is applied to the circuit.

    It would be helpful to know the gain (hFE) of the transistor and the "pull in" current and resistance of the relay coil.

    Post Edited (Mike Green) : 3/31/2008 12:02:54 AM GMT
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 00:02
    ok what I am trying to do is put 5vdc through a larger relay to run something, testing with LED for now. The way to get the relay to turn on or off is by putting 5vdc accross the coil. I could use the bs2 to do it but thats pushing the limits of the bs2, safer to do it this way! the way I am putting 5vdc accross the coil is by constantly having the 5 volts already on the coil and just turning the ground on or off by means of the npn. When I send 5 volts through the resistor and into the base it should trigger the transistor to short out the emitter and collector. That would take the ground straight across the coil of the relay. IT HAS worked before! I have the same crumpled up schematic....which is why I think I had to modify something last time and didn't modify the schematic. Do you see anything wrong in the schematic as to why this wouldn't work? on the transistor it says on the first line N636 second line 2N and bottom line says 5961. I tried turning the transistor around reversing the E and C but got nothing..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-31 00:14
    You have a 470ohm resistor between +5 and Ground (which does nothing.)

    You do not have/show a free-wheeling (protection) diode across the relay.· That makes me think that your transistor is kaput.

    See attached drawing.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 00:15
    The transistor (2N5961) is only designed to switch up to 100mA. Do a Google search for the device number (2N5961) and look at the datasheet. The gain is high (100+) so that's not a problem. Maybe you burnt out the transistor. You do need a diode connected in reverse across the relay coil to protect the transistor (and the Stamp eventually) from the "back EMF" of the relay coil. Any switching or power diode will work (like the 1N4001).

    There's a couple of pages in the "Industrial Design" tutorial from Parallax's Stamps in Class Downloads page that cover this. It's around page 90. Have a look.
  • robots42robots42 Posts: 27
    edited 2008-03-31 00:27
    Your diagram is confusing so I am not sure about the 'it worked once'.
    However the attached will work better.

    The 1N4001 diode across the relay coil helps to stop interference and damage to the transistor when the transistor turns off. Without it the transistor may no longer work!
    the base resistor would be better at 4700ohm ie 4K7 yellow violet red.
    The BS2 is unlikely to be able to supply or sink enough current to turn on the relay.
    A 2N5961 has a maximum collector current of 50mA, most relays take more than this so you have probably blown the transistor.
    A 2N5961 has a minimum gain of 150 so the gain isn't a problem, the current capability is.
    Go buy a transistor with at least 200mA max collector current which should be enough but check the coil current of the relay.

    David
    640 x 480 - 15K
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 00:31
    maybe the transistor is bad, I dont know how to check to see. I think I should be putting ground through the transistor instead of 5 volts. I will try to use a different transistor...a new one. How do I connect a diode to that circuit? just as it looks? that would mean (on my breadboard) that the diode plugs into the same holes as the coil probes and the wires from the transistor and 5volts...understand? what diode should I use?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.

    Post Edited (Jayguy5000) : 3/31/2008 12:36:10 AM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-31 00:38
    Right, the diode shares the points/contacts the relay is connected to; the striped lead goes to +V, the other lead goes to the collector.

    A 1N4001 is good, a 1N400-anything will work.

    Post Edit -- I believe that "we" were working with you on this about this time last year.
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 00:46
    haha I know! I was looking up the old conversations about this but then I had questions and had to ask. I was thinking to myself, I wonder if any one will remember this or look me up and see I asked already, then I thought "naw no one would possibly remember" did you remember or look it up? I assume the 1n400# is a diode? The transistor I am using is a good one then I assume?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
  • robots42robots42 Posts: 27
    edited 2008-03-31 00:47
    to check the transistor put a LED and a 470 ohm resistor in series in place of the relay coil in my diagram, you don't need the diode. If you can switch the LED on and off with the transistor then the transistor is OK.
    The diode is a 1N4001 (1 amp diode) as it says on the diagram, I use them all the time, you could use a 1N914 or a 1N4148 diode or similar instead, just make sure it has the band at the 5v end otherwise it will fry and stop working. It normally doesn't conduct, but when the transistor turns off, the decaying magnetic field in the relay coil creates a reverse high voltage in the coil. One end is connected to 5v and the other end connected to the transistor can go several hundred volts positive, ie above 5v. The 2N5961 is only rated for 60v and the higher voltage will destroy it. The diode shorts out this high voltage to 5v so the collector of the transistor never gets more than 1 diode drop, about 0.7v, above the 5v line.
    David
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 02:02
    You do want to use the 470 Ohm resistor (not the 4.7K resistor robots42 suggested). This will provide around 10mA base drive as I said. A Stamp can easily furnish this and, if you have a low gain transistor, the 10mA will give enough drive to saturate the transistor so it conducts enough current to turn on the relay. You still didn't mention how much current the relay takes. The transistor should be rated for about twice that.
  • robots42robots42 Posts: 27
    edited 2008-03-31 08:38
    What Mike says about the base resistor is wrong.
    And the sort of small current low gain transistors needing 10mA base current haven't been around since manufacturers rejects were sold in hobby stores over 30 years ago.
    These days low current (less than 1amp) transistors don't have gains of less than 100 (ok there may be one, but don't use it) and most have minimum gains of ~300 to 1000, with the average gain of a type being about twice the minimum.

    To find out the base resistor required is very simple.
    Take the 2N5961 as an example (Data from Towers International Transistor Selector)
    If the maximum collector current for the transistor is 50mA
    and the minimum gain is 150
    then then the maximum base current required to fully turn it on is 50mA/150 = 1/3 mA =333uA
    If the base resistor is connected to 5V either by a switch or the Stamp then the voltage across the base resistor
    will be 5V-Vbe , ie about 5v-0.7v (for a silicon transistor), ie about 4.3V.
    4.3V at 333uA equates to 4.3V/(1/3)uA = 4.3*3 Kohm = 12.9 Kohm

    So using a 4K7 base resistor will allow just over twice the required current to saturate the transistor, which covers resistor tolerances, and less than 5V being delivered from an output pin etc.

    So what is wrong with putting more current into the base?
    It ends up as heat and damages/destroys the transistor that is what.
    Try connecting the base directly to 5V while holding the transistor, it may get hot but it will die.
    Using a 470ohm base resistor will give about 20 times as much current as needed!

    A 1N4001 diode is rates at 1amp, try putting 20amp through it and see what happens, it will probably go FzzzzCRAcK and fall apart.
    So go ahead, destroy your transistors if you want, but don't blame me.

    David
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 14:41
    well there seems to be a disagreement here between you two. I still havn't gotten this circuit to work! The relay works when I connect 5volts and ground to the coil,,,the led lights up. When I connect the ground back through the transistor, which is now a 2222, I get nothing.I am using a yellow - violet - red resistor between the 5vdc and the base (middle pin) ground is connected to the Emitter and the collector goes to the coil, other end of the coil has a constant 5vdc on it. When I connect the diode across the coil with the band on the 5 volt side I can not get the relay to work The way I would as i described at the beginning of this message...I tried switching the diode around and still nothing. The relay CAN be controlled by the bs2 but it uses so much current it stresses the stamp which is why I want to use a transistor to connect ground to the coil of the relay, saves the stamp. The specs on the relay are; voltage - vdc, coil resistance - 250 Ohms, contact rating - 0.5A at 125VAC, nominal current - 20Ma. I have used the stamp to turn this on and off but prefer not to do continue doing so. how can I run a test circuit with just the transistor to turn on a LED? I would like to connect a resistor to a I/o Pin and that into a transistor to trigger it, then connect ground and 5 volts to the E and C. Should work right?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 14:57
    The Stamp I/O pin can handle a 20mA load indefinitely as long as you don't have more than two of them on at the same time on a group of I/O pins (P0-P7 or P8-P15). This does not stress the Stamp. You still need the diode across the relay coil with the band connected to the +5V side.
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 15:02
    ok but I need to use lots of these relays! not just 2. how can I connect the 2222 to the stamp to turn the LED on and off? I am playing with it now and cant get it to light up! I am taking a 4700 Ohm resistor from Vss to Base, Emitter to Vdd Collector to cathode (LED) and anode to 470 Ohm and then that resistor is connected to Vss.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 15:11
    Please use PJ Allen's diagram shown earlier in this thread. With the relay you mentioned, you could use a 4700 Ohm resistor instead of the 220 Ohm one shown in the diagram.

    If you connect the free end of the 4700 Ohm resistor to ground, the transistor will be off. If you connect the free end to +5V, the transistor will turn on. If you can't get it to work, then you've not wired it according to the diagram or the transistor is bad (unlikely).

    Post Edited (Mike Green) : 3/31/2008 3:17:08 PM GMT
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 15:30
    you seem to have given up on acknowledging I am typing anything! I have tried (and just now again tried) pj allens schematic with both resistors. I dont think the transistor is switching over.. HOW CAN I TEST THE TRANSISTOR WITH A LED??? I dont want to use the relay I just want to use the transistor to turn the LED on and off. Does it matter if I use the Vss or I/o pin? any difference there? I dont htink so but i want to ask.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.

    Post Edited (Jayguy5000) : 3/31/2008 3:36:16 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-31 15:36
    ACK, ACK, ACK

    Just want to emphasize that it's not my circuit, it's Parallax's, and I agree with it.

    Use an LED in series with a 1K resistor in place of the relay coil.
  • robots42robots42 Posts: 27
    edited 2008-03-31 16:20
    We have told you a lot of times how to test the transistor with a LED, so don't shout. More information is in Parallax's workbooks which are free to download, and there is lots of information for beginners elsewhere on the web. Lots of beginners manage this without any trouble. So one final thing, have you correctly identified the leads of the transistors? Integrated circuit pin-outs are viewed from the component side of the PCB whereas transistor pin-outs are viewed looking on the pins so when you are plugging transistors into a breadboard you have to mirror the diagram although getting this wrong generally doesn't make much difference! Strangely enough if you swap Collector and Emitter not much changes, all the transistors I have tried this have still worked with the leads reversed but just not as well.
    Do everything one step at a time and double check everything, including the continuity of your breadboard.
    If you do it according to the circuits we have given you it will work.

    David
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2008-03-31 16:28
    Another thing you may want to check is the polarity of the LED when it is installed. If it is plugged in backwards it will not work. Can you double check the LED to make sure it is ok? Make sure you always have some sort of current limiting resistor inline with the LED. If not and you connect the LED directly across the battery you'll turn it to toast pretty quick.

    If the LED is troublesome then try a small flashlight bulb since polarity doesn't matter so much.

    Good Luck,

    Robert
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-03-31 16:36
    sorry to capitolize that, shouldn't have shouted, Im just getting really frustrated with all of this simple stuff not working. I can turn the LED on and off so yes its in right. I just cant turn it on and off with the 2222. If I understand correctly When I put a certain voltage into the Base of the transistor it should connect the E and C. I cant get it to work...still foolin around with it, who knows maybe it will work, I live in MD if any one is around, lol.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
  • Dave-WDave-W Posts: 94
    edited 2008-04-01 01:02
    Jay,

    I would be willing to bet you have the Emitter and Base reversed. Don't forget, there are several pinouts for the 2N2222. Some are E-B-C and some are B-E-C and maybe B-C-E. So double check your pinout for that particular device from the manufactures spec sheet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D. A. Wreski
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-01 14:11
    Dave,

    I’ve never seen multiple pin-outs for the 2N2222, however I have seen many datasheets that show the pin layout from the bottom view, which I think confuses some people.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2008-04-01 14:17
    well PJ Allen got me straightend out! I had the Vss and Vdd backwards. So now That I know where Ground is (lol) It works...now read my next question, what did I break.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Actually I think Im going to add the whiskers to my tank and let it roam, just need to figure out where.
  • robots42robots42 Posts: 27
    edited 2008-04-01 16:36
    Since it must be 20 years ago since I was testing transistors plugged in backwards I thought I would just check.

    Using a trusty (I can remember the pinout) BC109 npn
    emitter to 0v
    220R in series with a red LED from 5v to collector
    with a 4k7 base resistor to 5v
    the LED lights. (as it should)
    Swapping emitter and collector (ie plugging in the BC109 backwards) makes no apparent difference to the LED brightness and the LED can be switched off as before by disconnecting the base from 5v.
    Exactly the same with a BC549 (plastic BC109)


    Doing the same with a 2N3906 pnp (emitter to 5v, LEd to 0v, base resistor to 0v), when plugged in backwards the LED is dimmer.

    David
Sign In or Register to comment.