RGB SMT LED Cube, resistors, drivers, and shift registers.

http://www.fairchildsemi.com/ds/MM/MMBT2222A.pdf

I think this was the datasheet I was using.

The 2n2222s are for a cube that lights upto 4 RGB LEDs, assuming they are 20ma, then that means I need between 0 and 240 ma (12x20=240) for the LEDs, but that doesnt account for dissipation by the resistors or transistors in the circuit.

From what I can tell, if I use too much base resistor, it may limit current too much. and not sink enough current, which may make it not light up enough, too small of a resistor, and you risk drawing too much current from the microcontroler.

With the mosfets, you dont seem to need that resistor, or is it just under some circumstances?

I have 2 cubes that will need mosfets for turning planes on and off (both cubes are 4x4x4 RGB, and use a 4 plane setup for a 25% duty cycle. Each plane consists of 16 RGB LEDs, assuming 20ma, that totals 16x60=960ma, or about an amp.

One cube sinks, while the other cube sources, so I picked out an n-channel, and a p-channel.
Heres a link to the n-channel.
http://www.diodes.com/datasheets/ds30830.pdf

and heres a link to the p-channel.

In post #77 I talk about how I come to think that this will be a good part, and in post 81 I list the parts that I ordered.

As I understand things, the fets wont need a gate resistor (similar to a base resistor), but it will work best if I have a gate/source resistor (makes it switch faster?). I also read about ringing, and that you can have a ringing issue that may damage the fet, the resistor reduces ringing?

When you talk about a beta, is that the same as gain, or HFE as I've read in other documents?

It was quite a bit of effort trying to figure out the right parts. I had to read a lot of datasheets and try to compare values and such. Digikeys website helped, but even then I spent hours. It would be nice if it were easier.

I'd like to stick with transistors ("bee-jay-teez"), that's supposedly where you weren't getting support.

Beta is h_fe, Yes.
I'm still assuming that the "common emitter" circuit is the basis of this discussion.

As for "dissipation by the resistors or transistors in the circuit", remember: current is the same everywhere in a series circuit. Let's do one thing at a time and not get caught up in a manic death-spiral.

If you want the transistor to do 240mA, then let's figure 300mA, plan for more than is needed.
I think that a beta of 50 is a good assumption.
300 mA / 50 = 6 mA
So, with "5V" as input voltage to our humble transistor, (5V - Vbe )/6mA = 4V / 6mA = 667?.
So, we'll live it up and go with 470?, working out to about 8 mA.

If V_cc is 9V, and I'll venture that V_ce might approach 300mV, then 9V - 0.3 = 8.7V.
8.7V / 240mA = 36?.
3 100? in parallel gets you 33?, resulting 263mA.

So, set that up, starting with > 2K for that collector resistor. Measure the voltage across that resistor. The voltage across the collector / the collector resistor ? = collector current. Replace the collector resistor with a lower value, paralleling for value as necessary, taking notes along the way, till you have several data points that you can analyse. [2K, 1K, 500?, 100?,...]
If you can manage with the milliammeter then go that route. Voltmeters make you get out the calculator, but they don't blow fuses.

The absence of an LED in the circuit doesn't matter, as we're just looking at, discussing, the collector current thing.

I think the primary issue I had was trying to figure out the beta, or gain as others called it, when I asked. One person told me to assume a gain of 100, another person told me to assume a gain of 10, and I was unclear on how anyone comes to the conclusion of a good number, both seem to be guesses, and radically different guesses at that.

I looked over the datasheet to try to figure it out. There are several graphs and several tables of data, but I couldnt figure out which one is the correct figure. If you do the calculations with each figure, you get very different results, and I couldnt rely on any of those calculations to be even close.

It seems to me that the part has a specific beta, you shouldnt have to guess if its 10, 50,100, or whatever. I do understand that at different temperatures, the beta will vary, but at or near room temperature, they should be should be pretty consistent.

Your first calcluation, with the 50 beta estimate is for the base resistor correct? That resistor goes between the arduino, and the base on the transistor, correct?

The second calculation you posted you said was for the collector resistor, Im not sure how/what/why that is about. Is that a resistor between the collector, and ground?

With the base resistor, I basically made a guess, then made some calculations, then tried a few sizes of resistors, making notes along the way. Because I was cascading them, I ended up testing them in tandem, as well as single.

It seems to me that I should have been able to get it a lot closer with the calculations, but having to guess with the beta made the calculations seem pointless.

I should look for my voltmeter, I havnt seen it in like 20 years. Measuring was very difficult, since my minimum was 20ma, and my max was 240 ma, I couldnt use one setting to measure all conditions, and that made measuring relatively inaccurate.

In your second calculations you have 9v -.3, should that be 9v-.7 (saturation voltage)?

When I was doing my testing, I only measured current, but I measured it at a few places.

It would also be good to understand why we need a resistor. its my understanding that he base resistor can be used to limit the current to the collector, but its primary function is to limit the current on the microcontroller, without it, you may draw too much current and break the microcontroller. Is that a fair statement? is there more too it?

I've started a couple of schematics. Before I put all the wiring in, its a bit easier to understand so Im including these views, that really only show how the transistors relate to the cathodes on the LEDs.

I've just added the full version. The schematic is kinda weird looking but its complete.

The BOM:
64 CC RGB LEDs
20 2n2222 transistors (I used little SOT23s)
20 Resistors 8-270 Ohm, 8-100 Ohm, 4-150 Ohm
40 pin sip socket (to connect arduino)
Arduino (I used a Nano, but any should work)
Runs on USB or alternate 6v power supply.

Edit: removed incomplete drawings, The full drawing is about 2,000x2000 px, its kind of big, but reducing it made it too hard to read.

Heres a schematic for the charliecube spire, its not the whole cube, but if you can understand one spire, then multiply it by 16, you are most of the way there.

Edit: Changed drawings, included both common anode and common cathode.

I just wanted to try to get you to do and understand one thing right: the common emitter circuit.
The key to understanding is to stay with the subject, avoiding the introduction of side issues.
I set out a modest experiment, but without a voltmeter it's pointless.
(You have an ammeter, but no voltmeter?)

There's a big difference between VB, VBE (approx 0.7V), and VCE.

With regard to "specific beta", all design assumptions are, or should be, based on worst-case, h_fe/beta guaranteed Minimum.
In some production lot there would likely be little variation unit to unit, but from lot to lot, or manufacturer to manufacturer there's no telling.
You may find that your transistors do better than the guaranteed minimum, well and good, so you can utilise that overage.

Anyway, till we can agree to work on one specific circuit, really wring out the fundamentals, I can't see any point in going on.

I have a pile of DMMs, the are cheap, but good enough. Somewhere, I may still have a nice meter (you know, the kind with a needle resting on some diamond chips to pivot smooth and effortlessly. I cant remember the last time I saw it, but its a basic VOM.

I think i understand the basics of the calculations, but it would be nice to understand why the parts are needed. I also dont like the guessing part of the calculation, it seems to me that the part will likely behave about the same under similar conditions for most people. It seems like it should be easy to look that up in a chart or graph, and get close with your calculations, but I wasnt able to do that, I had to test things, before I could get in the ballpark.

The last several posts, I've only been talking about using 2n2222 BJT in my circumstances of lighting up to 0 to 4 RGB LEDs (0 to 12 LEDs total) at one time.
The posts with the schematics show you how the transistors are being used. That same circuit can probably be modified to use mosfets, or ULN (darlington arrays) chips easily though. I did test all 3 types of parts using the same LEDs and resistors that I used on the cube.

I do also have unfinished projects that will need mosfets, and I've picked out some tiny parts that hopefully will be suitable for my needs (about 1 amp), and as I understand it, they dont need a resistor between the arduino, but they need one between the gate/source, I think I have some 4.7k's for that.

Hippynerd:
I think i understand the basics of the calculations, but it would be nice to understand why the parts are needed.
Which parts? Are we discussing the common emitter circuit?

I also dont like the guessing part of the calculation, it seems to me that the part will likely behave about the same under similar conditions for most people.
It's not a "guess". You have to start somewhere. Having only the least is a good start, if there's more (as in more beta, as may be likely) then it only gets better. The circuit will not be a worse performer for the transistor's having more beta (gain) than anticipated.

It seems like it should be easy to look that up in a chart or graph, and get close with your calculations, but I wasnt able to do that, I had to test things, before I could get in the ballpark.
How can I know where you're losing the plot? You haven't shown your work.

I can't see what's going on in your schematics; they're pretty free-form, difficult to follow.

I just went back and changed some other drawings, and removed the incomplete ones. The complete one is kind of big 2000x2000 pix, but if I reduce it too much, its harder to read.

I will look for my notes, it was a while ago, so I may be a while before I find them.

I took some data with two different transistors, a 2N3904 and a PN2222.

I ran the 2N3904 out past recommended Absolute Max.
What's not across the load (VL is across VCE.

Clearly, the PN2222 has more gain.
If you don't like comparing the 32? load data, the PN2222 does a lot better job with 67? load. It's able to sustain > 120mA collector current with 1mA base current.
I'm using resistors for load because I don't want to string out a bunch of LEDs.

[Given the 32? example: 3 Greens in series (= 6V) with a 220? resistor would result about 10mA; so, 24 of those circuits in parallel would have the same effect (240mA).]

This is what I was trying to get you to do in Reply #101.

I looked around for my notes, and I couldnt find much, so I did the calculations again:

I considered 4 circumstances Highest load (240ma), lowest load (20ma), Highest gain guess (100), lowest gain guess (10). Im only using 5v, and saturation point is .7v.

Loads:
1-12 LEDs, assuming 20mA.
20mA to 240 mA
.7v Saturation
Vin=5v
Gain/Beta/HF_E: 10, 100

#1 (20ma load, gain 10)
Base current = 2mA (20/10=2)
5v-.7v = 4.3v
4.3/.002(2ma) = 2150 ohms
Base resistor size 2.15K ohm

#2 (20ma load, gain 100)
Base current 20mA (20/100)= .2
5v-.7v = 4.3v
4.3/.0002 = 21,500
Base resistor = 21.5k ohm

#3 240 mA load, gain 10
Base current = (240/10) =24mA
5v-.7v = 4.3v
4.3/.024 = 179 Ohm

#4 240 mA load, gain 100
Base current = (240/100)=2.4 mA
5v-.7=4.3v
4.3v/.0024 = 1791 ohm
Base resistor =1791 ohms

From there It looks like I have range of 180 to 2k ohms. Which is pretty big, it doesnt help me figure out what part to order, so I cant order parts, until I narrow this down.

To make thing a little more complicated, Im cascading the transistors, so, even if these numbers were 100% accurate, they may not be after the second transistor.

In the past I've done calculations, and later found out that real world numbers and calculations can be very different, its best to test things with the specific parts, and specific power supplies, because they can vary. Sometimes that 5v power supply is only 4.5v, others may be over 5v. 100 ohm resistors may actually be 95 ohms. These seem like tiny insignificant amounts, but when you throw them into the equation, it can change the results quite a bit.

I ended up getting using many resistors and a few transistors, setup a test rig with the parts I plan on using (LEDs, resistors, 2n2222s and a variety of base resistors). I did a bunch of testing and measuring, then I realized that I needed to use 2 transistors for my testing, so that It would be exactly like I will be using them.

I had a lot of hassle trying to measure, since my ranges of measurement was from a fraction of an mA to about 250mA, which meant 2 settings on the meter, and the 2 settings were inconsistent. but my measurements lead me to believe that I could use between 150 and 1k ohm base resistors, 150 drew a lot of current at the base when all LEDs lit (about 40ma), and 1k restricted the current a little bit, 300 ohms seemed to work good, and keep the base current under 20ma. I wasnt able to get 300, but I was able to find 270 ohm resistors, which is what I ended up using.

While I was testing the 2n2222 with 4 RGB LEDs I did similar experiments with the mosfets that I picked out for the other cubes (they need to sink/source almost a amp, way too much for 2n2222s). I have a p-channel, and an n-channel, both have similar ratings, both need to be able to light between 1 and 48 LEDs (assuming 20ma), thats nearly a whole amp. I only did a little measuring, but it seem like they only had about 1ma load on the gate, they seem like a much better part than the BJTs.

In the past I've done calculations, and later found out that real world numbers and calculations can be very different, its best to test things with the specific parts, and specific power supplies, because they can vary.

Yes, this is known as "DVT" - Design Verification Testing.

Again, my sole motivation in posting on the subject was in response to your having posted that you hadn't gotten support enough to understand the relationship between beta and collector current.

I still dont have any idea how to figure out how to figure out the gain/hfe/beta for the calculations, It seems to me, that should be as simple as looking it up in a table on the datasheet.
The beta numbers 10 and 100 came from 2 different individuals, when I asked them where on the datasheet can I find the right value for my uses (20-240ma at 5v).

It seems to me, that there should be a few common resistors used with 2n2222 transistors, one for 5v, and other for 12v applications. the part is only good for about 1/2 amp (mine are smt, and only good for 350ma). I would think that I would find 5v circuits all had about the same value base resistor, and 12v circuits would have a different value, but the 12v circuits would all have a similar value base resistor.

It seems like it should be easier than it is, and it seems like I have to assume every transistor will have a beta between 10 and 100, and be prepared for every calculation in between.

Hippynerd:
I still dont have any idea how to figure out how to figure out the gain/hfe/beta for the calculations,

Then you haven't been reading any of my posts.

Hippynerd:
It seems to me, that should be as simple as looking it up in a table on the datasheet.

Again, (I have posted this twice before) beta is not a firm figure, there's a range, but a minimum guaranteed is always specified - that's what you work with. Reconcile yourself to the fact that the way it's done and how you want it are two different matters.

Hippynerd:
The beta numbers 10 and 100 came from 2 different individuals, when I asked them where on the datasheet can I find the right value for my uses (20-240ma at 5v).

Those numbers did not come from me.

Hippynerd:
It seems to me, that there should be a few common resistors used with 2n2222 transistors, one for 5v, and other for 12v applications. the part is only good for about 1/2 amp (mine are smt, and only good for 350ma). I would think that I would find 5v circuits all had about the same value base resistor, and 12v circuits would have a different value, but the 12v circuits would all have a similar value base resistor.

Why would you think they would be the same?
The base current required for IC up to 240mA is different than that for 100mA or 50mA. Yes, someone could set it all up for the possibility of 240mA, no matter what, but then where that's more than required it'd be over-driven like crazy. That's OK, in a political sense, but the cognoscenti will deride the unnecessary base current.

Moderator edit: unnecessary sarcasm removed

I understand that the gain will not be the same at all voltages, and all currents, but the part is pretty limited in its rage of current, and using it at 5v is very common (especially when you are using it with microcontroller, like we do on this forum)

With a 2n2222 transistor, and 5v, how many possible base resistor sizes could I need? We know the current wont be more than 1/2 amp, or we would need a different transistor. At 240ma, you may have a different gain than at 10ma, which will effect the size of the base resistor. but at similar current levels, it should be pretty similar (note: similar does not mean exactly the same, it means near, or close to.) I understand there will be some deviation from lot to lot, and manufacturer to manufacturer but at 5v, one size resistor should be good for a fair range of current.

Anyway doing the calculations isnt the problem, calculating my needs isnt a problem, figuring out the right value for gain/beta/hfe is a problem You mentioned that I can assume its 50, someone else says I should assume its 10, another person says its probably about 100.

When all is said and done, the calculations were kind of pointless, since I had to hook them up and measure to find the answer.

Moderator edit: severe over-quoting removed; vitriol removed

Thanks for removing those offensive posts.

I am curious about the claims of vitriol though, but whatever, its probably not important.
I dont really see any value in the posts after I posted my calculations. Those are mostly just a bunch of incorrect assumptions and of little or no educational value.

Hippynerd:
I dont really see any value in the posts after I posted my calculations.

There is value to the forum. The posts stay.

Hippynerd:
I am curious about the claims of vitriol though, but whatever, its probably not important.

It is entirely up to you to decide if it is or is not important. If I have to edit any of more your posts on this thread you will be given a timeout. If access to this forum is important to you then you will temper your responses.

Thanks for your help, its a big improvement. Im sorry for any hassle.