Now that I'm looking back - He used different values.
Probably so. Your base resistors are incredibly low-valued.
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?
Yes.
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.
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.
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.
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.
Oops - you're quite right about that. Not quite sure where my head
was there.
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
voltages.
Then design things to work.
Could you advise on how to make such a current source?
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,
then.
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
point.
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.
Jon