In my project I'm using GSM module for controlling the AC operated devices using cell phone. For this purpose I'm using following components:

Controller : ATMEGA32A

GSM module : SIM800C

Relay : 5VDC coil, 230V/7A Goodsky make

Transistor used for switching : 2N3904

Freewheel diode : 1N5819

Power IC: LM2596,adj

I have designed the circuit so that base current should be 8.4mA in the saturation mode. Overall circuit works on 4VDC(Pull in voltage for relay is 3.75V). The circuit worked fine. But after some time around 8-10 months some modules fail because of transistor failure. All the other components are perfectly fine. I have not included any resistor between base to emitter is this the issue for transistor failure.

Thanks for suggestion but as per datasheet maximum allowed dissipation is 625mW which is enough considering the voltage and current levels at which the circuit is operating. Also I had thought of boosting the supply voltage but GSM controller works till 4.2V only so I dropped out that idea.

This leaves too little voltage for the relay and consequently possible high dissipation on the transistor.

I'm not sure I follow your thinking?

Agreed this is a marginal design, and obviously is failing in the field, but it isn't clear yet why it is failing.

My data sheet gives a Vce(sat) at Ic = 50 mA of 0.2 V.

With a 4.0 V supply, that leaves 3.8 V across the relay, with the NPN in saturation.

OP states that the pull in voltage for the relay is 3.75 V.

That is why this is a marginal design, there is very little margin to insure that the relay will pull in.

It isn't stated whether the 3.75 V pull in voltage is a guaranteed minimum value, or simply what the OP measured on one device on the bench.

The circuit doesn't show the power supply, but if this this a battery operated device, then one might expect the Vsupply to drop over time, and the small leeway in the relay drive might well result in some relays not being turned on.

That said, the steady state power dissipation of the relay is determined solely by its coil resistance, (70 ohms).

Not fully driving the relay on won't, (I think), change the energy dissipated by the NPN transistor.

The NPN will be adequately driven into saturation mode, (as desired), with a reasonable logic level high signal, and it's energy dissipation is independent of whether or not the relay is actually fully, mechanically, turned on or not.

The 2N3904 has a Ic max of 200 mA, and the relay should draw < 60 mA when on.

I'll let someone else do the Thermal calculations on the transistor to see if it is well within spec if operated for a sustained period of time without a heat sink, in room air.

Thermal calc's aren't my strong point...

Overheating the transistor and thermal run away, would, however, be one potential source of failure.

Additionally, it would be worth looking at the micro's logic low voltage, and making sure that the transistor is not partially turned on when one thinks that it is fully off.

In this case the NPN would be operating in its linear range, partially on, not enough to turn on the relay, but enough to dissipate energy within the transistor.

Again, worth checking it's thermal safety factor without a heat sink, and making sure that it is actually fully off when expected to be so.

As KAS already mentioned, a small NFet might be a better choice for driving a small relay these days, and it would provide a better margin for insuring that the relay is turned on.

It would still be reasonable, however, to check the above and perhaps some other factors to try to definitively determine the reason for the in-field failures.

Relays tend to need a high pull-in current and a smaller hold current.
If you don't get a positive pull-in, you risk arcing on the relay contacts.
.
If you can buy your relay with a (higher current) 3.3V coil, you can be confident that the relay will operate reliably.
Then you can switch out some of the coil current because the hold requirement is smaller.
.
Personally I would be happier with solid-state switching instead of a relay. But a relay is more appropriate for high voltage or isolated loads.
.
David.

It isn't stated whether the 3.75 V pull in voltage is a guaranteed minimum value, or simply what the OP measured on one device on the bench.

As per relay datasheet attached minimum pull in voltage required is 75%(i.e 3.75V minimum) of DC rated coil voltage. With the given components there is no issue in switching relay at all.

DocJC wrote:

The circuit doesn't show the power supply, but if this this a battery operated device

Device is AC powered so this is not the issue.

DocJC wrote:

Additionally, it would be worth looking at the micro's logic low voltage, and making sure that the transistor is not partially turned on when one thinks that it is fully off.

As per atmega32a datasheet at logic low output can be as high as 0.7V which might result in power dissipation as transistor might be in active region. A strong pull down resistor around 1k from base to emitter(GND) can ensure complete cutoff, please correct me if I'm wrong here.

