Arduino Forum

Using Arduino => General Electronics => Topic started by: macweenie on Jan 02, 2013, 06:18 pm

Title: A noob resistance question
Post by: macweenie on Jan 02, 2013, 06:18 pm
I think I understand that the reason you put a 220 ? resistor on the ground leg of an LED (such as in the 'blink' tutorial) is to dump any excess current as heat before it goes to ground, although if you are grounding it I'm not entirely sure why that is necessary. My question is if you use a 220 ? resistor on one LED could you use a 2.2k ? resistor and tie 10 LEDs to it? I'm not asking because resistor are so expensive or that I would prefer to use a rats nest of wires to accomplish the same task but just out of curiosity. It seems to make sense mathematically but I never see anyone doing it so if you CAN do it there must be some reason why you shouldn't and I just wondered why that is.
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 02, 2013, 06:21 pm
Quote
is to dump any excess current as heat before it goes to ground,

No it is not.
It is to drop the excess voltage and approximate a constant current drive.

Quote
My question is if you use a 220 ? resistor on one LED could you use a 2.2k ? resistor and tie 10 LEDs to it?

No, apart from being the wrong way round, for 10 LEDs it would have to be a smaller resistor not a larger one, the voltage drop is proportional to the current.

Read this:-
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html (http://www.thebox.myzen.co.uk/Tutorial/LEDs.html)
Title: Re: A noob resistance question
Post by: macweenie on Jan 02, 2013, 07:15 pm
Well, I can see I am going to have to do a LOT of work on the hardware side of this. From your link:

Quote
Like all math we can make the "proportion" bit into an equals if we put in a constant of proportionality, like this:-

V = k * I

The constant of proportionality is called "resistance" and so we write :-

V = R * I


In the first equation I am guessing 3.3V=(?)*40Ma? I have no idea what k stands for but the voltage should be the 3.3V the board runs at and the current is the 40Ma the pin puts out? If I thought I would have had any interest in electronics later in life I would have paid more attention in my high school electronics elective.

As for the second if it is 3.3V=220?*40Ma, and I am only guessing, how do you multiply ohms by Milliamps and come out with an answer that makes sense? Isn't that kind of like comparing apples to oranges or combining a tractor with a reading lamp?

This probably doesn't require a reply, what the link has illustrated for me is that I am going to have to take a class or something to figure out the electronics end.

Thanks for the reply.
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 02, 2013, 07:28 pm
Quote
and the current is the 40Ma the pin puts out?

No 40mA is the current that starts to cause damage if you pull it out of a pin.

The first formula is the derivation of ohms law, with the constant of proportionality being actually resistance.

Quote
if it is 3.3V=220?*40Ma,

It is NOT.
Ohms law says if you know any two quantities you can find the third.
So if you had 40mA flowing through 220R then the voltage across it would be:-
0.04 * 220 = 8.8V.
If you had 3.3V across a resistor of 220R then you would get a current through the resistor of:-
3.3 / 220 = 0.015 Amps or 15mA

Quote
how do you multiply ohms by Milliamps and come out with an answer that makes sense?

Because the units of ohms multiplied by the units of current produces the units of Voltage.
The multiplication of units should have been in your science 101.

One volt is defined as the amount of voltage required to push one amp of current through a resistance of one ohm.
Title: Re: A noob resistance question
Post by: oric_dan on Jan 02, 2013, 08:09 pm

Quote
is to dump any excess current as heat before it goes to ground,

No it is not.
It is to drop the excess voltage and approximate a constant current drive.


The other way to say this is that, the R in series with the Led is used to "limit the current"
to an acceptable value.
Title: Re: A noob resistance question
Post by: macweenie on Jan 02, 2013, 08:32 pm
Explained like that it makes sense to me. Believe it or not I used to understand ohms law but over the years spent in graphic design and asset management I have forgotten it. Once you reduced it to a 'solve for x' equation (voltage/current=resistance; voltage/resistance=current; resistance*current=voltage) it made sense. So if I were running my Arduino at 3.3V and needed to pull 15Ma from a pin I would need to use a 220? resistor BUT if I were running the board at 5V and needed 15Ma then I would need a 334? (or the next larger value). Also, I am assuming (incorrectly no doubt given my track record) that 15Ma is the amount of current needed for an LED to turn on. Okay NOW I think I understand why you would need a LOWER resistance for 10 LEDs than for 1 (3.3V=x*150Ma(10 LEDs*15Ma each)). Therefore x=a 33?  (or the next larger value)resistor.

Still wrong?
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 02, 2013, 09:08 pm
Quote
Okay NOW I think I understand why you would need a LOWER resistance for 10 LEDs than for 1 (3.3V=x*150Ma(10 LEDs*15Ma each)). Therefore x=a 33?  (or the next larger value)resistor.

Still wrong?
   

The maths is right but the electronics behind it is wrong. You can not use one resistor for more than one LED because the forward voltage drop of each LED is slightly different. So therefore each LED needs its own resistor.

Quote
Also, I am assuming ...... that 15Ma is the amount of current needed for an LED to turn on.

For a start it is milli Amps mA not mega Amps MA. Second no there is no set amount of current to turn on an LED, the smaller the current the dimmer it is. I have a white LED that is too bright to look at directly when it only draws 3mA. It depends on the specific LED. There is however a minimum voltage required to turn it on, normally called the forward voltage drop.
Title: Re: A noob resistance question
Post by: oric_dan on Jan 02, 2013, 09:53 pm

Quote
Okay NOW I think I understand why you would need a LOWER resistance for 10 LEDs than for 1 (3.3V=x*150Ma(10 LEDs*15Ma each)). Therefore x=a 33?  (or the next larger value)resistor.

Still wrong?
   

The maths is right but the electronics behind it is wrong. You can not use one resistor for more than one LED because the forward voltage drop of each LED is slightly different. So therefore each LED needs its own resistor.


Yeah, this is the usual consideration, but have you ever actually tried using just 1 series R
for multiple Leds? I'm just curious as to the actual results.

Quote

Quote
Also, I am assuming ...... that 15Ma is the amount of current needed for an LED to turn on.

For a start it is milli Amps mA not mega Amps MA. Second no there is no set amount of current to turn on an LED, the smaller the current the dimmer it is. I have a white LED that is too bright to look at directly when it only draws 3mA. It depends on the specific LED. There is however a minimum voltage required to turn it on, normally called the forward voltage drop.


Yeah, Leds come in old style [ie, poor efficiently], plus the newer medium- and high-output
devices. The latter will produce a lot of light for a couple of mA.


Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 02, 2013, 09:59 pm
Quote
Yeah, this is the usual consideration, but have you ever actually tried using just 1 series R
for multiple Leds? I'm just curious as to the actual results.

If the LEDs are of different colour then only the colour with the lower voltage will come on. Beginners often try and use RGB LEDs with only one resistor.

If the LEDs are of the same colour then they will not share the current equally and one will be brighter than the other. Maybe if running at more than half the maximum current one LED will have too much current and burn out a lot quicker.

If the LEDs are being controlled separately but still have one resistor. Then the brightness will depend on how many LEDs are turned on. This is what happens when beginners put one current limiting resistor on a seven segment display.
Title: Re: A noob resistance question
Post by: oric_dan on Jan 02, 2013, 10:10 pm
Quote
Maybe if running at more than half the maximum current one LED will have too much current and burn out a lot quicker.

Yeah, that's the baddie. Looking at this d/s, there is 33% tolerance on forward voltage,
could be bad.

http://www.surplustronics.co.nz/library/Mega-White-LED.pdf
Title: Re: A noob resistance question
Post by: macweenie on Jan 02, 2013, 10:23 pm
Grumpy_Mike, Telecommando, and oric_dan(333),

Thank you all for your help. I would like to say that I believe you have helped me to understand this subject better. I have read and reread your responses, followed your links, and bit by bit I THINK I may be getting a handle on this.

I know I can go to different websites and read what other people have done to set up, let's say an RTC, and I can mimic what they have done but I really want to understand WHY you put a capacitor here or need a resistor there or why the oscillator should be 32Mhz (forgive the capitalized M if it is incorrect please) instead of 16Mhz. Is there a good resource for electronic components that explains 1)this is what it is 2) this is what it does 3) this is how it works and 4) this is why you would want to use it? Not a cookbook as much as a compendium of ingredients and a cooks insight on how you might want to combine them.
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 02, 2013, 11:25 pm
Quote
32Mhz (forgive the capitalized M if it is incorrect please) instead of 16Mhz

Yep capitalisation is correct.  :)

