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

Floating input

JsavJsav Posts: 25
edited 2009-03-25 17:36 in BASIC Stamp
Howdy all,
··· My problem is that I'm using a pushbutton as a condition with which to initiate a bunch of actions, and I'm having trouble controlling what the basic stamp sees.

The circuit I'm using (x3) is given by page 90 of the What's a Microcontroller - Student Guide, or http://www.parallax.com/Portals/0/Downloads/docs/books/edu/Wamv2_2.pdf

When the pushbutton is depressed, IN3 reads 1 as long is it's depressed and the LED will blink on and off as suggested, however, when the pushbutton is not depressed IN3 has a tendancy to float between 1 and 0, and I'm not sure why. I can't program for actions that are based on the condition of IN3 (0 or 1) if it keeps floating between, obviously I want it to be 0 when left alone and be 1 when and only when the pushbutton is depressed.

Any suggestions on why IN3 is floating? or what I can do to remedy this.

It also happens on any input pin, not just 3.

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-03-25 16:04
    Jsav,

    Are you using a 10K pull-down resistor as suggested on page 90?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • JsavJsav Posts: 25
    edited 2009-03-25 16:16
    Yup, well it's more like 9.8k due to manufacturing error, they're all a little off, like 9.8k, 460ish and 218ish, all slightly lower, but is that enough to cause this problem?
  • JsavJsav Posts: 25
    edited 2009-03-25 16:24
    Here's an idea of my code with two LED's and 1 pushbutton

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    DO
    DEBUG ? IN5
    PAUSE 800
    DEBUG ? IN7
    PAUSE 800

    IF (IN5 = 1) THEN
    HIGH 13
    PAUSE 50
    LOW 13
    PAUSE 50
    ELSE
    PAUSE 100
    ENDIF

    IF (IN7 = 1) THEN
    HIGH 15
    PAUSE 50
    LOW 15
    PAUSE 50
    ELSE
    PAUSE 100
    ENDIF

    LOOP




    in this case, both LED's blink accordingly when the pushbutton is depressed, connected to pins 13 and 15 respectively, but again, the debug displays that pin5 and pin7 are floating between 1 and 0 when the pushbutton is left alone.
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-03-25 17:10
    I run you code and see the unnused pins (not pulled up) always at 0.

    I am using 100KOhm pullup and see always·1.

    Please explain what do you mean by "floating " between 0 and 1.

    Do you mean alternating between 0 an 1 ?·
  • JsavJsav Posts: 25
    edited 2009-03-25 17:15
    Yes I do mean alternating between 0 and 1 (on the debug screen based on the IN5·? prompt), I'll try it with different resistors, the 220's there to protect the input pins of the stamp, do u have a resistor there?
  • JsavJsav Posts: 25
    edited 2009-03-25 17:34
    Also, pull up or pull down, either situation results in a pin that alternates between 1 and 0 reguardless if the pushbutton is depressed
  • JsavJsav Posts: 25
    edited 2009-03-25 17:36
    I have resolved this problem, thank you both for the prompt replies. [noparse]:)[/noparse]
Sign In or Register to comment.