Calulating BJT base resistance for PIC led switching?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    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 16:37.
    All progress began with an idea

  2. #2
    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.

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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...

  7. #7
    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...

  8. #8
    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... ???

Similar Threads

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

Members who have read this thread : 0

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