Go Down

Topic: Help check my (basic) understanding (Read 4633 times)previous topic - next topic

vtterp

Jan 29, 2013, 07:22 pm
I am new to this world of the arduino (and electronics in general to be more precise) and have spent some time trying to wrap my head around many of the concepts.  After much reading I've decided to jump into building a 3x3x3 cube (wanted to do a 4x4x4 but think a 3x3 is more prudent for a first project).

I've gone ahead a purchased a number of blue LED's from eBay which have the following specs - 3.0-3.4v, 3.22v typical, 24mA max, 13000 mcd.  In trying to calculate the resistors I need I've both used an online "calculator" and more importantly tried to apply Ohm's law as I understand it... And, this is where I need my understanding to be checked.

I understand that the Arduino Uno works at 5V.  So, if I am applying  Ohm's law correctly, I need to calculate the "voltage drop" (which I am equating to the remaining voltage after the LED), and divide by the current I want the circuit to draw (in this case based on what the LED can handle):

R=V/I
R=(5 - 3.2)/.02A == 90ohm resistor required (this uses an avg voltage of the LED and assumes a chosen 20mA current)

So, I think I should be rounding up to a 100ohm resistor to prevent more than 20mA going through the LED.  This is consistent with what the calculators are returning.  I assume rounding up to a higher resistor will simply limit the current available for use by LED resulting in an imperceptibly dimmer LED.

What I am not 100% on is how the the arduino's output current plays into this (or if it does at all).  I understand that the max input or output the pins can handle is 40mA.  I assume that it is the resistor that limits the current from the pin, hence an additional reason for choosing 20mA in the above equation.  So, hypothetically if I used a smaller resistor more current would flow through the LED potentially damaging it and the in/output pin.

Eg. - using an imaginary 10ohm resistor
I=V/R
I=1.8/10 = .18 amps or 180mA == damage to the LED and i/o pin

Does all of this sound right?

CaptainJack

#1
Jan 29, 2013, 07:37 pm
You got it pretty much right.

Arduino pins can supply 40 mA with a total of 200 mA for the entire atmega328 chip. However, with a 100 Ohm resistor and a single led connected to a pin, the 40 mA maximum is not an issue.

However... 3x3x3 = 27 leds, drawing each 20 mA makes 20x27 = 540 mA which is more than your arduino can supply. I suggest using a led driver, transistor, mosfet, whatever makes you happy.

I build an 8x8x8 ledcube which was fed of 595 shift registers. No, not what they are intended for, yes, pushing the limits on how much current they can supply, and mostly: yes, a very convenient hack.

So first find it how you want to supply power for your 27 leds. Each pin of a 595 register typically supplies 30-35 mA. This will do for you. To drain a plane of 9 leds, use a transistor. If you want more advice it might help to post your proposed schematic for your ledcube.

Cheers !

Jack

retrolefty

#2
Jan 29, 2013, 07:42 pmLast Edit: Jan 29, 2013, 07:44 pm by retrolefty Reason: 1
Quote
However... 3x3x3 = 27 leds, drawing each 20 mA makes 20x27 = 540 mA which is more than your arduino can supply. I suggest using a led driver, transistor, mosfet, whatever makes you happy.

Keep in mind that most all led cube designs never try and turn on all the leds on at any single instant of time, but rather a 'level' at a time so for a 3x3x3 design there would never be more then 9 leds drawing current at any given instant, so no problem for the arduino 5v pin suppling that total current. It's the multiplexing timing that can make it appear that all 27 leds can be on at the same time, but it's simply an optical allusion as the human eye can't resolve faster time spans.

Lefty

fungus

#3
Jan 29, 2013, 08:01 pm

Does all of this sound right?

Yes...but bear in mind that some of your LEDs might only need 3.0V.

If you use the 'correct' resistor for 3.2V then the 3.0V LEDs might receive much more than 20mA. This is because a LED doesn't have a constant resistance. The resistance of a LED varies with the voltage across it and drops away exponentially as you approach the 'optimum' (in this case when you get 20mA). At 20mA a tiny error in voltage can produce a massive error in current, enough to hurt the LED.

To light up a LED safely you should either:
a) Use a circuit which controls current, not voltage (eg. A LED driver chip).
b) Aim for less than maximum current, eg. 15mA (the LED resistance curve is much flatter here so errors don't matter as much).

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

retrolefty

#4
Jan 29, 2013, 08:07 pm
Quote

If you use the 'correct' resistor for 3.2V then the 3.0V LEDs might receive much more than 20mA.

I think you are over stating the case. If a led with a nominal 3.2vdc Vc rating was actually 3.0 Vf then the
90 ohm resistor would limit the current to 22 ma, hardly a thing to be concerned about, right? There can be more then that much variation in the arduino boards Vcc voltage depending on the USB voltage allowance of 4.75 to 5.25 vdc standard.

Lefty

vtterp

#5
Jan 29, 2013, 08:20 pm
Thanks for the quick replies.  At least I now feel like I am making some sense of all of this in my head... and yet it is clear I have a long way to go

I was under the impression that because of multiplexing I wouldn't be pushing the arduino too much.  LED driver chips and the like are beyond my skill set at the moment, but I will certainly add them to the list of items to research.

Jack - I'll be working on the schematic over the next few days and will post once it's complete.  I am thinking of using gzip's build as a go-by http://www.instructables.com/id/LED-Cube-and-Arduino-Lib/?ALLSTEPS

retrolefty

#6
Jan 29, 2013, 08:37 pm

Thanks for the quick replies.  At least I now feel like I am making some sense of all of this in my head... and yet it is clear I have a long way to go

Your understanding of the principals at hand have been just fine, your learning journey is off to a fine start.

I was under the impression that because of multiplexing I wouldn't be pushing the arduino too much.  LED driver chips and the like are beyond my skill set at the moment, but I will certainly add them to the list of items to research.

That is correct, a 3x3x3 led cube will be no problem being powered by your arduino board. You will need 3 transistors to drive the three 'levels' as a 'level driver' via 3 output pins, as it has to be able to supply up to 9 X 20 ma, more then a output pin can handle by itself. So you will need to use 12 digital pins, but keep in mind that the analog input pins can function as digital pins just by using pin numbers 14 to 19, so a Uno board is good to go.

Lefty

Jack - I'll be working on the schematic over the next few days and will post once it's complete.  I am thinking of using gzip's build as a go-by http://www.instructables.com/id/LED-Cube-and-Arduino-Lib/?ALLSTEPS

fungus

#7
Jan 29, 2013, 09:08 pmLast Edit: Jan 29, 2013, 09:12 pm by fungus Reason: 1

Quote

If you use the 'correct' resistor for 3.2V then the 3.0V LEDs might receive much more than 20mA.

I think you are over stating the case. If a led with a nominal 3.2vdc Vc rating was actually 3.0 Vf then the
90 ohm resistor would limit the current to 22 ma, hardly a thing to be concerned about, right?

"The resistance of a LED varies with the voltage across it and drops away exponentially as you approach 20mA..."

Here's an actual graph from the datasheet of a real-life red LED rated at 2.0V-2.5V. Let's see what an error of 0.2V does...

At 2.2V you get 20mA - perfect!.

At 2.4V you get about 45mA - more than double the current at 2.2V and enough to kill the LED (its maximum rating is 30mA).

So no, I don't think I'm overstating anything.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

MarkT

#8
Jan 30, 2013, 01:23 am
You are confused - the resistor sets a relationship between current and voltage, so does the LED, the actual voltage/current is
determined by where the response curve of the LED crosses the load-line of the resistor.  The current won't double or anything
remotely like it.

LED that takes 20mA at 3.2V, 90 ohm resistor drops 1.8V at 20mA - all consistent.
LED that takes 45mA at 3.2V, 90 ohm resistor drops 4.05V, therefore LED gets 0.95V - doesn't happen.

What happens is a bit more current flows, the voltage across the resistor increases, then the LED ends
up with about 3.0V across is and about 20mA flowing through it.  Hence the name "current limiting".

If the supply voltage was 3.3V though, this limiting effect would be much poorer - by throwing away 1.8V
you gain current stability.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

SirNickity

#9
Jan 30, 2013, 01:31 am
A blue LED at 20mA is also blindingly bright.  So, I would shoot for 10mA and the whole babysitting millivolt differences becomes moot.  :-)  IMHO.

