How to calculate the PNP transistor base resistor?

Thread Starter

akke

Joined Dec 17, 2015
77
I need to drive a LED from a 3.3v GPIO pin (arduino).
I want to use the BC857BS (double) transistor for this purpose because I accidentally have many of them, coming from a wrong order.

The transistor will be powered from a 5V source. The LED's datasheet shows it needs 1.25v and 20ma current.

I calculated R8 to be 188 Ohm so I chose 200 Ohm as closest match.
I did some calculations for R9 too, and came at 26K. But I'm not sure how to correctly calculate it.

R26 will be connected to the GPIO pin (3.3v, not 5v!).

Please have a look at the attached schematic.

Thanks for your time!
 

Attachments

Last edited by a moderator:

MrAl

Joined Jun 17, 2014
10,881
Hi,

The simplest way is to use the approximate Beta to calculate the base current knowing the emitter current and the emitter voltage.
You can know the emitter current because that is what you are setting it for.
You can calculate the emitter voltage knowing the emitter current, and add the base emitter voltage. Subtract that from the input voltage then use Ohm's Law to calculate the base resistor value knowing the base current has to be the emitter current divided by the Beta, as an approximation.

Using the transistor as a constant current source is better though.
 

Papabravo

Joined Feb 24, 2006
20,589
If you want 20 mA through the LED then you should plan on setting the base current to 10% of that amount or 2 mA. If the base current is 2 mA and the base is at (5V - 0.7V) = 4.3 V, then the other side of the resistor should be at (nearly) ground potential. Let us say that it will be at 0.2V. So:

\( \cfrac{(4.3\text{ V}-0.2\text{ V})}{2\text{ mA}}\;=\;2050\text{ }\Omega \)

You still need to make sure that whatever is driving the transistor can sink 2 ma of current. If not, then additional components may be required. For example, a 74LVC1G04 for example.

https://www.ti.com/lit/ds/symlink/s...h%3Dsearch-everything%26usecase%3Dpartmatches
 

sghioto

Joined Dec 31, 2017
5,079
I need to drive a LED from a 3.3v GPIO pin (arduino).
The transistor will be powered from a 5V source. The LED's datasheet shows it needs 1.25v and 20ma current.
Problem is when the GPIO is at 3.3 volts the PNP transistor will still be conducting somewhat without reverse bias with the emitter at 5 volts.
Why not use the 3.3 volt supply
 

Papabravo

Joined Feb 24, 2006
20,589
The 74LVC1G04 can be powered by +5V and it will see a logic '1' from your 3.3V output high from the processor. This may be marginal in practice.

There are also devices that have specifically TTL thresholds that can be used to interface 3.3V and 5V systems with each other. As an alternative consider 74VHC1GT50

https://www.onsemi.com/pdf/datasheet/mc74vhc1g50-d.pdf
 
Last edited:

sghioto

Joined Dec 31, 2017
5,079
A GPIO can deliver 20ma generally. Going by the 10% rule add a 1K resistor R10 for reverse bias. This will turn OFF the transistor when the GPIO is at 3.3 volts.
1692382841722.png
 

Thread Starter

akke

Joined Dec 17, 2015
77
The arduino in question will be an MKR WIFI 1010. According to the specs:
DC Current per I/O Pin7 mA
 

Thread Starter

akke

Joined Dec 17, 2015
77
Problem is when the GPIO is at 3.3 volts the PNP transistor will still be conducting somewhat without reverse bias with the emitter at 5 volts.
Why not use the 3.3 volt supply
The arduino has an onboard 3.3V regulator that should indeed be capable of driving some leds.
So 3.3V is an option too.
 

sghioto

Joined Dec 31, 2017
5,079
The arduino has an onboard 3.3V regulator that should indeed be capable of driving some leds.
So 3.3V is an option too.
Yes. IN that case remove R10, set R9 at 10K and R8 to 100 ohms. Measure the voltage on the collector, should be near 3.3 volts when the LED is ON.
 
Last edited:

MrAl

Joined Jun 17, 2014
10,881
Another idea.
D1 only needed if the LED still has a faint glow when Vin=3.3 volts.

Just to note though, you can make a much cleaner design using an NPN transistor like 2N2222 or 2N4401. These little transistors are not expensive at all.
Transistor_Led-2.png
 
Last edited:
Top