Connect with us

how to control LED array? (follow-up)

Discussion in 'Electronic Basics' started by Michael Noone, May 28, 2005.

Scroll to continue with content
  1. Hi - this is a follow-up to this thread:


    I've been working on finalizing the design. I've drawn up a schematic in
    Eagle of what I think should work:

    This is essentially identical to what John Fields was suggesting, except
    I've modified some resistor values as I have now chosen LEDs: (3.3v
    forward voltage, 20-30ma typical current)

    The design of this array calls for only one column to be on at any given
    time. The columns are active high, and the rows are active low. The goal
    is to saturate the transistors. The value for R1-R16 was chosen by
    dividing the typical base-emitter saturation voltage by the base
    current, thus 0.85/.015 = 56.67, or about 56 ohms. These values were
    found on page two of both the 2N4401 and 2N4403 datasheets:

    The value for R16-R24 was chosen by taking (V+ - 2*VCesat - Vled)/ILED =
    (5 - 2*0.4 - 3.3)/.03 = .9/.03 = 30 ohms. A current of 30ma was chosen
    because only one led on each row will be on at any given time, and as
    each column will only be on for 1/8 of the time - I feel it is best to
    use the maximum current allowed.

    Oh - lastly, if anyone is curious as to the odd placement of gnd on the
    row connector and +5v on the column connector (as the layout would
    probabaly be nicer the other way around) - I did this as a reminder that
    the rows are active low and the columns are active high.

    So how does everything look? Some of my calculations and final numbers
    differ from the original thread - thus I thought I should check back to
    see if I'm doing something wrong. Thanks so much,

    -Michael J. Noone
  2. Ban

    Ban Guest

    Did Mr. Fields also advise to take these 56 ohms base resistors? They will
    consume more current than the LEDs. You can use 470 ohms for them. with 8mA
    you can drive easily 100mA collector current in case you multiplex. You have
    to calculate the voltage across the resistor, not the transistor. when you
    have 4.5V control signal (typical PIC) and 0.75V Ube, then R= 3.75V/8mA =
    468 ohm. You can even take 1k if you use transistors with beta of 150 or
    Uce sat will be a bit lower than 0.4V, maybe 0.15V, so it is better to use
    47 ohm for 30mA. But if you always multiplex them and the program doesn't
    get stuck with one LED always on, you can probably even put 100mA through
    the LED with a duty cycle of 1/8. It would be better to make a current
    source for the Leds then you do not need these resistors at all and can
    easily adjust the brightness.
  3. Now that I'm looking back - He used different values.
    The idea is that there'd be 15ma going through the 56ohm transistors,
    saturating the transistors. (I believe they're saturated at 15ma?) Did I
    mess up somewhere in my calculation?
    But unless I'm looking at something wrong - that wouldn't saturate the
    transistor, and if it's not saturated my understanding is that you can't
    accurately predict voltage and current through it.
    It will need to be able to drive 240ma - 8*30ma = 240ma. I want to run
    these at max brightness due to the 1/8 duty cycle.
    Oops - you're quite right about that. Not quite sure where my head was
    Oh damn - just realized that Vcesat is not constant - it varies
    depending on collector current. That's no good... I'm not quite sure
    what exactly to do about that as collector current should be anywhere
    between 0 and 240ma - which presents a fairly wide range of Vcesat
    Could you advise on how to make such a current source?


  4. Ban

    Ban Guest

    Michael, in the first place choose different transistors for 240mA current.
    I had a look at the Zetex site and found these for example:
    ZTX1047A Vbe<70mV @1A Ib=10mA
    ZTX1048A Vbe<45mV @0.5A Ib=10mA
    ZTX717 Vbe<17mV @0.1A Ib=10mA
    ZTX788A Vbe<35mV @0.1A Ib=2mA
    You can also get a ready made current source BCR402R, you can switch it off
    putting pin1 high.
    .. It is also possible to make a current source with 2 transistors that can
    be switched by a logic voltage. But I do not draw it now.
  5. Why use different transistors? The 2N4401 and 2N4403 are both rated for
    600ma I believe. Is your worry that they will be dissipating too much
    power? I must admit my use of them is due to them being the ones
    reccomended to me - but also it makes sense to me to use them as they
    are considered to be "classic" transistors.
    I'm looking at the datasheet for the BCR402R, but I must admit I'm a bit
    confused about it. Is the idea of the chip essentially that it outputs
    an amount of current controlled by the size of the resistor between Vs
    and Rext? The datasheet is rather sparse in regards to the effects of
    changing the value of this resistor. Or is the idea that the chip always
    supplies 30ma if it can, and this resistor is used to drop the voltage
    down? The latter of these is what I'm thinking is probabaly the case -
    but I'm just not sure - I mean I think most LEDs run at more like 5-15ma
    - I think 30ma is pretty high for an LED.

    So - what I think you're suggesting is to use these BCR402Rs to drive
    single LEDs at a time, and then use a saturated transistor to handle the
    whole 240ma. Is that right? Also - do you know of any sources for the
    BCR402R? The usual suspects - Digikey, Newark, and Mouser, all don't
    carry it.


  6. John Fields

    John Fields Guest

    If you want to drive the LEDs at 30mA, then the column driver needs to
    pass 240mA with all the LEDs in that column ON.

    For a forced beta of 10, Fairchild spec's the 2N4401 Vbe(sat) at 0.9V
    with about a 300mA load, so the base resistor would be:

    Vcc - Vbe 4.1V
    R = ----------- = -------- ~ 171 ohms
    Ib 0.024A

    Since there's nothing critical about that forced beta and you've got
    an awful lot of gain available, I'd round up to the next standard 5%
    value, which is 180 ohms.

    With about 24mA being pushed through the resistor it'll be

    E² 16.8
    P = --- = ------ ~ 0.09W
    R 180R

    but since you'll be doing 8:1 multiplexing it'll only be dissipating
    1/8 of that, or about 12 milliwatts, so 1/4 watt thru-hole resistors
    will be fine if you're going that route.

    With a collector current of about 300mA, Fairchild spec's Vce(sat) at
    about 0.2V for a 2N4401, so the multiplexed transistors will be

    (Vcc - Vce) Ic 4.8V * 0.24A
    P = ---------------- = -------------- = 0.144 watts
    8 8

    Which the 2N4401s can easily handle.

    Looking at the row drivers; even if you're multiplexing, all the LEDs
    in a row could be on one right after the other, so each of the 2N4403s
    will have to handle a maximum of 30mA of collector current. With 30
    mA of collector current and a forced beta of 10, Fairchild spec's the
    2N4403's Vbe(sat) at about 0.8V, so the resistance of the base
    resistor would be:

    Vcc - Vbe 4.2V
    R = ----------- = -------- = 1400 ohms
    Ib 0.003A

    Then, since we've got a drop across the LED of about 3.3V at 30mA, a
    drop of about 0.05V across the row driver at 30mA, and a drop of about
    0.2V across the column driver at 240mA, the LED's current limiting
    resistor needs to be:

    Vcc - (Vled + Vce1 + Vce2) 1.45V
    R = ---------------------------- = ------- ~ 48.3 ohms
    Iled 0.03A

    With standard 5% values of 47 ohms and 51 ohms available, it might be
    tempting to go for 47 ohms, but in many cases that 30mA current
    specified for white LEDs is the _absolute maximum_, so it would be
    prudent to round up to 51 ohms.

    Also, not knowing what your I/Os look like, I've made the assumption
    that the drive from your µC is rail-to-rail and haven't considered the
    drop which will be encountered when the ports actually have to supply
    current into the row and column driver bases, particularly the column
    drivers, so you may want to rework the numbers with that in mind.
  7. John Fields

    John Fields Guest

    Aarghhh!!! It should be:

    Vce(sat) Ic 0.2V * 0.24A
    P = ------------- = -------------- = 0.006 watt
    8 8
  8. Probably so. Your base resistors are incredibly low-valued.
    You can saturate a BJT with a lot less than 15mA into the base. It
    all depends on the circuit around it and the BJT. Of course, with 56
    ohms, you'd probably be getting more than 15mA, as well.
    You can probably run them with even more than 30mA, given that they
    will only be on for 1/8 duty. You might want to make this an
    adjustable setting so you can change things later on.
    Then design things to work.
    Actually, I don't think you need to worry about controlled current
    sources or sinks. The topology you have is just fine for getting the
    job done. You could try and design something else, but I'd recommend
    getting the design you already have laid out working reasonably well.
    Then, once you understand it well enough, you can always work on
    various improvement ideas later on.

    Let's look at a slightly modified version of your design. I've made
    the PNPs the high-current sources that may need to drive many LEDs at
    once and the NPNs the lower-current sinks that will never need to sink
    more than one LED's current. You can always arrange it the other way,
    of course. Here's a 3X3 design that is expandable to the 8x8 on which
    you appear to be working:

    : Vcc
    : |
    : | Vcc
    : \ |
    : / Ra3 |
    : \ 47k |
    : / |
    : Rb3 | |<e Q3
    : 3---/\/\-+-------------------| PNP
    : |\c
    : |
    : | COL 3
    : +--------------------+--------------------+-- ~~~ ----,
    : | | | |
    : Vcc | | | \
    : | | | | / R3
    : | Vcc | | | \ 47k
    : \ | --- --- --- /
    : / Ra2 | ~ \ / D3A ~ \ / D3B ~ \ / D3C |
    : \ 47k | --- --- --- |
    : / | | | | gnd
    : Rb2 | |<e Q2 | | |
    : 2---/\/\-+------------| PNP | | |
    : |\c | | |
    : | | | |
    : | | | | COL 2
    : +--------------------+--------------------+--------- ~~~ ----,
    : | | | | | | |
    : Vcc | | | | | | \
    : | | | | | | | / R2
    : | Vcc | | | | | | \ 47k
    : \ | --- | --- | --- | /
    : / Ra1 | ~ \ / D2A | ~ \ / D2B | ~ \ / D2C | |
    : \ 47k | --- | --- | --- | |
    : / | | | | | | | gnd
    : Rb1 | |<e Q1 | | | | | |
    : 1---/\/\-+-----| PNP | | | | | |
    : |\c | | | | | |
    : | | | | | | |
    : | | | | | | | COL 1
    : +--------------------+--------------------+---------------- ~~~ ----,
    : | | | | | | | | | |
    : | | | | | | | | | \
    : --- | | --- | | --- | | / R1
    : ~ \ / D1A | | ~ \ / D1B | | ~ \ / D1C | | \ 47k
    : --- | | --- | | --- | | /
    : | | | | | | | | | |
    : | | | | | | | | | |
    : | ROW A| | | ROW B| | | ROW C| | gnd
    : +------+------'.. +------+------'.. +------+------'..
    : | | |
    : \ \ \
    : / RA / RB / RC
    : \ \ \
    : / / /
    : | | |
    : | | |
    : RbA |/c QA RbB |/c QB RbC |/c QC
    : ,--/\/\-+-| NPN ,--/\/\-+-| NPN ,--/\/\-+-| NPN
    : | | |>e | | |>e | | |>e
    : | | | | | | | | |
    : A \ | B \ | C \ |
    : RaA / gnd RaB / gnd RaC / gnd
    : 47k \ 47k \ 47k \
    : / / /
    : | | |
    : gnd gnd gnd

    I've used ~~~ and .. to indicate places where more rows and columns
    may be added. (I think that it should be clear enough, given that
    you've already been laying out an 8x8.)

    The diodes shown above are the LEDs, of course.

    Let's take it in sections. The current sink is:

    : |
    : \
    : / RA
    : \
    : /
    : |
    : |
    : RbA |/c QA
    : ,--/\/\-+-| NPN
    : | | |>e
    : | | |
    : A \ |
    : RaA / gnd
    : 47k \
    : /
    : |
    : gnd

    This section sinks the current for one LED, only. The NPN, QA, is
    operated as a switch (assumed saturated.) The input point called "A"
    is the place where your logic-level control enters to control the
    switch, QA.

    Let's make the design assumption that the beta we want should be about
    20 (a figure that is well below the peak beta for most common devices
    today.) If you expect to sink 30mA per LED, then you would expect
    (30mA/20) or 1.5mA for the base drive. At about 1mA or so, typical
    Vbe is very close to the usual 0.7V assumption, so let's go with that
    as an approximation. So the base of QA will be at 0.7V when sinking.

    If your logic level control is nominally 5V and CMOS and having to
    provide 1.5mA or so, let's choose an estimate of about 4.8V at the pin
    of your micro (it's not uncommon to find output resistance slopes of
    about 60-150 ohms for micro pins; so use the worse value of 150 ohms
    at 1.5mA to get 0.225V drop -- I just called this 5-.2 or 4.8V.) This
    means that RbA should be (4.8V-0.7V)/1.5mA or 2733 ohms. A standard
    value at or below this figure should be fine. 2700 ohms, then.

    If you wanted to sink 100mA, instead, the computation would be to
    figure a base drive of 100mA/20 or 5mA. Your micro's output would
    probably drop to something like 4.2V, supplying that much current (you
    can always examine the data sheets to get a better figure for this.)
    This means your RbA value should be (4.2V-0.7V)/5mA or 700 ohms. Call
    it 680 ohms to pick up on a standard value.

    What about the dissipation? Well, for QA, the operating Vce at a beta
    of 20 might be around 0.1V or so. Looking at the 2N2222A from
    Motorola, I see that at an Ic=10mA and an Ib of 0.5mA (beta=20), the
    Vce is typically below 0.05V at 25C. I also see that an IC=150mA and
    an Ib of 7.5mA (again, beta=20), the Vce is typically below 0.1V.
    Let's use the higher Vce, or 0.1V. That makes things look worse,
    heating wise, so it will be a conservative estimate if you choose to
    run at 30mA instead of 100mA. With Vce=0.1 you get 0.1V*30mA or 3mW
    at 30mA and you get 0.1V*100mA or 10mW at 100mA. Both dissipations
    are easily handled by a 2N2222. Also, by a 2N3904, if you prefer.
    The TO-92 plastic package will be just fine.

    Luckily then, no need to go find large NPNs.

    By the way, I've added RaA here as a 47k value designed to ensure that
    if there is no signal input at "A", then the base will be clearly
    pulled to ground keeping the NPN base from floating and firmly off.
    At a base voltage of about 0.7V when ON, this resistor will sink
    another 15uA. It won't be noticed. Or even a 10k @ 70uA won't be
    noticed. But tying it down like this may help in a stand-alone
    display with a connector, where the signal lines might just "float in
    space," otherwise.

    Forget RA for the moment and lets go on to the high side "column
    driver" section:

    : Vcc
    : |
    : | Vcc
    : \ |
    : / Ra1 |
    : \ 47k |
    : / |
    : Rb1 | |<e Q1
    : 1---/\/\-+-----| PNP
    : |\c
    : |
    : |

    Very similar. Except that there may be a problem due to the amount of
    current sourcing required. Let's see if there is a problem, first.

    This section sources the current for up to eight LEDs in your design.
    The PNP, Q1, is also operated as a switch (assumed saturated.) The
    input point called "1" is the place where your logic-level control
    enters to control the switch, Q1.

    Let's make the design assumption that the beta we want should be about
    20 (again, a figure that is well below the peak beta for most common
    devices today.) If you expect to sink 8*30mA per LED, then you would
    expect (240mA/20) or 12mA for the base drive. As this is about 10X
    the base current for the sinking driver above, that implies about 60mV
    greater Vbe -- let's just call it 0.8V. So the base of Q1 will be as
    low as 0.8V below 5V, or 4.2V, when sourcing.

    If your logic level control is nominally 5V and CMOS and having to
    sink some 12mA or so, let's choose an estimate of about 1.1V at the
    pin of your micro (it's not uncommon to find output resistance slopes
    of about 60-90 ohms for the low side of CMOS micro pins; so use the
    worse value of 90 ohms at 12mA to get 1.08V drop -- I just called this
    1.1V.) This means that Rb1 should be (4.2V-1.1V)/12mA or 258 ohms. A
    standard value at or below this figure should be fine. 220 ohms,

    What about the dissipation at 8*30mA? Well, for Q1 as a 2N4403, the
    operating Vce at a beta of 20 might be around 0.35V or so (guessing
    from the curves on the data sheet.) With Vce=0.35V you get
    0.35V*240mA or 84mW. Plus some for the base drive of 0.9V*12mA (0.9V
    comes from the data sheet and the 12mA comes from 240mA/20), which is
    another 11mW for a total of some 95mW. Call it 100mW. The junction
    to ambient thermal resistance is 200, so this means 20C over ambient.
    Livable in the 2N4403, I think.

    Luckily then, no need to go find large PNPs, if you are satisfied with
    30mA LED currents.

    If you wanted to sink 100mA for each LED, instead, the computation
    would be to figure a base drive of (8*100mA)/20 or 40mA. Your micro's
    output probably cannot sink this much. So this would mean that you
    need another BJT. If you chose to use a Darlington arrangement, your
    Vce would be about 1V or so, a serious loss from your 5V supply, and
    assuming things could still work at 800mA that would still amount to a
    dissipation of 800mW -- a lot. So perhaps no Darlington arrangement.

    Oh, well. You might even want to use two BJTs in the case at 12mA
    base drive for the 30mA/LED case, so let's look at one of several
    possible ideas:

    : Vcc
    : |
    : | Vcc
    : \ |
    : / Ra1 |
    : \ 47k |
    : / |
    : | |<e Q1p
    : ,--+-----| PNP
    : | |\c
    : | |
    : Rb1 |/c Q1n |
    : 1--/\/\---| NPN
    : |>e
    : |
    : |
    : \ Re1
    : /
    : \
    : /
    : |
    : gnd

    In this case, the base drive for Q1p is now provided by Q1n and
    doesn't have to be supplied by a microcontroller's pin. Also, the
    sense of the "1" input is inverted from before, but that's a minor

    Now, we can still go with Q1p's beta being 20. So we will need to
    still sink about 40mA of Q1p base current.

    At these kinds of currents, can a 2N4403 handle the dissipation??
    With 800mA, the Vcesat will be about 0.6V, so that is 480mW. Plus
    40mA*Vbesat or at least 40mA*1.1V which is another 44mW. Call it
    something on the order of 550mW. The junction-to-ambient thermal
    resistance is, again, 200 for the 2N4403, so the change over ambient
    is .55*200 or 110 C. Way too hot.

    We need to select a different device. Perhaps something in a TO-220
    package. A TIP-30A, for example, has a junction-to-ambient figure of
    62.5. I think the Vce would still be about 0.6V and the Vbe would
    still be in the area of 1.1V (something less than 1.3V, according to
    the sparse data sheet from STMicro) so the temp change would be
    ..55*62.5 or 34.5 C. Livable change, I think.

    Let's go with the TIP-30A for figuring purposes. We'll stay with
    Vcesat=0.6V when sourcing 800mA. The Vbe could be argued to be less
    than 1.3V, but let's just call it 1.3V and not quibble about it, for
    now. This means that Vc of Q1n will be 1.3V below 5V, or 3.7V. Let's
    keep Q1n's Vce to about 1.5V (out of saturation) so that its beta will
    probably be in the vicinity of 200, or so. This means that Ve of Q1n
    will be about 2.2V. Vbe of Q1n will probably be close to 0.7V, so Vb
    will be 2.9V. Since Re1 must handle our 40mA of base drive for Q1p
    plus a little base current for Q1n, we can figure that Re1 must be a
    tiny bit less than 2.2V/40mA or <55 ohms. We can select 47 as a
    standard value, then. Rb1 should be (5V-2.9V)/(40mA/200) or 10,500
    ohms. Call it 8.2k just to be sure.

    That's about it. If you go back to the fuller design I listed, you
    will also see R1, R2, and R3. I just added those pull-downs to keep
    the nodes at ground when the column isn't being actively driven. I
    don't know if floating them would be a problem, but if you use a scope
    to probe those points it would probably be nice to have the pull-downs
    in place.

  9. Rich Grise

    Rich Grise Guest

    John, have you ever considered making these corrections _before_ you
    hit send?

  10. John Fields

    John Fields Guest

  11. I forgot to finally address myself to the value of RA in:

    : |
    : \
    : / RA
    : \
    : /
    : |
    : |
    : RbA |/c QA
    : ,--/\/\-+-| NPN
    : | | |>e
    : | | |
    : A \ |
    : RaA / gnd
    : 47k \
    : /
    : |
    : gnd

    What it should be depends on the Vcesat of QA and the Vcesat of Q1 (or
    Q1p, from the earlier discussion) and on the expected voltage across
    the diode at the desired current. Already, we know that for QA, this
    Vcesat is about 0.1V. Also, if you are going with 30mA per LED, the
    2N4403 gives you about 0.35V for Vcesat at full-bore 240mA. So, you
    lose about .45V (call it .5V) at those two places. Also, the LED
    itself at 30mA is about 3.3V from what you've said. So the total loss
    of voltage is about 3.8V from 5V. That leaves 1.2V for the resistor,
    RA, at 30mA. So, Ra=1.2V/30mA, or 40 ohms. Make it 39, as a standard

    In the case of the higher drive, 100mA per diode, more thoughts are
    needed. Here, with the TIP30A I mentioned, the Vcesat is still about
    0.6V at 800mA. If you use a TIP42A, instead, that drops well below
    0.2V with 40mA base current. Whether you use one or the other only
    chooses where the heat gets dissipated (RA or Q1p), so long as there
    is enough voltage headroom for the LED itself. So let's see what the
    LED requires.

    I don't have a data sheet on your LEDs, so a lot of guessing is in
    order. But the diode equation that says that the slope of the Vd vs
    Id line (the linearized resistance) of a diode is about (nkT/q) /
    (Id+Isat). At Id's of 20-100mA, Isat can be largely ignored. So this
    is about n*26mV/Id or something like 2.6 ohms at 30mA with n=3
    (nominally 1, but 3 isn't an unreasonable guess) and .78 ohms at
    100mA. For pure rough-shod guessing work, I'd take the average of
    these two (2.6+.8)/2 or 1.7 ohms as the mean slope and figure that if
    there is 3.3V at 30mA, then there is 3.3V+(100mA-30mA)*1.7 or 3.42V at
    100mA. Call it 3.5V. So, with 5V supply, we are left with (5V - 3.5V
    - .6V - .1V) or 0.8V. That's slim, but it suggests an RA of .8/100mA
    or 8 ohms. Use a 7.5, I suppose.

    RA would need to dissipate 75mW. In the 100mA per LED design, Q1p
    would be dissipating some 550mW, if you recall, with the TIP30. If
    you wanted to shift more dissipation to RA, you could use the TIP42
    which would cut its Vcesat to say 0.2V and its dissipation to under
    200mW. But then the difference in Vcesat (0.6 - 0.2) would have to be
    picked up in the resistor, RA. So it's new value would be 12 ohms and
    its dissipation would be 120mW. That might not seem quite right,
    because you might be wondering how it is that you can go from 550mW to
    200mW on Q1p and only go up from 75mW to 120mW on RA. But if you
    remember that there are eight of these RA resistors, each of which are
    carrying their own part of this difference, then you can see how it
    all comes out even again. In other words, by using a slightly more
    expensive PNP on the high-side source, you can distribute the power
    dissipation over 8 resistors, resulting in lower peak temperatures

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day