2
\$\begingroup\$

I'm applying a 3.3V signal with my Raspberry Pi to the base of an NPN transistor to activate a SPDT 6V relay (relay data sheet, model G2R-1-S-DC6(S)). The relay pickup/dropoff voltage is 4.4/0.9V. The transistor activates the circuit like it should when the signal is applied, but it does not turn off when the signal is removed.

The relay coil resistance is 68.7 ohms, as shown in the simulation. The 161 ohm resistor was added to dissipate some power because the transistor is rated for 600 mW. When adding the emitter resistance, I calculated that it needed to be under 40.7 ohms. I used a 33 ohm because that is what I had on hand. The 24Vdc supply is used here because it is what is available in the system. I am using a 2N2222 transistor from Radio Shack with a Beta=200. The 3.3V ground and 24V ground were tied together when the circuit was constructed.

I've experimented with adding a resistor from base to ground; I tried this with 10k, 33k, and 100k resistances. I have tried a diode in parallel with the relay pointing up. I used a new transistor every time I tried a new circuit to ensure the transistor was not burned up from the previous test. I also tried multiple different combinations of Rb and Rc with the same result. The strange part is, when experimenting with Rc values, the Beta calculated from test measurements ranged from 50-500, which is very odd. In all trials, the current through the relay was as calculated in the simulation; it did not change upon application and after removal of the signal.

I saw another post where someone used a small capacitor in parallel with Rb to sweep voltage off the base emitter, we also tried this but it didn't work (link - it is the third diagram from the top).

Any advice will be will be greatly appreciated.

Simulation of Circuit with no Signal

Simulation of circuit with 3.3V Signal

\$\endgroup\$
  • 1
    \$\begingroup\$ How about this. Use your setup to turn on the relay. Then try to turn it off. Now measure the voltage across the relay coil. That should tell you if you're having transistor problems. My thought is that you're somehow not releasing your control voltage, even though you think you are. \$\endgroup\$ – WhatRoughBeast Apr 20 '14 at 4:01
  • \$\begingroup\$ Are you sure that you have the 2N2222 pins correctly figured out? Does the 2N2222 shut off the current when you connect the base to ground? (ie: detached from the RPi?). FWIW, I would say it's really ill-advised to use a 24V supply for experimentation of this kind when you only need 6V. One false move and your Pi will be baked. Also, when switching a load, there's no need for the emitter resistor, it just complicates your experiment. (But you DO need a base resistor, as I think you've figured.) \$\endgroup\$ – gwideman Apr 20 '14 at 4:02
  • \$\begingroup\$ Also, reviews at radio shack for the "NPN Transistors (15-Pack) 276-1617" suggest that it is sometimes mispackaged and contains PNP transistors instead. Hope that didn't happen to you. \$\endgroup\$ – gwideman Apr 20 '14 at 4:06
  • \$\begingroup\$ Also the "upward pointing diode" across the relay is necessary for protection. Not having that will allow the relay coil to produce a pulse of high voltage when switching off, which will fry the transistor. So include that always. Should be a power diode something like a 1N4001, 2, 3, 4 (or schottky), not a 1N4148 or 1N914 signal diode. \$\endgroup\$ – gwideman Apr 20 '14 at 4:12
  • \$\begingroup\$ You should change the 161 ohm resistor to about 210 ohms, so it will drop 3/4 of the 24 volts, leaving 6 volts for the relay when it is on. The emitter resistor is not required. From your figures, the transistor is turning off correctly, but you might want to reduce the base resistor so the transistor saturates when on (but removing the emitter resistor may take care of that). \$\endgroup\$ – Peter Bennett Apr 20 '14 at 4:52
4
\$\begingroup\$

Add a fly-back diode.

When switching the current off, a coil will reduce the voltage until something starts to conduct so it can continue to let the current flow, as long as it has magnetic energy inside. Sadly, the conductive path is provided by your transistor -- after it was fried.

That negative pulse can reach thousands of volts. Seriously!

\$\endgroup\$
4
\$\begingroup\$

The relay won't turn off anymore because the first time you tried to turn it off, the flyback voltage generated by the relay coil blew out the transistor so that it is now permanently shorted between collector and emitter.

The common way to deal with this is to put a diode accross the relay coil in reverse. It is oriented so that it does not conduct when the relay is being powered on. When the relay switches off, the diode provides a safe path for the flyback current from the coil, until that eventually dissipates due to the forward drop of the diode and the resistance of the coil.

The rest of your circuit also has problems. Having both a emitter and base resistor makes no sense. Since you have way more voltage available than necessary, I'd use the transistor in current sink configuration. Connect the base directly to the digital output, and put the appropriate resistor between the emitter and ground for the relay current. Now the relay will always see that current when on, regardless of the supply voltage. Higher than necessary supply voltage will cause more dissipation in the transitor, so a resitor in series with the relay does make sense.

\$\endgroup\$
  • \$\begingroup\$ I would 2nd that. \$\endgroup\$ – dannyf Mar 8 '17 at 21:55
  • \$\begingroup\$ @Olin: Just curious, what effect does it have on the current sinking of the Transistor, if the resistor is placed between emitter & ground, vs when it's placed, between Relay and Collector (with the emitter connected directly to ground). Also, why this should be preferred if we have way-more voltage than is needed by our load. \$\endgroup\$ – Vishal Sep 8 '17 at 10:39
0
\$\begingroup\$

Additionally to the aforementioned suggestions, your design doesn't provide enough current for the coil. Your description shows Ic=65,71mA, according with the specifications of your relay the coil needs 87mA in DC mode for the SPDT at 6V. You needs 20mA more. If the relays are not driven with the current according the manufacturer specifications often they works erratically. I recommend you to use a Darlinton transistor configuration to drive your relays. It is the usual way to do this ( for example using the ULN2803A ICs to drive several relays).The Darlington can switch more current than with the collector-emitter design. enter image description here

\$\endgroup\$
  • \$\begingroup\$ Your answer makes no sense. He said the relay is turning on, just that it can't be turned off afterwards. If there was too little current thru the coil, it wouldn't ever turn on in the first place, and that wouldn't explain at all why it can't be turned off. \$\endgroup\$ – Olin Lathrop Apr 21 '14 at 19:51
  • \$\begingroup\$ I agree with you Olin, probably he has not placed a diode across the coil connection. Any case if he place the diode, his design will not work properly according the relay specification, my comment still valid. ( I have modified the text). \$\endgroup\$ – Alf Apr 21 '14 at 20:13
  • \$\begingroup\$ Unfortunately, we didn't have time to work with the transistor design to get it to work. We were able to get the relay working with a MOSFET, we had sunk too much time into the transistor design. Thanks anyway for all of your answers, we at least know that it wasn't a simple mistake. \$\endgroup\$ – Andrew Wellmeyer Apr 22 '14 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.