I/O Pin Voltage/Current Requirements
Bill M.
Posts: 4
I am new to the Basic Stamp, and I am trying to read a switched voltage on an I/O pin using the BUTTON function.··I want to be clear of how the i/o pins work.· The specifications say that each pin can sink/source ~25mA, and I read that each pin has an input impedance of 1Mohm.· If the input impedance is so large, then why can't I directly connect the switch from Vdd to the pin?· It seems to me that with the given input impedance, the input current should be on the order of a uA (Vi/Ii = Ri = 10^6).· I would like to use the Button function to branch when Vdd is switched to the I/O pin.· I noticed in the 'What's a Microcontroller' book that they prefer to implement button switches to correspond to logic 0.· Can anyone clarify this for me?·
Comments
If what you're wanting is a variable (bit) to be 1 when the input is active, you can do this with an active-low circuit:
· theBtn = ~IN0
The tilde operator inverts the variable it's attached to, so when the actual input is zero (active), the value moved into 'theBtn' will be 1.· What is important is to pull the input pin to the opposite state (usually through 10K) so that the high-impedance input of the microcontroller is not affected by noise.· And we recommend a 220-ohm inline resistor to protect the pin in the even of a programming error (that causes the pin to be a driven ouput when the button is pressed).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/26/2005 1:49:10 PM GMT
You say that a 220 Ohm inline resistor is recommended to protect the pin in the event of a programming error that makes the pin an output.··I understand the need for the inline resistor but am unsure of the value.· Your post says 220 Ohm but your attached diagram shows a 220 KOhm inline resistor.· I would have though 220 Ohm would be too low and 220 KOhm too high.· I always beleived - and my reasoning for this may be wrong - that the correct amount was about 1 KOhm.· How does one calculate the value of this inline resistor ?
Regards,
Nav.
Update: I've attached a corrected schematic to the original post.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/26/2005 1:49:48 PM GMT