Electronic – arduino – Need help calculating resistance for transistor base

arduinocurrentrelayresistorstransistors

I have 3 12VDC/40A automotive relays (datasheet) that I want to use with my Arduino.
Based on the tutorial I am following (link) I need transistor, resistor, and diode. I am not an electrical engineer therefore I am unsure about the parts and calculations I made.

For the start, relay coil resistance is 90+-10% Ohm per datasheet. So I proceed by calculating the current flow.

Voltage=Resistance*Current

Current=Voltage/Resistance

Current=12V/90

Ohm Current = 133mA

For the transistor I can get 2N3904 or 2N4401. At this point I have to calculate resistance for the base of transistor. In tutorial its as following

hfe = Ic / Ib

Ib = Ic / hfe

Ib = 0.03 A / 75 Ib = 0.0004 A => 0.4 mA

R1 = U / Ib

R1 = 5V / 0.0004 A

R1 = 12500 Ohm

2N3904 datasheet states the H(fe) is 30-300 when lc = 100mA (mine is 130mA) and Vce = 1V. At this point I have no clue what is going on, thus I need help.

Edit:
Here is what I ended up with. RLY1 in the picture is 12VDC/40A (link)

enter image description here

Best Answer

Let's design for worst case, that is a good practice.

\$Ic = 133\text{mA}\$

\$h_{FE} = 30\$ # according to the datasheet minimum 30, typically much better; @Ic=100mA

You can calculate Ib now:

\$I_b = \dfrac{I_c}{h_{FE}} = \dfrac{133\text{mA}}{30} = 4.43\text{mA}\$

\$V_{BE,SAT} = 0.95\$ # datasheet, nearest match is 50mA. Maximum value, practical value is probably much lower (0.65V)

Now let's calculate the base series resistance. This is equal to the voltage across the resistor, divided by the current through it. The current through the resistor is the same as the base current. The voltage across it is the rail voltage (5V) decreased by the base-to-emitter voltage of the transistor V(CE,sat).

\$R_B = \dfrac{U_{R_b}}{I_b} = \dfrac{V_{CC} - V_{BE}}{I_B} = \dfrac{5 - 0.95}{4.43/1000} = 913\Omega\$

With all the worst case engineering up to here, for once let's just round it up to the nearest E12 resistor value of 1kΩ (or 820Ω for worst case engineering, it will work with either).

Related Topic