Shop OBEX P1 Docs P2 Docs Learn Events
Unknown input — Parallax Forums

Unknown input

NosePickerNosePicker Posts: 54
edited 2008-07-10 16:08 in BASIC Stamp
I am trying to learn how to monitor an input pin on a Basic Stamp II. I have it on a test breadboard with a 6v power supply.
I have written several test programs like make an led blink and everything seems to work as expected.
However I wrote this simplt program and had nothing hooked to pin 8 and got the following results:
As you can see the input pin appears to report random values as to if it is high or low with nothing hooked to it at all.
Is this normal?

<<<<< Program code >>>>>
input 8 
checkpin: 
  if IN8 = 0 then ison 
    debug "0," 
    pause 1000 
    goto checkpin 

 
ison: 
  debug "1," 
  pause 1000 
  goto checkpin

<<<<<< Results >>>>>>>

0,0,1,0,1,0,0,1,1,1,0

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks

NosePicker

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-10 03:30
    This is normal. If nothing is connected to an input pin, what you have is a high impedance input stage with a threshold of maybe 1.5V. Any voltage on that pin above that gets read as a one. Anything below that gets read as a zero. This input is extremely sensitive to static potentials, induced currents from adjacent wiring, the phase of the moon, etc.
  • DJSandbergDJSandberg Posts: 56
    edited 2008-07-10 03:42
    NP,

    If you put a 10,000 ohm resister from IN 8 to ground, this will give you 0,0,0,0,0,0,0,0.· If you hook the resister to +Voltage, you will get 1,1,1,1,1,1,1.

    Daryl
  • David H.David H. Posts: 78
    edited 2008-07-10 12:59
    Nosepicker,

    This situation Mike explained is called "floating". When you have a circuit hooked up, and you are looking for a high signal, you want the pin to always read a low in a neutral state. That's why you would put a 10K ohm resistor from the pin to ground, like Daryl stated. Then the basic stamp will see a "0" all the time, until a high signal is applied to that pin. Then the resistor link is basically ignored by the basic stamp, and it will read the high signal.
    Good luck with the projects.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    David


    There are 10 types of people in this world,...
    Those that understand binary numbers, and those that don't!!!
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-07-10 15:59
    And yes, a "Floating" pin reads whatever RF is in the vicinity -- usually the 60Hz power mains frequency. So it WILL look like noise.
  • NosePickerNosePicker Posts: 54
    edited 2008-07-10 16:08
    Wow it is amazing how much I have learned the past few days from this forum alone. I just wanted to put a shout out to thank all you guys for your help with my stupid little issues.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks

    NosePicker
Sign In or Register to comment.