It is tricky because all that knowledge often comes down to simple experience, and knowing what the particular circumstances are.
I usually say that given N engineers there will always be at least N+1 strongly held opinions about the correct design decisions.

That is why there are engineers who produce good designs and those who produce not so good ones.
There is such a lot to know and I think the trick is knowing just how much to take account of.

I have had many engineers work under me and they would all produce different designs but some were better than others. They all knew the same stuff but how they weighed it in the balance would be different.
At some levels it is as much an art as a science.
Title: Re: A noob resistance question
Post by: anorton on Jan 03, 2013, 03:23 am
I was about to start a thread on this very topic, but apparently it has been asked before! :)

After reading through the thread (and the links posted therein), I have a couple of questions:

1. When performing Ohm's Law calculations, what specifies the values for V and I?
V, to me, should be the supply voltage (3.3V or 5V would be what I'm using in this case).  And should I be the maximum allowable current to pull from the pin?  Just wanting to make sure... :)

2. What is the maximum allowable current draw for the 5V pin on an Arduino Uno?  From this page (http://arduino.cc/en/Main/ArduinoBoardUno), I see 50mA for the 3.3V pin, but nothing is listed for the 5V pin.

3. Can one model a switch/pushbutton similarly to an LED?  I ask this because a switch also has "infinite" resistance when not activated, but near 0 resistance when pressed.
Title: Re: A noob resistance question
Post by: retrolefty on Jan 03, 2013, 03:28 am
Quote
At some levels it is as much an art as a science.


Except artist aren't generally held to target costs and time to market goals. Hard to shine when the clouds of management call the shots.  ;)

Lefty
Title: Re: A noob resistance question
Post by: retrolefty on Jan 03, 2013, 03:38 am

I was about to start a thread on this very topic, but apparently it has been asked before! :)

After reading through the thread (and the links posted therein), I have a couple of questions:

1. When performing Ohm's Law calculations, what specifies the values for V and I?
V, to me, should be the supply voltage (3.3V or 5V would be what I'm using in this case).  And should I be the maximum allowable current to pull from the pin?  Just wanting to make sure... :)

40ma is absolute maximum, but 20-30 ma is a better maximum limit standard to stick to. Keep in mind due to internal resistance of the output pins the output voltage will sag as current draw from the output pin is increased. Just shows that there is a difference from fundamental principal and electrical reality of real world components. That is why the datasheet for devices are so important to study and understand a chip limits and capabilities.

2. What is the maximum allowable current draw for the 5V pin on an Arduino Uno?  From this page (http://arduino.cc/en/Main/ArduinoBoardUno), I see 50mA for the 3.3V pin, but nothing is listed for the 5V pin.

Because there is no exact answer. If the board is being powered via USB then there is a 500ma thermofuse that sets a maximum limit for the board and anything you wire up to it. But if powered from an external DC voltage source then there might be somewhat more but it depends on the exact DC voltage input as there is a heat dissipation limit for the on-board 5vdc voltage regulator. So hard answers are desirable but often allusive in the real world.

3. Can one model a switch/pushbutton similarly to an LED?  I ask this because a switch also has "infinite" resistance when not activated, but near 0 resistance when pressed.

No, totally different components, and a switch doesn't share all the characteristic of a switch and visa versa.

Title: Re: A noob resistance question
Post by: anorton on Jan 03, 2013, 03:46 am
40ma is absolute maximum, but 20-30 ma is a better maximum limit standard to stick to. Keep in mind due to internal resistance of the output pins the output voltage will sag as current draw from the output pin is increased. Just shows that there is a difference from fundamental principal and electrical reality of real world components. That is why the datasheet for devices are so important to study and understand a chip limits and capabilities.

Ok.

Quote
Because there is no exact answer. If the board is being powered via USB then there is a 500ma thermofuse that sets a maximum limit for the board and anything you wire up to it. But if powered from an external DC voltage source then there might be somewhat more but it depends on the exact DC voltage input as there is a heat dissipation limit for the on-board 5vdc voltage regulator. So hard answers are desirable but often allusive in the real world.

Hmmm... Ok.  Where do I find the information for the on-board 5vdc regulator?

Quote
No, totally different components, and a switch doesn't share all the characteristic of a switch and visa versa.

:-\  Just when I thought I found a shortcut... ;)  Ok. 
Title: Re: A noob resistance question
Post by: oric_dan on Jan 03, 2013, 03:56 am
Quote
When performing Ohm's Law calculations, what specifies the values for V and I?
V, to me, should be the supply voltage (3.3V or 5V would be what I'm using in this case).


No, V is actually the voltage "drop" across the resistor. Eg, if 1K is tied between 5V and
3.3V, the current I = Vdrop / R = (5V - 3.3V) / 1K = 1.7 mA, and not 5 mA or 3.3 mA.
Title: Re: A noob resistance question
Post by: anorton on Jan 03, 2013, 04:21 am

Quote
When performing Ohm's Law calculations, what specifies the values for V and I?
V, to me, should be the supply voltage (3.3V or 5V would be what I'm using in this case).


No, V is actually the voltage "drop" across the resistor. Eg, if 1K is tied between 5V and
3.3V, the current I = Vdrop / R = (5V - 3.3V) / 1K = 1.7 mA, and not 5 mA or 3.3 mA.

In your example, you mean a 1K(ohm) resistor, right?  (just making sure--I'm really new, if you haven't figured it out yet.  :smiley-red:)

So, in this LED (https://www.sparkfun.com/products/9590) (for example), it says "forward voltage drop" is 1.8V-2.2V (DC).  Let's say I have a circuit that has 5V---LED---1K(ohm)---Gnd.  I want to find the current.  I = Vdrop / R = 2.2V / 1K = 2.2mA.

Right?  Or am I still confused... :/
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 03, 2013, 06:03 am
No with a forward voltage drop on the LED of 2.2V the drop across the resistor is 5 - 2.2 = 2.7 V
You can not use ohms law for an LED it does not work because it is a non linear device. Only the resistor.
Title: Re: A noob resistance question
Post by: JimboZA on Jan 03, 2013, 06:15 am
Quote
32Mhz (forgive the capitalized M if it is incorrect please)


The M's right, but the h's not.... Hertz's symbol is Hz, so you should write MHz
Title: Re: A noob resistance question
Post by: JimboZA on Jan 03, 2013, 06:35 am
My tuppence worth....

I think what might not be becoming clear to messrs anorton and macweenie yet, is the notion that all of the voltage across the LED and its resistor has to be accounted for: the 5v in the 5V---LED---1K(ohm)---Gnd scenario has to disappear by the time we get to the right hand end.

So here's how it all hangs together....

1) What's the input voltage? We're saying 5v, so we have that.
2) What's the voltage we must account for over the LED? Manufacturer will tell us, let's go with the 2.2V mentioned earlier
3) So what voltage must we disappear over the resistor? We started with 5, accounted for 2.2, so we have 2.8 left to drop over the resistor
4) How are we doing with Ohm's Law for the resistor so far? Well we don't know R, that's what we need to calculate; we do know the voltage (2.8v); we don't know the current....
5) But we do know that in a series circuit like this, the current through the LED has to go through the resistor: there's no other path. And we do know (or manufacturer will tell us) that it's 20mA, or 0.020A... this is the value to which we need to limit the current, the object of the exercise.
6) So now we can apply Herr Ohm to the resistor with R=V/I giving R=2.8/0.02 = 140 Ohm

