Driving a relay or a High Current Load using a Transistor may sometimes be confusing like, what value of resistor to use to drive the Transistor's Base.
So, heres how i got this to work.
1. Determine which transistor will be suitable.
As shown in Figure Relay rated Voltage = 12Volts,
Relay resistance = 200 ohms
Relay's holding Current = 12v/200 ohms = 60mA
So, we can use BC547 for switching the relay which has Icmax = 100mA and Vcemax = 45V
Switch any load by driving the transistor in Saturation mode will makes sure the load gets its rated current, Holding Current in case the Load is a Relay.
2. How to drive BC547 or any Transistor into Saturation mode:
We want to find the Base Current(Ibase) required to drive bc547 into saturation mode(Ic in this mode will be greater than relay's holding current i.e >60mA)
we cannot calculate Ibase by using beta of bc547, because beta value is varying with Ic and Vce.
So, we can see the Vce(sat) voltage on the datasheet of BC547. There we can find the Ibase(max) of BC547. see the screnshoot of datasheet below.click to see enlarged image.
From the above fig. IC=100mA(max), therefore Ib = 5mA(max).
So BC547 can withstand upto 5mA Base Current
Set Ibase just 10 to 20% lower for safety.(80% of 5mA = 4mA, actually we are Overdriving the transistor just to put it in Saturation mode)
So Rbase(RB) = [5V(Logic High From uC)]/4mA
Therefore Rbase(RB) = 1.25kohms ~= 1.2kohms
That’s all ..we are ready to drive a relay. Similarly we can find RB required for any Transistor.