Connecting Stamp 2e input/output pins to +5/Gnd. Is this safe?
dgersic
Posts: 10
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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.
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.
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.
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.
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.
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.
I'm a programmer. Of course I never make mistakes.
Allan:
Right, I knew that part, but thanks for the warning.
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.
Gah. That's what I thought I drew, but you're right, I didn't. It's what I meant to draw.
Yep, those are good for the pullups, but not so handy for the current limiting resistors.