EDIT:

This is all a consequence of Kirchoff's Voltage Law which Wikipedia (http://en.wikipedia.org/wiki/Kirchhoff's_circuit_laws) describes thusly:

Quote
The algebraic sum of the products of the resistances of the conductors and the currents in them in a closed loop is equal to the total emf available in that loop.


The products of the resistances of the conductors and the currents is simply the voltages (Ohm's Law).

Do we have a loop though? The 5V---LED---1K(ohm)---Gnd doesn't look like a loop... but it is if you think of the 5v and Gnd being eg the two terminals on a battery... then it would look like a loop: 5V---LED---1K(ohm)---Gnd---Battery---5v

So now we can see Kirchoff's Voltage Law at work in our simple circuit...

1) Total EMF available in loop: 5V
2) Sum of the voltages in the loop: Vled + Vresistor = 2.2 + Vresistor
3) So 5 = 2.2 + Vresistor or Vresistor = 5 - 2.2

Does that help?
Title: Re: A noob resistance question
Post by: oric_dan on Jan 03, 2013, 07:06 am
Quote
No, V is actually the voltage "drop" across the resistor. Eg, if 1K is tied between 5V and
3.3V, the current I = Vdrop / R = (5V - 3.3V) / 1K = 1.7 mA, and not 5 mA or 3.3 mA.
In your example, you mean a 1K(ohm) resistor, right?  (just making sure--I'm really new, if you haven't figured it out yet.  )

