Shop OBEX P1 Docs P2 Docs Learn Events
"What is a microcontroller" chap 2 questions — Parallax Forums

"What is a microcontroller" chap 2 questions

ToddHToddH Posts: 34
edited 2011-09-20 15:26 in Learn with BlocklyProp
I'm going through the "What is a microcontroller?" book. I have 2 questions about the LED test circuit exercise in chapter 2:

1) They have me use a 470 ohm resistor in the circuit. Why 470? Why not 1000 ohm or '??' ohm? Is there a formula that is used based on the 9 volt battery and the LED that I'm trying to light up?

second question:

2) The circuit is laid out as such: Vdd (+) --> Resistor -->LED ---> Vss (-)

If the current flows from negative to possitve, why isn't the resistor between the (-) and the LED rather than the (+) and the LED that is shown? Wouldn't you want the resistance to come as the current is flowing towards the LED (from the negative side)?

Thanks for any help!

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2004-12-31 19:07
    An LED can handle up to about 30mA of current, but is sufficiently bright with only a couple milli-amps.

    Using ohm's law, which describes the relationship of current (I), voltage (V)·and resistance(R):
    I = V/R = I=9V/470 ohm = .019 A or 19mA.·
    This is only a 'rough' approximation, since the LED will drop some voltage too.

    As to the placement of the resistor, in a series circuit it just doesn't matter on the placement.· The current flow is common to all, and the current is based on the total resistance in the path.· You can't have 100mA rushing to the LED, then only 20 mA leaving the LED to the resistor.

    Feel free to experiment with larger resistor sizes and to re-arrange the components.

    Good questions, it's nice when people want to know 'why's' instead of just following what the material tells you.

    -Martin Hebel
    Southern Illinois University Carbondale
    Electronic Systems Technologies
    http://www.siu.edu/~mhebel


    I'm going through the "What is a microcontroller?" book. I have 2 questions about the LED test circuit exercise in chapter 2:

    1) They have me use a 470 ohm resistor in the circuit. Why 470? Why not 1000 ohm or '??' ohm? Is there a formula that is used based on the 9 volt battery and the LED that I'm trying to light up?

    second question:

    2) The circuit is laid out as such: Vdd (+) --> Resistor -->LED ---> Vss (-)

    If the current flows from negative to possitve, why isn't the resistor between the (-) and the LED rather than the (+) and the LED that is shown? Wouldn't you want the resistance to come as the current is flowing towards the LED (from the negative side)?

    Thanks for any help!
  • ToddHToddH Posts: 34
    edited 2004-12-31 19:13
    "Ahhh!" on both accounts! Thanks much for your quick and complete answers [noparse]:)[/noparse]
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2004-12-31 19:25
    Welcome!
    (and·testing my signature updates)


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel

    Electronic Systems Technologies
    Southern Illinois University Carbondale
    Personal Links - ·Lot of BASIC Stamp info
    and
    SelmaWare Solutions
    StampPlot Pro Version 3 Release 4
    Now allows additional controls to be added, or developed!

    ·
  • iansmileriansmiler Posts: 4
    edited 2011-08-03 14:43
    I'm having a little trouble getting my head around this too.....

    In Fig 2-11 It is my understanding that the LED is spec'd as 20ma and that P14 is outputting 5V....

    If this is the case then shouldn't the resistor be 250 Ohm? As 5V / .02 Amps = 250 Ohm?

    Is it a typo or is there some black magic going on that I am not quite getting :D

    Ian
  • LeonLeon Posts: 7,620
    edited 2011-08-03 14:52
    You have a voltage drop across the LED of about 1.8 V. Look at a typical data sheet. 3.2 V /0.02 A = 160.
  • iansmileriansmiler Posts: 4
    edited 2011-08-04 04:49
    Then why does Fig 2-11 show a 470 Ohm resistor???
  • LeonLeon Posts: 7,620
    edited 2011-08-04 06:30
    To draw less current?
  • iansmileriansmiler Posts: 4
    edited 2011-08-04 06:52
    Ya - I get that... but I'm a controls guy and I see in Black and White!!! Is there any logic behind using the 470 Ohm as opposed to a 160 Ohm resistor? Or did they just randomly pick a resistor that they new would work within a certain range? I need closure >.<

    Thanks for the replys btw ;-)
  • piguy101piguy101 Posts: 248
    edited 2011-08-04 09:52
    There's no logic behind the 470 ohm resistor, you could use any resistor between 160 and a couple thousand ohms. 470 ohm is just a common and cheap resistor that will work the LED. You don't need to have exactly 20mA going through the LED, if fact you want a little less than 20mA something like 10-15mA, this is to extend the life time of the LED.
  • iansmileriansmiler Posts: 4
    edited 2011-08-05 16:29
    Lovely!!! I can now sleep soundly :D

    I hate grey areas! Thanks ;)
  • DamilesDamiles Posts: 1
    edited 2011-09-03 08:07
    iansmiler wrote: »
    Ya - I get that... but I'm a controls guy and I see in Black and White!!! Is there any logic behind using the 470 Ohm as opposed to a 160 Ohm resistor? Or did they just randomly pick a resistor that they new would work within a certain range? I need closure >.<

    Thanks for the replys btw ;-)

    I agree with the other replies. However, you should also keep the sinking/source limits of the BS2 micro controller in mind as well. Especially if you start experimenting with several LED's at once. This is copied and pasted from the BS2 Data sheet:

    "General-purpose I/O pins: each can source and sink 30 mA. However, the total of all pins should not exceed 75 mA (source or sink) if using the internal 5-volt regulator. The total per 8-pin groups P0 – P7 or P8 – 15 should not exceed 100 mA (source or sink) if using an external 5-volt regulator."

    So now if you use Ohm's law combined with "Fan In/Out specs," it may make more since as to why the Parallax folks are using a higher value resistor in their manuals.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-09-03 11:28
    Another thing to consider ... The voltage drop across an LED depends on the color of the LED and the materials used in its construction. A typical red LED drops about 1.7V. A blue or "white" LED typically drops about 3.1V. With a 470 Ohm resistor, the LED current will be (5.0V - 1.7V) = 3.3V / 470Ohm = about 7mA with a red LED and (5.0V - 3.1V) = 1.9V / 470 Ohm = about 4mA. Both are within the limits of the I/O pin an high enough to provide light.
  • ajwardajward Posts: 1,130
    edited 2011-09-03 17:24
    Mike Green wrote: »
    Another thing to consider ... The voltage drop across an LED depends on the color of the LED and the materials used in its construction. A typical red LED drops about 1.7V. A blue or "white" LED typically drops about 3.1V. With a 470 Ohm resistor, the LED current will be (5.0V - 1.7V) = 3.3V / 470Ohm = about 7mA with a red LED and (5.0V - 3.1V) = 1.9V / 470 Ohm = about 4mA. Both are within the limits of the I/O pin an high enough to provide light.

    I wasn't aware of those differences! Thanks Mike!

    Amanda
  • sakibmoonsakibmoon Posts: 5
    edited 2011-09-20 15:18
    I am not very knowledgeable about this, but as far as I know the current rating of LED is 20-25 mA. Here, we get the current is either 4mA or 7mA. Isn't it too low?
  • PublisonPublison Posts: 12,366
    edited 2011-09-20 15:25
    sakibmoon wrote: »
    I am not very knowledgeable about this, but as far as I know the current rating of LED is 20-25 mA. Here, we get the current is either 4mA or 7mA. Isn't it too low?

    I think Mike spelled it out in post #14. Is there still something you do not understand?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-09-20 15:25
    It depends on the LED. Some will put out a lot of light with only 5 to 10mA of current and some will not. If you're running your circuit off batteries, you want to use the minimum amount of current that will produce as much light as you need (or want).
  • LeonLeon Posts: 7,620
    edited 2011-09-20 15:26
    Modern LEDs provide plenty of light at 5 mA or less.
Sign In or Register to comment.