retrolefty

#10
Jan 30, 2013, 01:40 amLast Edit: Jan 30, 2013, 01:45 am by retrolefty Reason: 1

Quote

If you use the 'correct' resistor for 3.2V then the 3.0V LEDs might receive much more than 20mA.

I think you are over stating the case. If a led with a nominal 3.2vdc Vc rating was actually 3.0 Vf then the
90 ohm resistor would limit the current to 22 ma, hardly a thing to be concerned about, right?

"The resistance of a LED varies with the voltage across it and drops away exponentially as you approach 20mA..."

Here's an actual graph from the datasheet of a real-life red LED rated at 2.0V-2.5V. Let's see what an error of 0.2V does...

At 2.2V you get 20mA - perfect!.

At 2.4V you get about 45mA - more than double the current at 2.2V and enough to kill the LED (its maximum rating is 30mA).

So no, I don't think I'm overstating anything.

Your graph is not taking into consideration the effect of the series current limiting resistor, which is what the conversation is all about, proper sizing of such a resistor. Your graph is showing the effect of a non current limiting voltage source driving the led. We simply are not driving the led with a constant voltage source, but rather a current limited source. Your graph show why it is important to use current limiting resistor with low power leds, which some people still feel are not required, if they can some how control the source voltage, which as your graph shows is a dangerous route to take.

Lefty

fungus

#11
Jan 30, 2013, 11:19 am

Your graph is not taking into consideration the effect of the series current limiting resistor, which is what the conversation is all about, proper sizing of such a resistor. Your graph is showing the effect of a non current limiting voltage source driving the led. We simply are not driving the led with a constant voltage source, but rather a current limited source. Your graph show why it is important to use current limiting resistor with low power leds, which some people still feel are not required, if they can some how control the source voltage, which as your graph shows is a dangerous route to take.

Hang on...I'm being thick, aren't I?

Just because much more current could go through the LED with a 0.2V change, it doesn't mean much more current could go through the resistor. The voltage across the resistor only changes by 0.2V so the difference in current will be in proportion.

I stand corrected.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

vtterp

#12
Jan 30, 2013, 06:59 pm

I was under the impression that because of multiplexing I wouldn't be pushing the arduino too much.  LED driver chips and the like are beyond my skill set at the moment, but I will certainly add them to the list of items to research.

That is correct, a 3x3x3 led cube will be no problem being powered by your arduino board. You will need 3 transistors to drive the three 'levels' as a 'level driver' via 3 output pins, as it has to be able to supply up to 9 X 20 ma, more then a output pin can handle by itself. So you will need to use 12 digital pins, but keep in mind that the analog input pins can function as digital pins just by using pin numbers 14 to 19, so a Uno board is good to go.

Lefty

So, I've gone back to a 4x4x4 and am having a conversation with myself regarding the need for transistors.  As the Uno can utilize 20 pins (16 columns, 4 rows) as digital pins and because of multiplexing, shouldn't I be able to (safely) get away without transistors?  Regardless, I am amidst some heady (for me) reading on transistors and hope to understand the use of them for this project if necessary.  I have some 2N2222's here and was initially planning on using these on the rows but am having some serious trouble understanding the calculations behind choosing correct resistors to use with the transistors.  Any "beginner language" help would be greatly appreciated.

