How to choose the base resistor value for the BJT in a LED on/off circuit? - Page 1
Forum section: electronics / beginners

author: Aakash
author_rank: Contributor
timestamp: December 03, 2021, 08:21:33 pm
content: Can anybody explain, how do I set the value of resistor R1 here? why 1k is chosen specifically?

author: Zero999
author_rank: Super Contributor
timestamp: December 03, 2021, 08:26:36 pm
content: The transistor needs sufficient base drive to saturate, i.e. turn hard on. A general rule of thumb is the base current should be about1/10of the collector current, hence why the base resistor is around ten times the value, of the LED's current limiting resistor.

author: rstofer
author_rank: Super Contributor
timestamp: December 03, 2021, 08:46:34 pm
content: Compute the collector current as Vcc - VceSat - 2V (assumed LED forward voltage) / 100 Ohms = (5 - 0.2 - 2) / 100 = 28 mAUsing the 1/10 current idea, calculate the base resistor as (Vcc - 0.7) / 0.0028 = 1536 Ohms so a 1K resistor will easily pump enough current into the base.Now it's your turn: build the circuit on a breadboard and measure the currents/voltages and see if my math comes close.

author: Aakash
author_rank: Contributor
timestamp: December 03, 2021, 09:56:20 pm
content: Appreciate your response, but may I know why does the base current need to be 1/10th of the collector current. what if it's different?

author: Zero999
author_rank: Super Contributor
timestamp: December 03, 2021, 10:27:41 pm
content: Quote from: Aakash on December 03, 2021, 09:56:20 pmIt's a general rule of thumb. The base current required to saturate a transistor varies greatly. It varies with the temperature and from one part to another, even if they have the same part number. Here's a link to an explanation I gave in another thread, to save me repeating it.https://www.eevblog.com/forum/beginners/please-look-at-schematic-to-drive-24v-relay-with-arduino/msg3728989/#msg3728989

author: srb1954
author_rank: Super Contributor
timestamp: December 04, 2021, 06:44:04 am
content: Quote from: Aakash on December 03, 2021, 09:56:20 pmThe base current is set to that value to ensure that the transistor is saturated i.e. the transistor is fully turned on and there is minimal voltage drop (Vcesat) across the collector to emitter. If the base current is lower than the 1/10 ratio the Vcesatvoltage will be a little higher and there will be more power dissipated in the transistor when switched on.Having the base current at 1/10th of the collector current is the industry standard (usually denoted as Ic/Ib = 10) and ensures saturated operation even if a transistor is at the low end of its current gain (HFE) range. In datasheets manufacturers generally specify the performance of their BJTs when operating in the saturated state using this Ic/Ib = 10 ratio. However, there are some exceptions, particularly for higher current or higher voltage devices, where the Ic/Ib ratio may be specified as low as 5.