I also checked N-FET but was unable to find the one with given constraint of Vds<=200mV at Id>=70mA.

Can anyone guide me for the power dissipation calculation in partially cutoff region?

I strongly advise using a 3V coil. This would ensure that the relay will pull-in reliably.
A 4V supply is unwise for a 5V coil.
Note that you can reduce the current for hold.
.
From memory, the 2N3904 does not have a high hFE but you are supplying 10mA base current. So the transistor will definitely be saturated.
If the base current is coming from push-pull output from the AVR, it should switch off safely.
You can easily test to destruction. Compare MTBF for 1N5819 or zener.
.
David.

"N-FET but was unable to find the one with given constraint of Vds<=200mV at Id>=70mA."

IIRC most custom LED torch drivers use mosfets that meet the criteria: operating from single LiIon, low "on" resistance, low voltage gate control. Not sure about packages though, since majority of these come in SMD.

On the other hand, 3V relay, as David advised, and freshly selected (preferably "digital") BJT shall do.

when you start up ,the atmel cpu will be in pull up state before you are init the io

I think Thierry likely identified the problem, and hence the solution.

How exactly?

AVR power-up default state for GPIO is high-impedance input, no pull-up. A BJT is a current-based device, not a voltage-based device like a MOSFET. With an unititialised and floating GPIO pin, no current will flow through the BE junction, so the BJT will remain completely off, even without an external pull-down.

We haven't seen any code. Perhaps the OP is manipulating DDRxn instead of PORTxn. If so, then this would leave the pull-up enabled, resulting in some current flowing through BE.

How much current? Assuming a minimum VBE of 0.5V, a minimum pull-up of 20K, and VCC=4V, IBE would be (4 - 0.5) / (20000 + 330) = 3.5 / 20330 = 172uA. Max hFE is about 150, so that IBE translates to an ICE of about 25.8mA.

With VCC=4V and a 70R relay coil, that amounts to a VCE of ((4 / 0.0258) - 70) * 0.0258 = 2.2V, and a dissipated power of 2.2 * 0.0258 = 56.6 mW. Well within device limits. The junction temperature will rise no higher than ambient + 11°C, with case temperature no higher than ambient + 5°C.

You can wiggle all of the numbers I propose above (RPULLUP, VCC, VBE, hFE, etc.) and never arrive at a dissipation outside the capabilities of the device.

I don't see this as a the source of the problem, whether or not the OP is wiggling DDRxn instead of PORTxn.

I would prefer to put a scope on the collector to see if the protection diode is actually doing its job.

EDIT: Switched arithmetic to use worst-case values.

EDIT2: In fact, we can calculate worst case dissipation in the transistor for a given load R, which will happen when VCE = VLOAD (the proof is left as an exercise for the reader). With VCC = 4V, that's VCE = VLOAD = 2V. With RLOAD = 70, then ILOAD = 2 / 70 = 28.57mA, and so also ICE = 28.57mA, and dissipation PCE = VCE * ICE = 57.14mW. Even if we throw worst-case PBE (which will never be coincident with worst-case PCE), that's just (4-0.5)2 / 330 = 37.12mW, for a total of 94.26mW, and junction temperature will be no more than ambient + 19°C. Well within safety limits for the device.

EDIT3: Errors in arithmetic.

"Experience is what enables you to recognise a mistake the second time you make it."

noise or leak current are enough to set the transistor in bad situation.

I have see this a lot of time.

With a BJT? I doubt it. And as I've shown there is no way the OP's circuit (VCC=4V and a 70R relay coil) could exceed the current, power, or thermal limits of a 2N3904.

If the base is getting hit with high voltages due to EMI, ESD, or other source, then surely the AVR's GPIO pin would fry long before a sturdy BJT.

That said, a pull-down can be handy to speed the turning off of a transistor, but that won't help the OP, he's using it as a steady state switch. Were this a PWM application, yes you could drive the transistor into shutdown more rapidly with a pull-down or by grounding the base, thereby reducing dissipation, but dissipation is almost certainly not the OP's problem.

"Experience is what enables you to recognise a mistake the second time you make it."