I've also attempted a first draft of a schematic for this project (attached).  It assumes the use of transistors but does not include the connections to the Uno.  I plan to have the columns connect to "digital" pins 0-13 and "analog" 0-1, while the rows will connect to "analog" 2-5.  Thoughts?  Am I tracking in the right direction?

Nickity - I am planning on "diffusing" the LEDs by sanding them.  While this won't diminish the brightness, I hope it will prevent the need for sunglasses.

retrolefty

#13
Jan 30, 2013, 07:35 pmLast Edit: Jan 30, 2013, 07:37 pm by retrolefty Reason: 1
So, I've gone back to a 4x4x4 and am having a conversation with myself regarding the need for transistors.  As the Uno can utilize 20 pins (16 columns, 4 rows) as digital pins and because of multiplexing, shouldn't I be able to (safely) get away without transistors?

No. Think about a given pattern you may want to display that turns on all 16 leds of a single level (Row) going to a single output pin driving that row. That could be 16 X 20 milliamos of current which is more then the poor row enable pin can supply, hence the need to use 4 switching transistors to drive the 4 levels (Row). That make sense?

Regardless, I am amidst some heady (for me) reading on transistors and hope to understand the use of them for this project if necessary.  I have some 2N2222's here and was initially planning on using these on the rows but am having some serious trouble understanding the calculations behind choosing correct resistors to use with the transistors.  Any "beginner language" help would be greatly appreciated.

A 2N2222A transistor is really not able to switch 16 x 20ma of current, you need a 'bigger' transistor.

I've also attempted a first draft of a schematic for this project (attached).  It assumes the use of transistors but does not include the connections to the Uno.  I plan to have the columns connect to "digital" pins 0-13 and "analog" 0-1, while the rows will connect to "analog" 2-5.  Thoughts?  Am I tracking in the right direction?

Keep in mind that pins 0 and 1 are used to upload sketches into your chip, so you may need to be able to easily remove things you wire to pins 0 and 1 when you need to upload a sketch and then reattach them.

Nickity - I am planning on "diffusing" the LEDs by sanding them.  While this won't diminish the brightness, I hope it will prevent the need for sunglasses.

Others have tried many methods of manually diffusing clear leds with rather poor effect, including sanding, painting, etching, etc. But maybe you will have better luck. One thing is clear that led cubes should definitely utilize diffused leds, otherwise the visual effects lose a lot if the leds have narrower output beam, making the angle of viewing of the cube poor, the effects just won't be as good as using diffused leds.
Lefty

SirNickity

#14
Jan 30, 2013, 08:23 pm
I built an indicator out of various 3mm colored LEDs.  The red, green, yellow, and blue LEDs were all diffused, but the white was clear.  I sanded it with a fine sandpaper and it turned out great.  Easy does it though, a little goes a long way.  I canned my first attempt because I had sanded several flat spots into it.  ;-)  (Technically, I didn't can it, I just use it for breadboard projects where I don't care about the visual quality.  Why waste a good LED?)

At the risk of being a FET pusher, try a small MOSFET instead.  This is the perfect sort of application for them.  You should use a small (100-200R will do fine) resistor for good measure, but the FET gate (analogous to the base of a BJT) has a high impedance, so there's no need to current limit or calculate gains.  You'll need a logic level FET.

I use VN10LPs for moderate current (270mA) -- here's a link to Digikey: http://www.digikey.com/product-detail/en/VN10LP/VN10LP-ND/92610

If you're driving them all at a full 20mA, you'll need something with more gusto.  Here's a ZVN4206A good for 600mA:  http://www.digikey.com/product-detail/en/ZVN4206A/ZVN4206A-ND/92604

Those are both N-channel, so you'll be switching between the LED and ground.  (Same as NPN.)

Go Up