So, in this LED (for example), it says "forward voltage drop" is 1.8V-2.2V (DC).  Let's say I have a circuit that has 5V---LED---1K(ohm)---Gnd.  I want to find the current.  I = Vdrop / R = 2.2V / 1K = 2.2mA.

Right?  Or am I still confused... :/


Yeah, the other guys are correct, and as I said you use "the voltage "drop" across the resistor"
to get the current through it. Ohm's Law is for resistors.

Title: Re: A noob resistance question
Post by: anorton on Jan 03, 2013, 03:44 pm
JimboZA's post really cleared it up for me--I needed that background information that is probably really basic to a lot of people here... :)

Thanks, everyone, for all your help!

//Andrew
Title: Re: A noob resistance question
Post by: macweenie on Jan 06, 2013, 03:56 am
Thanks JimboZA,

Although I got a great deal of information before your post, you gave me the piece of the puzzle I was lacking. I hadn't understood just WHERE the current I needed to power, in this case, an LED was coming from. Having looked briefly at the datasheets for different chips and sensors I wasn't making the now obvious connection that the items current requirements was in there. I was under the assumption that 15mA (right?) was the rule of thumb for ALL LEDs, but now it's so obvious I could face-palm.

So using the following datasheet:

(http://www.freeimagehosting.net/t/9hpg6.jpg) (http://www.freeimagehosting.net/9hpg6)

I would subtract 4V (maximum forward voltage) from the 5V the Arduino is putting out to get a drop voltage of 1V which using V = r * I would be 1V = r * 20mA or 1 / .2 = a 5 ? resistor? I combed the datasheet for any other values that looked right but theses were the only ones that seemed to fit the bill.
Title: Re: A noob resistance question
Post by: retrolefty on Jan 06, 2013, 04:00 am
Quote
or 1 / .2 = a 5 ? resistor?


No .2 is 200 ma, you need to use .02 in your calculation.

Lefty
Title: Re: A noob resistance question
Post by: macweenie on Jan 06, 2013, 04:09 am
The moment I hit post I knew I screwed up, but the dog asked to go out and you caught it before I could fix it :smiley-red:.

so it should be a 50? resistor... Do you know HOW I know I want to learn this? Because I keep on trying even though I have been wrong 100% of the time!
Title: Re: A noob resistance question
Post by: retrolefty on Jan 06, 2013, 04:51 am

The moment I hit post I knew I screwed up, but the dog asked to go out and you caught it before I could fix it :smiley-red:.

Oh, the old "the dog eat my correct posting" excuse, go to the corner.  ;)