author: mariush
author_rank: Super Contributor
timestamp: December 04, 2021, 07:37:10 am
content: I've found this video tutorial to explain well how to choose a base resistor and why you should use oneYou can replace the solenoid with your led or any other device that consumes power.Just keep in mind that you also need to limit the current going through the led using a resistor or a led driver, if your transistor is gonna be fully on it will pretty much not limit the current going through it, so your led could break without a resistor or something limiting the current.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: December 04, 2021, 10:15:18 am
content: That the base current should be 10% of the collector current is a very brainless assumption. There is no "industry standard" for this.Small signal transistors can have a **guaranteed** Hfe (current amplification factor) greater then 500 while it can be around 10 (or even lower for some very old) power transistors.Hfe is also dependent on current and temperature, but for a lot of small transistors it's safe to work with a minimum Hfe of 100 in your calculations. But a better answer is that if you have to ask, then you would be better off learning more about BJT's. Start by reading some tutorials (video's) and ammend that with some real experimentation and verification on a breadboard and real parts.

author: CaptDon
author_rank: Super Contributor
timestamp: December 04, 2021, 02:24:49 pm
content: Maybe you should buy a book, even an online book and Learn about transistors and transistor circuits? Have you ever heard of HFE? The measurement of current gain? You would if you take the time to read about transistor circuits. That transistor may have an HFE of 100 which means the collector current under certain conditions will be 100 times the base current. This is important when designing linear amplifiers and class A and B amplifiers. In your case they choose 10% of expected collector current and any transistor with an HFE of 20 to 100 or more will 'Plug and play' in the circuit. Why was 1k chosen? Suppose the 'drive voltage' was different? Asking one question about one resistor is only scratching the surface. Read about the hows and whys of transistor circuits and start designing your own circuits.

author: rstofer
author_rank: Super Contributor
timestamp: December 04, 2021, 04:43:46 pm
content: Look at the datasheet for the 2N2222A and under "On Characteristics" "DC Current Gain" look at the range of hFE(current gain). At very light loads it can be as low as 35 and at high loads it could be as high as 300. Even at 10 mA (and we're talking about 20 mA), the gain could be as low as 35 (at a very cold -55 degrees C) up to 75.ETA: I guess I should mention that collector current is equal to hFE* base current. The whole discussion is meaningless without this definition.Gain is all over the map and while 1/10 base current is overkill, it is used fairly often. Remember, we assumed the driving voltage was 5V but what if the driving device can't quite reach 5V? There are logic families where the output voltage is somewhat less than Vcc. Our circuit still has to work regardless of what the driving device is doing and regardless of which gain 'bin' our transistor came from.While you're at it, look at VCE(sat)I assumed 0.2V and the datasheet says a max of 0.3V but they don't specify a 'typical' value.Then look at VBE(sat)- I assumed 0.7V but the real value could go as high as 1.2V and that changes the calculation substantially.Don't like 10% base current? No problem! Pick a different number. But what you can't do is design a circuit that is dependent on selecting transistors on the basis of gain from a box of parts. What if you happened to grab a 2N3904 - no, I haven't looked at the difference, I just assumed a 2N2222A for this discussion.https://www.onsemi.com/pdf/datasheet/p2n2222a-d.pdfSince we're only talking about 20 mA of collector current and 2 mA of base current (maybe), the 1/10 thing works pretty well. Even if all the parameters stack against the design, the base current will probably be adequate.The only thing that really matters is how the circuit performs with real numbers. I used 2V for Vf of the LED - it could be as high as 3V at 20 mA according to this typical LED datasheet. Look under "Forward Voltage".https://www.vishay.com/docs/83171/tlur640.pdfUnderstand that every single number I used was a guess. But there's a reason that datasheets have a lot of numbers. Oddly, under different circumstances, every single number on the datasheet is important.As I said earlier, build the circuit on a breadboard. Measure Vbe, Ib(measure drop across the base resistor and calculate - measure the resistor first so you have the real number), measure Ic (measure drop across the collector resistor and calculate) and, most important, measure Vce(sat)by probing between collector and emitter. Is the transistor saturated?Measure Vin so you can see what the driving circuit is doing. If this is coming from a uC, use an output pin to drive the base resistor.Having completed this experiment, you will understand why we commonly guess at 1/10. It's a guess that is known to work more often than not and when you're talking about 2 mA, it probably doesn't matter unless you are using really wimpy batteries. Then you are probably wasting energy but think about it: you are wasting 10 times as much lighting up the LED. Pulse it slowly 1/10 on and 9/10 off - this will reduce the energy consumption dramatically.

author: rstofer
author_rank: Super Contributor
timestamp: December 04, 2021, 05:07:30 pm
content: While you are experimenting, change the collector resistor (increase it) to reduce the LED current from around 20 mA to 10 mA and 5 mA. You may find a collector current that provides adequate indication without wasting a lot of energy. The idea that every LED MUST have 20 mA is nonsense.Experiment! That's how you learn this stuff.Numbers are great fun but the only thing that matters is how the circuit performs.

author: srb1954
author_rank: Super Contributor
timestamp: December 04, 2021, 10:36:26 pm
content: Quote from: Doctorandus_P on December 04, 2021, 10:15:18 amIt is a de facto industry standard in that a great many datasheets specify saturated switching operation at Ic/Ib= 10. A professional design engineer will design a circuit to use the device under conditions as close as possible to the device's specified, and guaranteed, operating conditions to ensure that the highest manufacturing yield is obtained for the product and that it continues to operate reliably under adverse field conditions. A design substantially deviating from the device's datasheet specifications is likely to earn the design engineer enormous scrutiny during the design review process and potentially scathing criticism from senior reviewing engineers.QuoteSmall signal transistors may well have a guaranteed Hfeof greater than 500 but this is the small signal incremental (AC) gain not the DC gain. Also, that guaranteed Hfeof 500 would definitely not have been measured with the transistor in saturation so is completely meaningless for this discussion.In this case the correct parameter to consider is the DC current gain HFEwhich will differ from the Hfe. It should be noted that for the typical BJT the HFEdrops off sharply when the transistor goes into saturation so it is necessary to supply extra base current to maintain the transistor in the saturated state. The common design procedure for ensuring that there is always sufficient base current is to adopt a specified Ic/Ib ratio, typically 10 but maybe up to 20 for smaller transistors or as low as 5 for very large transistors.QuoteThis is bad advice.Assuming a minimum HFE(not Hfe) of 100 will not provide sufficient base current to ensure saturation in many transistors. I have never seen a transistor datasheet that specifies saturated operation at an Ic/Ib ratio of 100 so you can be pretty sure that most transistor manufacturers also don't think that saturated operation at an Ic/Ib ratio of 100 is a good idea.For example, a popular medium current driver transistor is the BC637. This has atypicalHFEthat peaks at around 97 at Vce=2V and Tj=25C. Using this transistor in a circuit at Ic/Ib=100 would ensure that a typical device wouldn't even achieve saturated operation and the situation could be even worse when production spreads of HFEand temperature variations are taken into account.QuoteThis is the only piece of good advice in this post. I would add to it that once you have gained a basic understanding of transistor theory you should read transistor datasheets and understand how real transistors perform and how semiconductor manufacturers specify, test and guarantee those devices.Simulating basic transistor circuits in something like LTCSpice is also very useful for understanding how transistors behave under various conditions. You can very quickly plot the performance of the transistor under numerous operating conditions much easier than trying to hook multiple meters and power supplies to a transistor on a breadboard. However, it is important to remember that the SPICE simulation is based on amathematicalmodel that approximates a typical transistor and usually doesn't incorporate the production spread of parameters seen in real transistors. Ultimately, you are going to have to build your circuit and test its performance with real devices with all their built-in limitations.

author: richard.cs
author_rank: Super Contributor
timestamp: December 05, 2021, 12:29:18 am
content: There are of course other ways to arrange this basic circuit. For instance you could use the transistor as an emitter follower (supply to collector, load to emitter) with no base resistor, and a slightly lower LED resistor, or if you had a lower logic voltage or higher LED supply it might make sense to put the resistor at the emitter and LED at the collector, the transistor then acts as a constant-current sink.The circuit as drawn is normally used with the transistor saturated, minimising the power dissipated in the transistor, but for a low current signal LED the other circuits can also be useful.

author: David Hess
author_rank: Super Contributor
timestamp: December 05, 2021, 12:47:50 am
content: I sometimes use a forced beta of 10, but often 20 or 50 with common small signal transistors. Low noise high gain parts can use a forced beta of 200 or higher, like with a 2N5089 from 0.1 to 10 milliamps, but that is beyond the point of diminishing returns.One advantage of using a part like the 800 milliamp 2N4401 instead of the 200 milliamp 2N3904 is that it has higher gain above 10 milliamps.

author: Vovk_Z
author_rank: Super Contributor
timestamp: December 05, 2021, 05:34:46 am
content: Also we may use small MOSFET like 2N7000 and forget about all those calculations at all.

author: David Hess
author_rank: Super Contributor
timestamp: December 06, 2021, 12:23:50 am
content: Quote from: Vovk_Z on December 05, 2021, 05:34:46 amMany designers prefer MOSFETs for exactly that reason, although they are more expensive. I see 2N3904s for $5.5/100 while 2N7002s are $8.1/100. In the past the price difference was much greater.Amazingly, pre-biased bipolar transistors are available even cheaper at $3.5/100 if you do not want to calculate and pay for an external resistor.

author: jfiresto
author_rank: Frequent Contributor
timestamp: December 06, 2021, 05:04:51 am
content: Quote from: Vovk_Z on December 05, 2021, 05:34:46 amOr perhaps use an emitter follower: transistor, LED resistor and LED?

author: Zero999
author_rank: Super Contributor
timestamp: December 06, 2021, 09:39:17 am
content: Quote from: David Hess on December 05, 2021, 12:47:50 amAt higher currents, the ZTX1149, ZTX689 are good.https://www.diodes.com/assets/Datasheets/ZTX689B.pdfhttps://www.diodes.com/assets/Datasheets/ZTX1149A.pdfQuote from: jfiresto on December 06, 2021, 05:04:51 amThe emitter follower is a good idea, when it's just driving an LED with a series resistor, but you don't get any voltage gain. There's around 0.8V to 1.5V of voltage drop, depending on the current.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 06, 2021, 09:55:47 am
content: For LED switching there is no need to drive the transistor deep into saturation. Nothing really bad happens if the transisotr is not fully saturated. This is somewhat different when driving a larger load, where the transistor may overheat if not saturated, or a relay not reliably switching.For the higher currents MOSFETs got more popular.If power consumption does not matter than a firced beta of 10 is OK, especially at relatively low currents. Modern small transistors can usually get away with less base current. If power consumption matters, one would normally not send 25 mA to a LED unless absolutely needed for really high brightness.

author: tggzzz
author_rank: Super Contributor
timestamp: December 06, 2021, 10:18:28 am
content: Quote from: srb1954 on December 04, 2021, 10:36:26 pmI'll bet that "specification" is merely the ratio at which they test production devices or measure other properties such as VCEsat. There is absolutely no reason why it must be operated at that ratio.Overdriving the base current can lead to other effects that affect the operation of some circuits, although almost certainly not this one.There is no substitute for understanding the device physics. Doctorandus_P is right.

author: David Hess
author_rank: Super Contributor
timestamp: December 06, 2021, 09:14:12 pm
content: Quote from: Zero999 on December 06, 2021, 09:39:17 amThose high gain low saturation bipolar transistors are really neat, but more expensive. I think Zetex invented them, lookup "super e-line", but many companies make them now including On and Fairchild. I wish they were clearly identified.QuoteOr put the resistor in series with the emitter, and drive the emitter or base, so the transistor becomes a constant current sink/source to drive the LED directly and only one resistor is needed.

author: rstofer
author_rank: Super Contributor
timestamp: December 07, 2021, 01:23:51 am
content: I decided to play with the constant current source in LTspice using generic components (LED and Transistor are default values) and the result is 22.7 mA flowing through the LED with a 150 Ohm emitter resistor and 5V on the base and collector.Substituting a 390 Ohm resistor yields 8.8 mA flowing through the LED.asc file attachedIt's a heck of a lot faster to model these circuits than it is to build and instrument them when you just want to test an idea.Code:--- Operating Point ---V(p001):0.735911voltageV(n001):5voltageV(p002):4.14523voltageIc(Q1):0.0225038device_currentIb(Q1):0.000225038device_currentIe(Q1):-0.0227288device_currentI(D1):0.0227288device_current <======I(R1):0.0227288device_currentI(V1):-0.0227288device_current

author: not1xor1
author_rank: Frequent Contributor
timestamp: December 07, 2021, 09:09:34 am
content: the base resistor value in this case is not critical. In the simulated circuit an Ib variation of 0.1-2mA produces a quite small change in Ic and a bit more in Vce-sat.BTW Since most small LEDs do not withstand currents above 20mA it would be better to increase the collector resistor to 330 or even 1000 ohm.

author: Aakash
author_rank: Contributor
timestamp: December 07, 2021, 07:36:44 pm
content: Quote from: not1xor1 on December 07, 2021, 09:09:34 amThank you so much for your response. May I know what simulation software did you use?

author: sairfan1
author_rank: Frequent Contributor
timestamp: December 07, 2021, 10:19:49 pm
content: @Aakash which simulator did you use? is it some free online?

author: rstofer
author_rank: Super Contributor
timestamp: December 07, 2021, 11:10:47 pm
content: I wonder about Vsat in the above simulation, the datasheet doesn't show a value anywhere like 27 mV. Vsat is more typically 0.2V.That's ok, my LED model (the default) is garbage as well. I have to add a simulation model like:.model LED_model D(IS=3e-18 RS=17 N=2)and change the device D on the schematic to LED_model to get a Vf that's anywhere near reasonable. I need to study up on this because it still doesn't quite match a real LED according to a datasheet.That's the cool thing about computers, you can get the wrong answer with certainty and a lot of digits.Simulation will never replace breadboarding.

author: rstofer
author_rank: Super Contributor
timestamp: December 08, 2021, 01:29:13 am
content: Here's a video that describes creating a model for the LED from measured data. The author took MANY samples of voltage and current (indirectly) and used Excel to fit the coefficients of the diode equation.https://youtu.be/EOPV9Zo0IIM?list=PLwqxpnKyoHro6Jf2rhStCHS-DQ6PUimZ_Interesting stuff!

author: not1xor1
author_rank: Frequent Contributor
timestamp: December 08, 2021, 02:43:41 pm
content: Quote from: Aakash on December 07, 2021, 07:36:44 pmLTSPICE

author: not1xor1
author_rank: Frequent Contributor
timestamp: December 08, 2021, 02:52:33 pm
content: Quote from: rstofer on December 07, 2021, 11:10:47 pmaccording to the datasheets of 2 different manufacturers 200mV is maximum Vce-sat at 10mAunfortunately I can't test a real circuit at the moment but it would be easy to check with a breadboardI'm confident that a real circuit won't yield much different values

author: Aakash
author_rank: Contributor
timestamp: December 10, 2021, 07:13:55 pm
content: Quote from: sairfan1 on December 07, 2021, 10:19:49 pmI didn't use any simulator, I just used a circuit screenshot which was available from the internet.

author: ledtester
author_rank: Super Contributor
timestamp: December 10, 2021, 08:02:24 pm
content: Quote from: Aakash on December 10, 2021, 07:13:55 pmThe screenshot in reply #23 looks like LTspice which is a free download from Analog Devices (analog.com).