Shop OBEX P1 Docs P2 Docs Learn Events
SX20 Source current. — Parallax Forums

SX20 Source current.

ElectronegativityElectronegativity Posts: 311
edited 2005-08-30 16:59 in General Discussion
Hi guys (gals?), I am planning to hook up an SX20AC/SS chip to Lumex LED display.
The display is rated for 25mA maximum continous current per segment or 150mA for < 10uS.

If I run the display cathode to ground and hook SX20 outputs directly to the segment pins will it fry the display?

What if I put a resistor between the cathode pin and ground?

I also noticed that the SX20 has 2 pins each for Vdd and Vss; do I need to hook all 4 of them up?

Thanks,
-Alexander

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I wonder if this wire is hot...

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-29 16:49
    Alexander,

    ·· You should always have current limiting resistors in series with LEDs, especially when you're driving them directly from the I/O pins.· If you're going to do this, you should strobe the outputs at high speed so that they appear to be on at the same time when displaying a digit, but they would actually be lit one at a time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-29 20:24
    Hi Chris:

    What is the current limit for a particular resistor?

    For example, what would be the current if I put a 10k resistor directly to ground from an output pin.

    Would the above example damage an SX chip?

    I have been thinking of doing something like the above example to detect if a dip-swich or jumper is set.
    The pin would be pulled high, but would read low if connected to ground.

    Thanks,
    -Alexander

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • John CoutureJohn Couture Posts: 370
    edited 2005-08-29 20:46
    To find current for a circuit (If I understand Ohms Law correctly).

    The chip will output up to 5 volts (assuming a 5VDC source), the resistor is 10K. Using the formula I=V/R (current = Volts / Resistance)

    I = V / R

    I = 5 / 10000

    I = .0005 Amps (or 500uA, or .5mA)

    However, Chris Savage or Jon Williams better weigh in on this because that is what they do for a living (I just teach computer sci .... and try not to touch both wires at the same time).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-08-29 21:10
    Alexander said...
    I also noticed that the SX20 has 2 pins each for Vdd and Vss; do I need to hook all 4 of them up?
    yes.
    Alexander said...
    What is the current limit for a particular resistor?

    For example, what would be the current if I put a 10k resistor directly to ground from an output pin.

    Would the above example damage an SX chip?

    I have been thinking of doing something like the above example to detect if a dip-swich or jumper is set.
    The pin would be pulled high, but would read low if connected to ground.
    The current that flows through a resistor is the voltage across it's terminals divided by the value of the resistor, as John explained.
    The max per pin on an SX is 20mA I believe (maybe 25?), but as a safety margin don't exceed 15mA. Also you will have to make sure that the total current of all I/O pins does not exceed the maximum for the chip, IOW you cannot drive all the pins at their individual maximums because you will exceed the overall maximum. You example would not fry your SX20. If you are simply trying to read a DIP switch, you would setup the pin as an input and have the following configuration:

     
       ^ Vdd
       |
       \
       /  10K Ohm
       \
       /
       |
       |  \ Switch
    SX-+-- \---
               |
             __|__   
              ___  GND
               _
     
     
    

    Since the SX pin is configured as input, the current flowing through the SX pin is negligable. If the switch is on the SX will see a 0, if it is off it will see a 1.

    Now for LEDs, they have a voltage drop across them when they are turned on (Vf), so to calculate the correct value for your resistor, use: R=(Vdd-Vf)/I, where I is the desired current, not to exceed the maximum current for the SX pin, then choose the closest value of resistor that is higher than the resistance you calculated. Never drive an LED without a current limiting resistor, even if you are doing switching to limit the overall current, if there is a bug in you program, or if you program hangs while the pin is on, you will fry your LED and perhaps even the SX. If the number of elements you have to drive requires more than the total current the SX20 can handle, you will have to use a driver for the LEDs such as a darlington array.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-29 21:34
    ·· I think these gentlemen has summed this up pretty well for now.· Just remember, when LEDs are rated x amount of milliamps, that's what you need to adjust, not what it will use by default.· If you wire it directly to Vdd it will take what it can get.· The Resistor is there to limit the current to the specifications.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-29 22:44
    Hi all, thanks for the input.

    John: Your calculation would be correct if the SX could source one amp per pin.

    According to the documentation, the SX20 can source 30 milliamps per pin with an absolute maximum value of 45 milliamps per pin.

    I read the entire document ( http://www.parallax.com/dl/docs/prod/datast/SX2028AC.pdf ) without seeing an explicit reference to a maximum total current sourced by all pins, but there is something in there that says the power dissapation is 700 milliamps. If this is the correct value then there is no need to worry since running all 12 output pins at their absolute maximum rating would only source 540 milliamps. At the normal output level the sum would be 360 milliamps.

    Someone please correct me if the above calculation is wrong!

    Paul: I am confused by your diagram; do you have one pin connected to both ground (through the switch) and Vdd?
    It looks like throwing the switch would create a short circuit directly from Vdd to ground through the 10K resistor.
    is there anything wrong with setting the pin as an output, pulling it high internally, then connecting it to ground through a resistor and a switch so the read command would give 1 if the switch is open and 0 if it is closed?

    Using R = (Vdd-Vf)/I with Vdd = 5V, Vf = 2.5V and I = 20mA, I would need a 125K resistor.
    That seems a bit high, but I guess I can start with 125K and work my way down if it doesn't work or if it's too dim.


    Would an output pin burn out if I pulled it high internally and then hooked it directly to ground with no resistor?
    In order to use John's calculation I would have to know the maximum current that would actually come out of a pin if you pulled it high and connected it directly to ground.


    I don't mean to be annoying with all the questions, but I burned out half the segments on 3 LED displays over the weekend and would like to avoid a similar fate for the next batch.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...

    Post Edited (Electronegativity) : 8/29/2005 10:52:36 PM GMT
  • John CoutureJohn Couture Posts: 370
    edited 2005-08-30 00:45
    ================
    LED:

    An LED is basically a diode that emits light when power is going through it in the proper direction. If you forget to put a resister in line it will draw too much current and you'll burn it out. A light bulb is like an LED but with a resistor. The light bulb filament has enough resistance built in that limits the amount of current that it draws. Although a light bulb is rated in WATTS, that can be converted to Amps. The summary: LED's need resistors in line. 470 ohm is ok but you can go down to 330 in some cases. Much lower than that and you may draw too much current on the chip (MCU) and cause the MCU to heat up and fry some internal circuitry.

    A good discussion on this is available from What's a microcontroller? book (free Parallax download http://www.parallax.com/dl/docs/books/edu/wamv2_2.pdf). This book is often referred to as "WAM" in the forums. Specifically see page 40 through 45 in the manual (which is page 49-54 in the PDF)
    =====================
    Total Current for All LED's:

    As was stated in earlier posts, if you need to drive many LED's at the same time, have the chip (MCU) lite them in sequence but at high speed. That way they all look lit and yet it is not such a strain on the MCU. The total amount of current allowed at any momemt in the Ubicom SX is stated on page 39 of the datasheet under section 17.1, "Absolute Maximum Ratings". It states that "Max current out of Vss pin" is 130mA .... remember if you have a bunch of LED's lit at the same time the MCU has to GET that current from somewhere ... thus the restriction on how much current can travel through Vss (or Vdd for that matter).

    ==========================
    Connection to both +5VDC and ground:

    Paul's diagram does indeed connect the MCU pin to both +5vdc and ground. However, there is a 10K resistor between the pin and +5vdc and a switch between the pin and ground. This circuit implies two states: High (default) and Low (momentary). The high state is because there is always a trickle of current coming through the resistor. With a 10k resistor, only a very small trickle of current gets through. When you press the button, you open up a huge drain (think of a dry river culvert). The MCU thus reads the pin a being LOW.

    Chapter 4 in the WAM book referenced above has a great discussion about this. The book is a excellent source of fundamental information on electricity and electronics. I highly recommend going through it even if you only skim it. I am embarassed to admit how much I learned about electricity and electronics by forcing myself to go through this tutorial but I am also grateful and indebted to Parallax for providing such an excellent resource.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • John CoutureJohn Couture Posts: 370
    edited 2005-08-30 00:54
    Oops, that was Chapter 3 in WAM is the discussion about connecting the pin to both +5 and ground through resistors and switches.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-30 02:25
    My printer is chugging ink and spewing paper cool.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-08-30 12:25
    Electronegativity said...
    Hi all, thanks for the input.

    Paul: I am confused by your diagram; do you have one pin connected to both ground (through the switch) and Vdd?
    It looks like throwing the switch would create a short circuit directly from Vdd to ground through the 10K resistor.
    is there anything wrong with setting the pin as an output, pulling it high internally, then connecting it to ground through a resistor and a switch so the read command would give 1 if the switch is open and 0 if it is closed?

    Using R = (Vdd-Vf)/I with Vdd = 5V, Vf = 2.5V and I = 20mA, I would need a 125K resistor.
    That seems a bit high, but I guess I can start with 125K and work my way down if it doesn't work or if it's too dim.


    Would an output pin burn out if I pulled it high internally and then hooked it directly to ground with no resistor? YES
    In order to use John's calculation I would have to know the maximum current that would actually come out of a pin if you pulled it high and connected it directly to ground. Dont do this, don't ever try to force a pin to two different values.


    I don't mean to be annoying with all the questions, but I burned out half the segments on 3 LED displays over the weekend and would like to avoid a similar fate for the next batch. you aren't, your doing the right thing by asking questions rather than bullheadedly proceeding without understanding what is wrong.

    John answered the question regarding the operation of the circuit I posted, a short is a low resistance path between Vdd and ground, since the 10k Ohm resistor is there (causing 0.1 mA to flow when the switch is on), this is not a short.
    Electronegativity said...
    is there anything wrong with setting the pin as an output, pulling it high internally, then connecting it to ground through a resistor and a switch so the read command would give 1 if the switch is open and 0 if it is closed?
    Configuring the pin as output will not accomplish what you think it will, because the resistor is there, the voltage at the pin will be high, meaning if you try to read the pin, it will be a 1. The only way the output will not agree with the input, is by forcing the voltage at the pin itself to be low (by tieing it directly to ground), and this is how you·fry your SX.

    Your calculation is wrong, the units of measure used in the equation are Volts, Amps and Ohms. So plugging in the values you gave R = (5-2.5)/0.02 =·125 Ohms or 1/1000th the value you calculated.

    There seems to be some fundamentals of circuit design that are escaping you, read the WAM text, it covers many of the basic principles. Because you are working with LEDs and they are sensitive devices, they are burning out because you are connecting them improperly.·In a way, this is very fortunate for you because when the LED burns out, your SX pin is protected from this improper hookup; but do this with a more robust device and you will fry your SX.

    Diodes (including LEDs) are exponential devices, meaning a small change in the voltage across the device causes a large change in current flowing through it. The equation is:
    109c605701a37ae869c22ca9e2389ccc.png
    don't worry about what all those letters mean, just look at the VD, which is the voltage across the diode, and how·a small change in it causes a change in current on the order of·e(VD), this is a huge change, so by forcing the voltage across the diode to be twice what it expects it to be, you are creating a current flowing through it that is way beyond what it can handle. This is why the current limiting resistor is nessesary.
    ·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10

    Post Edited (Paul Baker) : 8/30/2005 12:35:27 PM GMT
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-30 16:30
    Thanks Paul, I see now that I mixed up milliamps and microamps. blush.gif

    What about a switch between two SX pins with one configured as input and the other as output?
    Would the chip fry itself without a resistor in between?
    If so then what value would you reccomend?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-08-30 16:59
    Electronegativity said...

    What about a switch between two SX pins with one configured as input and the other as output?
    Would the chip fry itself without a resistor in between?
    If so then what value would you reccomend?

    This would work, but if you are writing the value to the output, you already know its value (since you wrote the value), so this doesn't make sense to do, it just wastes two pins. Since one is input and the other is output, no resistor is needed, but if you want to prevent accidental mistakes from occuring due to improper programming, place a resistor between 220 and 1k ohms as a safety (470 is a good value). If you are using the output pin to pullup the line read by the input pin (ie the output pin·is always a 1), the output pin·is a wasted·pin, just use a pullup resistor like I showed in the circuit diagram.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
Sign In or Register to comment.