so it should be a 50? resistor... Do you know HOW I know I want to learn this? Because I keep on trying even though I have been wrong 100% of the time!
Title: Re: A noob resistance question
Post by: fungus on Jan 06, 2013, 09:38 am

No with a forward voltage drop on the LED of 2.2V the drop across the resistor is 5 - 2.2 = 2.7 V


Are you sure?
Title: Re: A noob resistance question
Post by: fungus on Jan 06, 2013, 09:43 am

Thanks JimboZA,

Although I got a great deal of information before your post, you gave me the piece of the puzzle I was lacking. I hadn't understood just WHERE the current I needed to power, in this case, an LED was coming from.


Glad you understand it.

Now you're getting good a reading datasheets, the second thing you need to look at is the graph of voltage vs. current and the min/max range of voltages that the LED needs. As you'll see the graph shows that ass you approach maximum current, even minor variations in voltage (eg. 0.1V) can produce <b>huge</b> difference differences in current. The LEDs voltage tolerances are often more than 0.1V either way, so what voltage do you aim at...?

This is why controlling LEDs with resistors is a bad idea, and why they make special chips for driving LEDs - you need to control the current, not the voltage.
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 06, 2013, 05:59 pm
Quote
This is why controlling LEDs with resistors is a bad idea,

It is not a bad idea it is done all the time in a lot of professional applications and is quite satisfactory technique. It is not the technique to get the absolute exact control over the current but often this is not necessary.
Title: Re: A noob resistance question
Post by: macweenie on Jan 06, 2013, 09:53 pm
Quote
The LEDs voltage tolerances are often more than 0.1V either way, so what voltage do you aim at...?


