Transistor as switch

Flummoxed... again.

I had a circuit which worked fine for months. Put it on a PCB... it worked... briefly... then, I think, the transistor died. Of course, my "translation" to PCB could have involved mistakes... don't think so, though, and I THINK things WERE working... for a little while.

... is relevant sub-circuit. At the moment, the (failed?) transistor always conducts, the relay coil is always energized. The LED goes on and off as it should. I'm driving the sub-circuit with D13, but from a ModernDevice RBBB, which doesn't have an on-board LED on D13.

Anyone see anything "wrong" in that circuit? I've done a bunch of troubleshooting... the relay IS working, for instance, doesn't have "frozen" contacts. (If you know about these things, but when you look at the circuit you can't see anything wrong, that information would cheer me greatly, even if it won't fix my problem!)

A word of explanation... R2 and the capacitor are there to prevent the transistor from switching on unless there is a sustained "high" from the output of the Arduino. R2: 2k2, C1: 1000 uF. (The relay unlocks my front door, and when there's a power cycle, before R2/C1 were added, a brief high on D13 during the Arduino's reset opened the door!)

The transistor is a BC549. Thus there is an error in the diagram above, which shows a PNP wheras I'm using an NPN... I think... (I'm not very good on transistors! I AM using a BC549!)

The Arduino output (driving the base of the transistor, after R2) is usually low... from time to time it is brought high for about 3 seconds, during which time the relay coil should be (and was!) energized.

===
While writing... I put the above circuit together "by guess and by gosh", and it seemed to work. I'm using the same components as were in the breadboard in the PCB.

Design question: When things stopped working, I had a sudden panic... when the output from the Arduino goes low after having been high, it is connected, through the 2k2 resistor, to a "source" of up to 5v... the charge stored in the capacitor. When I calmed down, I told myself that was okay. Is it? Assuming, for simplicity's sake (Is an "okay" assumption for my purpose, which is to see if the circuit is okay?) that no current flows away through the base of the transistor, I think that when the output goes low, for as long as it takes to discharge the capacitor, current will flow into the output. But I think R2 limits that current flow to about 2.5mA, right?(I called R2 2k for the sake of the calculation)... so all well?

===
So! Having given away most of my ignorance, I will be watching this thread with bated breath for advice from you all!

===

If nothing jumps out at you in the above, maybe the following will unveil my mistake/ problem...

a) The transistor MAY have got a bit hot during soldering... Not "terribly" so, but I didn't treat it with GREAT care...

b) I tested the circuit in various ways... probably ran it with the relay not inserted, for instance. (But would never have run it with a coil present, but no snubbing diode... I don't think THAT explains things.)

c) I don't recall doing all the calculations regarding the power dissipation capabilities of the transistor. But the relay is "just a little guy", and the transistor has coped for months with the current which flows.

d) I've checked, and checked again, the orientation of the transistor in the circuit... I don't think it is in "upside down". The middle pin is the base. Anyone know what the circuit would do if the transistor WAS in 180 degrees wrong?

e) I don't see why it should matter... but obviously that may be true of whatever is making my relay stay on all the time!... but maybe I should mention that the voltage which energizes the relay (V-RLY) is also being used to supply the voltage regulator producing the 5v the ARduino is running on.

===
Why did I try to "go tidy"??? The breadboarded version was a mess... but it worked!!! Sigh.

===
Supplemental questions...

Thinking about all this gave rise to another dreadful thought....

Can the relatively high voltage from V-RLY travel "upstream" through the base of the transistor to reach the output of the Arduino, which should not, of course, ever "see" more than 5v? Or can I think of the base as incorporating a diode which would block such flow. Would the base of a PNP transistor in the same circuit also be a barrier to more-than-5v "above" the transistor? (Yes... I do realise that if V-RLY was something really high, the barrier (which I hope is) at the base would break down.)

C1 is going to really really slow down the switching of the transistor, this may have caused it to fail through over-dissipation (a switching transistor only works efficiently if hard on or hard off - you want to minimize the time it takes to switch).

If the transistor is off the current will be of the order of microamps, so no problem with dissipation. If the transistor is on and saturated it will have only 0.15V or similar across it at the relay's operating current - shouldn't cause a problem at currents below an amp.

If the transistor is half on for a prolonged period of time it will have both a large voltage and large current - so the power dissipation might be
over the safe limit... Normally this would only be the case for a microsecond or less, but C1 has stretched that to more like a second giving time for the die's temperature to rise a lot.

[ The BC549 is rated at absolute maximum of 100mA and 500mW - its not really a switching transistor (they normally take 500mA or more) ]

The reason the device was operating the relay on reset was the use of D13. Any pin from D2 to D12 would have avoided this issue, but D13 is pulsed when the bootloader runs at reset.

Except, that transistor on schematic PNP ( BC549 is NPN) , and collector - emitter swap,
I'd recommend to insert a small resistor between a capacitor and base, 100 Ohm let say.
I've seen in my practice, that when you disconnect collector (turn of a switch) and capacitor is fully charged, it will kill base-emitter junction of the transistor.

Very helpful, very clear... thank you everyone.

Ironic that I "chose" the one data line unsuitable for my purposes... I could have used any line, but went with that one as true Arduinos have the LED on it, and I thought that would be convenient for some users! That idiosyncratic "pulse on reset" is a nasty little "gotcha"... I'm pleased to know about it for the future!

Hi,

I am looking to do almost exactly the above.

OK - one small change, my access will be controlled by web request on the local network (this is to an external door for a shed that doesn't contain too much of value - and should allow access to anyone who is allowed on my home wifi)

Irrespective, I have a similar setup (Arduino, Strike Plate etc) - but have seen some schematics simply using a transistor - no relay - like so: http://i.imgur.com/tChKv.png

However the consensus is that the relay on the transistor is a better approach (as above and in the following) :


I have built a few Arduino projects - pretty much all lightweight (rf / ir transmit and receive, a few web handlers etc) - my grounding is coding, not electronics.

I haven't done anything with a second, more powerful power connection for fear of bruning the house down .. .

anyway, I have 3 questions

  1. Could the relay in your example (and the near identical example http://i.stack.imgur.com/sg1kM.png) be replaced by an OptoCoupler like :
    https://www.sparkfun.com/products/314

  2. Assuming that it can, I am guessing that the diode D1 is not required?

  3. My strike plate arrived WITH a diode? I assume this is to protect the power supply that will deliver 12V - and simply goes straight accross the 2 sides of the strike plate as per external example? I don;t actually understand what it is doing though - and without it in the diagram, I surely would have forgotten it. Your diagram above also does not show this snubber diode - is it implied?

A corrente que sai do arduino é de 40mA, verifique se a corrente que está chegando ao transistor está mantendo o ganho alto.