Shop OBEX P1 Docs P2 Docs Learn Events
FIXED! (thanks Mike Green and PJ Allen) - Really really strange BASIC STAMP beh — Parallax Forums

FIXED! (thanks Mike Green and PJ Allen) - Really really strange BASIC STAMP beh

pcprogrammerpcprogrammer Posts: 5
edited 2008-03-17 17:28 in BASIC Stamp
So I recently bought a BS2, and had tons of fun getting it to flash lights and stuff. Then I figured I'd try some input stuff, where lights could flash corresponding to what buttons I pressed. I quickly programmed it. Very easy stuff, I figured. I was wrong, of course.

It seems that the BS2 is emitting a sort of electromagnetic field that extends to about a foot above the button I put in for the input. Whenever I insert my hand into that imaginary bubble, the light goes on. Whenever I take my hand out, the light goes off. I thought that was pretty neat at FIRST, but it isn't very useful. How do I get rid of this weird problem? Is there a diagram and some code somewhere that I can follow to see if it's an issue with how i set it up?

I know the BS2 isn't completely busted, because it still works with just output.

Please help!

Post Edited (pcprogrammer) : 3/16/2008 9:07:27 PM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-03-16 16:53
    If you could attach your code and a diagram of what you have maybe we could help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • phil kennyphil kenny Posts: 233
    edited 2008-03-16 16:59
    A simple sketch or description of how the input pin is connected to the button
    would also help.

    Do you have a pull up or pull down resistor on that pin?

    If not, then that could be the problem.

    phil
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-16 17:03
    An unconnected Stamp input pin is fairly sensitive to static charges and other induced electric fields. If you connect it to a button such that the pin is really unconnected if the button isn't pressed, it will act the way you describe. As phil noted, it's standard practice to connect a high value resistor (10K or higher usually) between the I/O pin and either Vdd (+5V) or Vss (ground) to set the default voltage that the I/O pin sees.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-16 17:15
    WAM_button.jpg
  • pcprogrammerpcprogrammer Posts: 5
    edited 2008-03-16 17:21
    Thanks everyone! PJ Allen, what's that IMG from? I'd love to get a copy of that 76+ page book! As well, my button has only two pins. Is there a workaround so that I can still somehow attach the 10k resistor?

    edit: my pushbutton looks exactly like this one:
    http://www.starshipmodeler.com/tech/bw_base/29PushButton.JPG
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-16 17:29
    The book is "What's a Microcontroller" and it is available from the Downloads section at the Parallax website ( www.parallax.com )

    The junction of the two resistors should go to one terminal and the +V (Vdd) wire should go to the other.

    http://www.parallax.com/tabid/535/Default.aspx

    Post Edit -- Link added

    Post Edited (PJ Allen) : 3/16/2008 5:36:16 PM GMT
  • pcprogrammerpcprogrammer Posts: 5
    edited 2008-03-16 20:17
    It's still not functioning. I followed the diagram in the book exactly. Still, I'm getting the strange invisible bubble (again, i'm guessing electromagnetic) that is sensing my hand as it nears the button.

    Here's how i have mine set up:

    mydiagramsc8.th.png

    (click for larger image)

    As well, here's my code (copied from the book):

    ' What's a Microcontroller - ReadPushbuttonState.bs2
    ' Check and send pushbutton state to Debug Terminal every 1/4 second.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DO
    DEBUG ? IN3
    PAUSE 250
    LOOP
    
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-16 20:29
    OK, enough with the "electromagnetic bubble" already.

    If you have one, try a capacitor (0.1 uF or so, not super-critical this) across the 10K (one lead to pin 3 and the other to GND.)

    The switch should go to +5V (Vdd), your drawing shows it connected to the battery's +.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-16 20:32
    I would carefully check your setup again. Your diagram and test program look mostly correct, but what you posted and what you actually have may be very different. You may have a bad connection involving the 10K resistor and its ground connection.

    Also, you should never attach logic elements (like the pushbutton and 220 ohm resistor) to anything other than a 5V regulated supply. The 220 ohm resistor will protect the Stamp pin from destruction, but it's still not good to do. If your "green rectangle" is a 24 pin Stamp module, then use the Vdd (+5V) pin which is the +5V output of the module's regulator. The 9V battery gets connected to Vin while the pushbutton gets connected to the Vdd pin.
  • pcprogrammerpcprogrammer Posts: 5
    edited 2008-03-16 20:32
    when you say +5v, where is that? i don't know where else to connect it besides the battery.

    edit: I did not see Mike Green's post until after I posted the above. Sorry! Mike, you and I must have posted at the same time!

    Post Edited (pcprogrammer) : 3/16/2008 8:53:46 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-16 20:38
    Physical Pin 21 of the Stamp.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-16 20:41
    Look at the description of the BS2 Stamp module in the Parallax Basic Stamp Manual and how to wire it up. You'll see that there are three pins used for power. One pin is the ground or Vss pin. Another is labelled Vin and is the input to the voltage regulator on the module. This can be connected to a source of +6V to +9V. There's another pin labelled Vdd which is the output of the +5V regulator. If you have some other source of regulated +5V, you can connect it directly to the Vdd pin (and ground) and not use the Vin pin or the regulator. If you're using the Vin pin, then the Vdd pin is a source of regulated +5V power and can be used for things like your pushbutton. It is limited in how much current it can supply (about 50 mA).
  • pcprogrammerpcprogrammer Posts: 5
    edited 2008-03-16 21:04
    Yes! I got it working! It seems as though the BS2 was being really sensitive, so I had to significantly lower the resistance from 10k ohms. Thanks a LOT everyone for your help! I just can't believe how newbie-friendly the atmosphere here is.

    [noparse]:)[/noparse]
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-17 17:28
    Hello,

    I hope the switch isn’t still connected to the 9V line on your board. That will damage the I/O pin of the BASIC Stamp over time. In the diagram you posted that is what you were doing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.