Well fungus, I would say that I would add the 0.1V to the 4V maximum forward voltage so 5V - 4.1V = 0.9V drop voltage, then to calculate the resistor needed (if I use a resistor vs a chip) it would be 0.9V / .02mA = a 45? resistor (or the next larger value), HOWEVER since I am always wrong about these things my gut is telling me to SUBTRACT 0.1V from the 4.0V BECAUSE it is the MAXIMUM forward voltage and if it is maximum then I can't go beyond it right? So 5V - 3.9V = 1.1V and 1.1V / .02mA = a 195? resistor (or the next larger value). I am aware that you may have been asking a rhetorical question, but I wasn't sure.
Title: Re: A noob resistance question
Post by: fungus on Jan 06, 2013, 10:17 pm

I am aware that you may have been asking a rhetorical question, but I wasn't sure.


It was rehetorical. The correct answer is not to aim for a voltage.
Title: Re: A noob resistance question
Post by: fungus on Jan 06, 2013, 10:18 pm

Quote
This is why controlling LEDs with resistors is a bad idea,

It is not a bad idea it is done all the time in a lot of professional applications and is quite satisfactory technique. It is not the technique to get the absolute exact control over the current but often this is not necessary.


If you're aiming at 10-12mA (or less) on a 20mA LED, sure. The power curve is usually quite flat there.

If you're aiming at 20mA on a 20mA LED then resistors simply don't work.
Title: Re: A noob resistance question
Post by: macweenie on Jan 07, 2013, 01:32 am
Since you brought it up, I was wondering, How does using an LED Driver IC differ from powering the LEDs through a PWM enabled pin? Couldn't I use a shift register IC on a PWM pin to get the same result? Not that I have any immediate plans.
Title: Re: A noob resistance question
Post by: Grumpy_Mike on Jan 07, 2013, 02:46 pm
Quote
How does using an LED Driver IC differ from powering the LEDs through a PWM enabled pin

Rather the same way as driving a car differs from making a cake. No relationship whatsoever.
Title: Re: A noob resistance question
Post by: fungus on Jan 07, 2013, 03:27 pm

How does using an LED Driver IC differ from powering the LEDs through a PWM enabled pin?


It's completely different.

Not all ICs do PWM.

The IC will clamp the LED current to a fixed value (eg. 20mA), independent of voltage.