Calulating BJT base resistance for PIC led switching?


Closed Thread
Results 1 to 12 of 12
  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Default Calulating BJT base resistance for PIC led switching?

    Hi,

    Hoping this is not too off topic.
    I need my PIC to switch an ultrabright led.

    Using a BC182L general purpose NPN transistor from futurlec
    (http://www.futurlec.com/Transistors/BC182L.shtml)
    and an ultrabright led from futurlec
    (http://www.futurlec.com/LED/LED5YULB.shtml)

    I need to use a BASE resistor for my BJT.

    I'm using the ultrabright led at 2.4V 20mA with a 9V power supply, so I will be using a 330 ohms limiter resistor (9V-2.4V/0.02A)
    Then I've checked the web to find clues to calculate RB for the BJT but there are parameters I don't understand.

    according to
    http://www.kpsec.freeuk.com/trancirc.htm
    I should calculate the RB value with a pretty simple formula but when I have to find the Ic for the load, I'm stuck. How can I determine the right load resistance? Does it mean the total resistance of the current limiter for the led AND the resistance of the led? If so how can I calculate the resistance?
    I did not find the value of the led resistance in the specs of the led.
    Maybe using:
    U=R*I -> R = 2.4V/0.02A = 120 ohms?
    Then I should add the 330 ohms of the led current limiting resistor to have the Ic value using: 9V/.450Kohms = 20 mA?
    If so, then the RB should be (if HFE min is 100 and PIC supply is 5V):
    (5V*100)/(5*0.02A) = 5KOhms

    Am I right?
    Thanks for any hints...


    PS: I should add some voltage drop value somewhere for the transistor?


    In the same idea, I also have to switch an LM555 times but I don't know what value I should consider as the LM555 (the 'load') current and resistance...
    Last edited by xnihilo; - 10th November 2008 at 13:16.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Connect your NPN transistor with the emitter to ground then you can calculate the resistor in this way:

    R = (Vin - 0.7)/Ib

    Where:
    Vin = pic output (5 v)
    0.7 = base/emitter diode threshold
    Ib = desired base current ( 2mA is what you need for saturating 20 mA load)

    Nearest value = 2,2 K

    LM555 can be connected directly to 9 V PS and the output (pin 3) can drain your 20 mA load without any problem. So you can connect your led + 330 ohms directly to the IC.

    Al.
    Last edited by aratti; - 10th November 2008 at 17:37.
    All progress began with an idea

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Ok, i'm a poor teacher, but i think the following may help.
    <hr>
    You need to know the Hfe parameter of your BJT(gain). Here at 20mA, the minimum you may have should be 80.

    To make sure you saturate it properly, some will divide the Hfe parameter by 2, some by 5, and some others by 10.

    Let's use 5, so we have Hfe=16
    <hr>
    The base current is the Collector current/Hfe = 20/16 = 1.65 mA

    Assuming your PIC may give 5V at it's output, the base resistor will be
    (5-Vbe)/1.65mA = (5-0.7)/1.65mA = 2.606 K...

    anything in this range or lower will work.

    HTH
    Last edited by mister_e; - 10th November 2008 at 17:45.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Connect your NPN transistor with the emitter to ground then you can calculate the resistor in this way:

    R = (Vin - 0.7)/Ib

    Where:
    Vin = pic output (5 v)
    0.7 = base/emitter diode threshold
    Ib = desired base current ( 2mA is what you need for saturating 20 mA load)

    Nearest value = 2,2 K

    LM555 can be connected directly to 9 V PS and the output (pin 3) can drain your 20 mA load without any problem. So you can connect your led + 330 ohms directly to the IC.

    Al.
    Thank you but I beleive there has been a misunderstanding of my post:
    The LM555 is not driving any led, I'm using a BJT for switching a led (with its current limiter because I use 9V) and another BJT for switching an LM555.
    One pin of the pic is activating the first BJT to switch on the led and another pin is activating the second BJT to trigger the LM555 that will then switch a relay.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Why not using the LM555 @9V directly?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    You need to know the Hfe parameter of your BJT(gain).

    -> BC182L has a HFE(min) of 100.

    Here at 20mA, the minimum you may have should be 80.

    -> Why 20mA? Because it is the desired current for the load (led used with 9V supply and a 330 ohms current limiter resistor to have 2.4V 20mA)?

    To make sure you saturate it properly, some will divide the Hfe parameter by 2, some by 5, and some others by 10.

    -> Why? Is this empirical?

    Let's use 5, so we have Hfe=16

    -> Hm, yes, but why divide it by 5?

    The base current is the Collector current/Hfe = 20/16 = 1.65 mA

    -> This is the current needed at the BASE to saturate and switch the BJT then?

    Assuming your PIC may give 5V at it's output,

    -> Right

    the base resistor will be
    (5-Vbe)/1.65mA = (5-0.7)/1.65mA = 2.606 K...

    anything in this range or lower will work.

    -> The formulas I found on the web are more complicated and I don't find the same values... ???

  7. #7
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Why not using the LM555 @9V directly?
    Well, because I use it to activate a 5V relay that lets current flow straight from the 9V battery through a nichrome wire to heat it... I don't know exactly what amount of current passes through the relay but is is certainly more than the 200mA that the LM555 can source.

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Have a look at the right datasheet
    http://www.classiccmp.org/rtellason/...ata/bc182l.pdf

    Here at 20mA, the minimum you may have should be 80.

    -> Why 20mA? Because it is the desired current for the load ?
    Yes

    To make sure you saturate it properly, some will divide the Hfe parameter by 2, some by 5, and some others by 10.

    -> Why? Is this empirical?
    good question

    Let's use 5, so we have Hfe=16

    -> Hm, yes, but why divide it by 5?
    I believe dividing by 5 is usually safe enough, while dividing by 10 is much safe... well we drive LEDs, not big current, no big deal.

    The base current is the Collector current/Hfe = 20/16 = 1.65 mA

    -> This is the current needed at the BASE to saturate and switch the BJT then?
    Yes

    the base resistor will be
    (5-Vbe)/1.65mA = (5-0.7)/1.65mA = 2.606 K...

    anything in this range or lower will work.

    -> The formulas I found on the web are more complicated and I don't find the same values... ???
    What was your result? I use a simple method, proven to work along the years. For switching, there's no real big deal, on/off, that's it. It's an whole different story in, let's say, amplifiers, smal signal etc etc.

    Have I said I'm a bad teacher
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile The right values for BJT base resistor?

    I have made calculations for my several uses of BC182L general purpose NPN BJT. Would you mind and have a look at these so you can tell me if I'm right or wrong. Well, this is definately off topic but as I started it here, I would like to finish it here too
    (In fact, maybe I should use a mosfet instead of BJT to save the hassle of calculating the base resistors...)

    CASE 1:
    normal red led driven by pic
    I need 2V, 15mA, driven by 5V from PIC
    I will need 200 Ohms current limiter (5-2/0.015) between led and PIC.

    CASE 2:
    ultrabright led supplied by 9V battery, controled by a BJT (BC182L, HFE(min) = 80) driven by PIC (5V)
    Current limiter to get 2.1V 20mA with 9V => (9-2.1/0.02) = 345 Ohms
    Then for the Base current limiter I will have: 80/5 = 16 => 20/16, 5-0.7/1.25 = 3.44 KOhms resistor or less

    CASE 3:
    infrared led supplied by 9V battery, controled by a MOSFET (IRLD110) driven by pic (5V)
    Current limiter to get 1.4V 250mA: 9-1.4/0.25 = 30.4 Ohms

    CASE 4:
    One Pic pin controls a BJT (BC182L) to pull to GND a pin of another PIC.
    The pins of the two pic are connected via a 1K resistor, so current between pics will be 5/1000=5mA
    5/16 = 0.3125, 5-0.7/0.3125 = 13.76K resistor or less to be used as base current limiter

    CASE 5:
    LCD backlight controled by pic (5V) via a BJT (BC182L). Backlight need 5V 70mA.
    70/16 = 4.375, 5-0.7/4.375 = 0.98K or less to be used as base current limiter.

    CASE 6:
    A 5V, 30mA relay controled by a pic (5V) via a BJT (BC182L).
    30/16 = 1.875, 5-0.7/1.875=2.29K or less to be used as a base current limiter

    CASE 7:
    A PIC (5V) is used to pull to GND the TRIGGER pin of a LM555 via a 1K current limiter (so we will have 5V, 5mA) and a BJT (BC182L).
    5/16 = 0.3125, 5-0.7/0.3125 = 13.76K resistor or less to be used as base current limiter

    I wonder if all this is fine now or what...

  10. #10
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile mister_e ?

    Hello,

    Do you think my calculations in my previous post of RB when bjt is used with 2 pics is right?

    Do you think i should use some mosfet instead to stop bothering about bjt RB? Then i need logic level fets for my pics at 5v, like irld110 but they are more expensive...

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    let's see..
    CASE 1:
    normal red led driven by pic
    I need 2V, 15mA, driven by 5V from PIC
    I will need 200 Ohms current limiter (5-2/0.015) between led and PIC.
    OK

    CASE 2:
    ultrabright led supplied by 9V battery, controled by a BJT (BC182L, HFE(min) = 80) driven by PIC (5V)
    Current limiter to get 2.1V 20mA with 9V => (9-2.1/0.02) = 345 Ohms
    Then for the Base current limiter I will have: 80/5 = 16 => 20/16, 5-0.7/1.25 = 3.44 KOhms resistor or less
    OK!

    CASE 3:
    infrared led supplied by 9V battery, controled by a MOSFET (IRLD110) driven by pic (5V)
    Current limiter to get 1.4V 250mA: 9-1.4/0.25 = 30.4 Ohms
    Right too... BUT
    P=I*I*R = 250mA*250mA * 30.4 = ~2Watt
    sometime it's nice to place some led in serie to drop the current a little and avoid to brown your PCB... nice to heat an enclosure though

    CASE 4:
    One Pic pin controls a BJT (BC182L) to pull to GND a pin of another PIC.
    The pins of the two pic are connected via a 1K resistor, so current between pics will be 5/1000=5mA
    5/16 = 0.3125, 5-0.7/0.3125 = 13.76K resistor or less to be used as base current limiter
    OK
    CASE 5:
    LCD backlight controled by pic (5V) via a BJT (BC182L). Backlight need 5V 70mA.
    70/16 = 4.375, 5-0.7/4.375 = 0.98K or less to be used as base current limiter.
    OK

    CASE 6:
    A 5V, 30mA relay controled by a pic (5V) via a BJT (BC182L).
    30/16 = 1.875, 5-0.7/1.875=2.29K or less to be used as a base current limiter
    OK
    CASE 7:
    A PIC (5V) is used to pull to GND the TRIGGER pin of a LM555 via a 1K current limiter (so we will have 5V, 5mA) and a BJT (BC182L).
    5/16 = 0.3125, 5-0.7/0.3125 = 13.76K resistor or less to be used as base current limiter
    OK

    Sounds like you understood correctly what i said... easy huh?
    Last edited by mister_e; - 19th November 2008 at 21:36.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile

    Right too... BUT
    P=I*I*R = 250mA*250mA * 30.4 = ~2Watt

    -> Don't worry, it is a PWM output with max 2400 us bursts at 30% duty cycle. I'm using a 1W resistor even if i would need about 2W.

    Sounds like you understood correctly what i said...

    -> I guess so
    Seems you are a good teacher. Thanks a lot!

    About mosfets, i can as well replace bjt by logic level mosfets. I can get irl that can pass a few A.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 07:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 05:59
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 21:19
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03:30
  5. can't even flash an LED
    By bruno333 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2005, 14:27

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts