Shop OBEX P1 Docs P2 Docs Learn Events
Connecting Stamp 2e input/output pins to +5/Gnd. Is this safe? — Parallax Forums

Connecting Stamp 2e input/output pins to +5/Gnd. Is this safe?

dgersicdgersic Posts: 10
edited 2008-07-05 16:16 in BASIC Stamp
I'm powering the Stamp and the rest of the board I'm building with an external 5V switching power supply. For some user-selectable inputs, I'm using a set of DIP switches. There's a note on page 84 that says that connecting an input pin directly to +5V is potentially bad for the Stamp. Is that because a +5V supply could be well outside the "5V" range? Do I need a current limiting / pullup resistor for the +5V here, with the DIP switch pulling the to ground when selected?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-07-03 04:38
    Current limiting and pullup are two different things and are used much differently. If you could draw a diagram of your curcuit it would help. You most definitely need a resistor between any pin and ground or power.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 05:10
    As long as the +5V supply is the same one that powers the Stamp, the +5V on the input pin would never be higher than the +5V supply to the Stamp. If the input pin becomes more positive than 0.6V above the +5V supply, then you have a short circuit through one of the input protective diodes to the +5V Stamp supply. Something will blow in the Stamp.

    You could also accidentally program the I/O pin as an output, then get a short circuit across the power supply through the output transistor in the Stamp I/O pin circuitry. Something will blow in the Stamp.

    A 220 Ohm series resistor would limit any "fault current" through the I/O pin to about 25mA which the I/O circuitry can withstand indefinitely.
    Except in a few specific circumstances, it should not interfere with other uses of the I/O pin. That's why the HomeWork Board has built-in 220 Ohm resistors in series with all of the I/O pins.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-07-03 14:26
    Typically, you have a 220 ohm resistor in series with the I/O pin for current limiting purposes. Then, you have a 10 Kohm "Pull-up" resistor to give that pin a "1" value when the switch is "open". Then, you connect the other end of the switch to ground, to give a "0" value when the switch is closed.

    One thing people don't realize when they're starting out is that an Input pin not connected to +5 or GND through some 10K resistor is "floating". Meaning it doesn't HAVE a +5 or GND or "1" or "0" value, it "floats". Usually what does happen to the wire in this case is that it will pick up 60 Hz 'noise' -- which looks like a "1" or a "0" depending on when you read the pin. This is NOT a reliable way to use an Input pin.

    So the 10K "pull-up" resistor is there to give a reliable "1" to the line when the switch is open.
  • dgersicdgersic Posts: 10
    edited 2008-07-03 14:30
    Stephen: I understand the difference, the question was more about the need. Not much to draw, just put a SPDT switch between +5, gnd, and an input pin, like the first image. It'll work, but am I risking the Stamp, given that the +5 here is an actual 5VDC from an external power supply?

    What I actually need is an SPST switch (DIP switch type), though, so something like the second image, with the same +5 supply. The current source has a resistor, Gnd doesn't need one, and the switch makes the input pin high or low. I was going to use a 1K resistor here. Safe enough?

    Thanks.
    557 x 594 - 37K
    566 x 601 - 39K
  • dgersicdgersic Posts: 10
    edited 2008-07-03 14:47
    Mike:
    Mike said...

    As long as the +5V supply is the same one that powers the Stamp, the +5V on the input pin would never be higher than the +5V supply to the Stamp. If the input pin becomes more positive than 0.6V above the +5V supply, then you have a short circuit through one of the input protective diodes to the +5V Stamp supply. Something will blow in the Stamp.

    Thanks, that's what I was trying to understand. Given that it's all the same +5, I was trying to make sense of how anything could be damaged by it. I couldn't see a voltage potential there.

    Mike said...

    A 220 Ohm series resistor would limit any "fault current" through the I/O pin to about 25mA which the I/O circuitry can withstand indefinitely.

    Except in a few specific circumstances, it should not interfere with other uses of the I/O pin. That's why the HomeWork Board has built-in 220 Ohm resistors in series with all of the I/O pins.

    So, best possible setup here is like the attached image, with a 1K pullup, a 220 in series, and a DIP switch. I'm not using a homework board, it's not big enough for the other part of what I'm doing on the outputs, just a breadboard.

    Thanks.
    581 x 614 - 41K
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 14:47
    If you never make a programming error that might possibly change the I/O pin to an output, you would be ok with the 2nd case. A 1K resistor is lower than you need, but ok. 4.7K or 10K is more commonly used.

    The reason for the 220 Ohm resistor is to protect the I/O pin from the consequences of a mistake, an accident, not from normal expected use. Such an accident would destroy the Stamp I/O pin, but it's unexpected.
  • dgersicdgersic Posts: 10
    edited 2008-07-03 14:50
    Mike:

    I'm a programmer. Of course I never make mistakes. wink.gif
  • dgersicdgersic Posts: 10
    edited 2008-07-03 14:52
    Gah. 1K should have been 10K there. Sorry, it's early still, the caffiene hasn't quite kicked in yet. Like I said, I never make mistakes.
  • dgersicdgersic Posts: 10
    edited 2008-07-03 14:54
    allanlane5 said...

    One thing people don't realize when they're starting out is that an Input pin not connected to +5 or GND through some 10K resistor is "floating". Meaning it doesn't HAVE a +5 or GND or "1" or "0" value, it "floats". Usually what does happen to the wire in this case is that it will pick up 60 Hz 'noise' -- which looks like a "1" or a "0" depending on when you read the pin. This is NOT a reliable way to use an Input pin.

    Allan:

    Right, I knew that part, but thanks for the warning.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-07-03 16:43
    Well, your last picture is correct, except the 10K and 220 ohm resistors should be connected to each other -- giving you your 'default "1" ' when the DIP is open. And one end of the DIP switch should be connected to that SAME node of the 10K and 220 connection, and its other end to ground. Then you'll have the whole thing.

    By the way, they DO make "SIP" (Single In-Line Package) networks of 10K resistors. Tie one pin of the network to +5, and all the other pins of the SIP are the "other" ends of the 10K resistors. Saves a LOT of space and wires.
  • dgersicdgersic Posts: 10
    edited 2008-07-05 16:16
    allanlane5 said...
    Well, your last picture is correct, except the 10K and 220 ohm resistors should be connected to each other -- giving you your 'default "1" ' when the DIP is open. And one end of the DIP switch should be connected to that SAME node of the 10K and 220 connection, and its other end to ground. Then you'll have the whole thing.

    Gah. That's what I thought I drew, but you're right, I didn't. It's what I meant to draw.
    allanlane5 said...
    By the way, they DO make "SIP" (Single In-Line Package) networks of 10K resistors. Tie one pin of the network to +5, and all the other pins of the SIP are the "other" ends of the 10K resistors. Saves a LOT of space and wires.

    Yep, those are good for the pullups, but not so handy for the current limiting resistors.
Sign In or Register to comment.