LED cube column/level resistors question - AFTER reading for a couple of hours

Hey,

I'd first say like anyone else's first post, it is my first :slight_smile:
I have been reading quite a lot from this forum and others and gained a lot of knowledge i didn't have before, and managed to run quite a few arduino projects! So thanks in advance first of all, without you knowing you really did help me a lot..

Now to my project, i am trying out a 3x3x3 cube project for my dad, now i read and googled and checked all threads possible, I also googled for multiplexing threads, but i didn't get to one conclusion due to seeing different answers that boggled me.

Sorry for long post, i guess slow and explaining is faster and better understanding :roll_eyes:
Bottom line, the 3x3x3 cube is working, i put 9 resistors for columns, tried 220ohms for LED's columns. Put 3 resistors for the transistors, i tried 22k, 110ohm and 220ohm, all worked, not sure if brightest or not or whether the electronics were actually warming up and I couldn't tell..


Configuration:

  1. Arduino Uno 5v supply
  2. LEDs (clear blue) with 3.2 forward voltage (probably 20ma but im aiming at 15ma)
  3. transistors 2n3904 NPN (more than capable for 135ma=9*15)
    http://www.taydaelectronics.com/datasheets/A-111.pdf
    Managed to read it correctly i think.
  4. i want to run LEDs at 15ma

From what I read i understand i need to do one of the following, i'd appreciate helping me understand the correct scenario

  1. Put resistors only before the columns -
    (5-3.2-0.7)/15ma=73ohm

  2. Resistor before leds' columns AND for transistor base
    Column Resistor: (5-3.2-0.1)/15ma=113ohm (closest is 120 or 130 i think) > 0.1v there coming from the transistor side, that was a value for 20ma, i didn't bother to check the pdf for this as i just couldn't understand should i use this equation..
    Transistor Resistor (or "floor"): (5-0.7)/15ma=286ohm (not sure about closest resistor at the moment). > here 0.7v although it should be 0.77v from the datasheet graph, but it almost didn't matter the calculation so i am using 0.7 like most suggested- another reason why in the column calculation, i let it stay at 0.1v and didn't check exact number. if it matters - on the datasheet graph i see 20ma it should be 0.8v.

For what I understand I need to put resistors at both "places", one in series with led columns and one in series with the base of the transistor.. it made sense to me as those are connected directly to arduino as well so it will protect both microchip and transistor, but i saw posts that led me to believe that i can just put resistors before if i calculate the transistors voltage with it.. these specifically were quick replies so i wasn't too sure, but the rest of the forum threads weren't "set" on one answer.

I didn't understand how people reached resistors for the LED columns with values of 220ohms for 15ma while others wrote that they use ~130ohms.

Most if not all the threads I read were of the same schematics as mine, basic x^2+x cube.. same goes for the voltages etc.. although this can just be calculated with different numbers..

I also saw variations where people say to multiply the current (15ma) by 1/10 when calculating the resistor for the transistor
I am a bit confused and I don't want to run this incorrectly although it does currently

Sorry I didn't post schematics, I don't see a need for the question :slight_smile:

Thanks in advance!

The resistors between the Arduino and the 9 LED anodes will set the current for each LED, protecting both the LED and the Arduino pin.

The Base-Emitter junction of a transistor acts like a diode with Base the anode and Emitter the cathode. Without a resistor that 'diode' would short the Arduino pin to Ground and draw too much current. The Base-Emitter current is multiplied by the transistor so you don't need much. The "beta" of the transistor (DC Current Gain) is how much the current gets multiplied. You divide the Collector-Emitter Current (total through 9 LEDS) by the beta to determine the minimum current you need going into the Base from the Arduino pin. Any current above that and well below 40 mA (the pin maximum) will do. Typically a 1K resistor (about 5 mA) will work for all practical purposes.

Ok great, so I got a confirmation on two resistors for both anodes and catodes, I calculated the anodes' resistors as 73ohms (will find closest), with:
(5-3.2-0.7)/0.015
sounds too low for me for some reason, i guess this reason is all the other threads using 120ohms or so minimum for 15ma..

for the transistor i am still confused, i mean i did read this for example:
http://www.zen22142.zen.co.uk/Design/bjtsw.htm

ib = ic / hfe(min)
resistor would be= (5-0.7)/ib

which is exactly what you wrote (need to multiply 9*15ma of course), but i still dont understand how to calculate minimum hfe, the datasheet on characteristics show 100/30 min max, but compared to what i read and the graphs i saw it is completely different way..
Couldn't trnaslate what that link suggested to the datasheet i have.. although it is the same type of transistor, he zoomed in for example on the saturation part where the Vce was on the X axis of the graph, couldn't find that one..

It's important for me to stress, i READ READ READ, i love being self tutored so i dont just ask and expect my answers to be answered without really trying before, it's funny but i already read i think 15hours, need to go grab a freaking book :slight_smile:

So you have Arduino sourcing current into the LED anodes, and sinking current for a layer 's cathodes via NPN transistor?
Vbe Saturation is 0.65V to 0.95V with Vce Sat of 0.2V to 0.3V with Ib base current of 1 to 5mA for Collector current of 10-50mA, see page 2 of the datasheet.

So picking some numbers in the middle, say Vbe 0.8V, Vce 0.3V, and Ib 5mA:
Then LED resistor: (5V - 3.2V - 0.8)/15mA = 67 ohm 68 is standard value
Base resistor: (5V - 0.3V)/5mA = 940 ohm. Want to make sure transistor turns on fully, so use a standard value of 910 ohm or 820.
(5-.3)/820 = 5.7mA

Course, 9 * 15mA = 135mA, which is more than that transistor is rated for.
May have Absolute Ic of 200mA, but the characteristics all end at 100mA, so you're on your own for 135mA. You can be pretty sure Ib will need to be more than 5mA tho.

Perhaps the PN2222A transistor would be a better choice. It has a maximum continuous current of 1000 mA so the charts go up to 500 mA:

The pulsed current gain is about 175 at 135 mA so a minimum base current would be 9*15/175 or a little under 1 mA. A 1k base resistor should provide plenty of current.

Thank you both for answering, I read a lot from you guys over the different posts for other projects as well.. :slight_smile:
I think what I'll do is I'll get a different transistor and end this saga, Got to run some other projects, never got as perplexed as I am with this item.

i understand the characteristics end at 100ma, i should look more carefully at stuff like this in the future..
I was wondering though, if i take 1k resistor as johnwasser said on this current NPN transistor and put it for the base, i should be at 4.7ma.. wouldn't that be fine? i know i cant see the rest of the data but isn't the behaviour should be proportional to the rest?

The worst that can happen is that i go past the recommended power specs and burn something, like the led/transistor or even the pin? i am doing with the atmeg328 on a board (no arduino)

I am afraid wrong calculations, maybe even in the slightest could cause a fire.. for example I got a few projects i did with leds and el wires in cabinets etc, i am afraid that a too close contact between "open air" boards with electronics and wood or whatever material can catch up a fire.. so a bit afraid of connecting power from wall socket (12v etc) when not at home.. (even if it is turned off actually)

IC = 10 mA, IB = 1.0 mA
IC = 50 mA, IB = 5.0 mA

You need nearly 3 times that current. Will likely be a lot dimmer than you are expecting.